import{i as e,t}from"./jsx-runtime-Cx0BB4qO.js";import{Q as n}from"./workspace-D4nk9hec.js";import{i as r,o as i,t as a}from"./invariant-BeDuhpwN.js";import{O as o,a as s,d as c,n as l,t as u,u as d}from"./link-GOG-kXga.js";import{n as f,t as p}from"./useNavigate-CWOSRTQR.js";var m=`__root__`,h=class{get to(){return this._to}get id(){return this._id}get path(){return this._path}get fullPath(){return this._fullPath}constructor(e){if(this.init=e=>{this.originalIndex=e,this._branch=void 0;let t=this.options,n=!t?.path&&!t?.id;this.parentRoute=this.options.getParentRoute?.(),n?this._path=m:this.parentRoute||a();let r=n?m:t?.path;r&&r!==`/`&&(r=d(r));let i=t?.id||r,o=n?m:s((this.parentRoute.id===`__root__`?``:this.parentRoute.id)+`/`+(i??``));r===`__root__`&&(r=`/`);let l=o===`__root__`?`/`:r===void 0?this.parentRoute.fullPath:s(this.parentRoute.fullPath+`/`+r);this._path=r,this._id=o,this._fullPath=l,this._to=c(l)},this.addChildren=e=>this._addFileChildren(e),this._addFileChildren=e=>(Array.isArray(e)&&(this.children=e),typeof e==`object`&&e&&(this.children=Object.values(e)),this),this._addFileTypes=()=>this,this.updateLoader=e=>(Object.assign(this.options,e),this),this.update=e=>(Object.assign(this.options,e),this),this.lazy=e=>(this.lazyFn=e,this),this.redirect=e=>r({from:this.fullPath,...e}),this.options=e||{},this.isRoot=!e?.getParentRoute,e?.id&&e?.path)throw Error(`Route cannot have both an 'id' and a 'path' option.`)}},g=class{constructor({id:e}){this.notFound=e=>i({routeId:this.id,...e}),this.redirect=e=>r({from:this.id,...e}),this.id=e}},_=class extends h{constructor(e){super(e)}},v=e(n(),1),y=v.createContext(void 0),b=v.createContext(void 0),x={};function S(e,t){let n=v.useRef();return r=>{let i=e?.select?e.select(r):r;return e?.structuralSharing??t.options.defaultStructuralSharing?n.current=o(n.current,i):i}}function C(e){let t=f(),n=v.useContext(e.from?b:y),r=e.from??n,i=t.stores.getMatchStore(r),o=S(e,t),s=l(i,e=>e?o(e):x);if(s!==x)return s;(e.shouldThrow??!0)&&a()}function w(e){return C({from:e.from,strict:e.strict,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.loaderData):t.loaderData})}function T(e){let{select:t,...n}=e;return C({...n,select:e=>t?t(e.loaderDeps):e.loaderDeps})}function E(e){return C({from:e.from,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,strict:e.strict,select:t=>{let n=e.strict===!1?t.params:t._strictParams;return e.select?e.select(n):n}})}function D(e){return C({from:e.from,strict:e.strict,shouldThrow:e.shouldThrow,structuralSharing:e.structuralSharing,select:t=>e.select?e.select(t.search):t.search})}function O(e){return C({...e,select:t=>e.select?e.select(t.context):t.context})}var k=t();function A(e){return new j({id:e})}var j=class extends g{constructor({id:e}){super({id:e}),this.useMatch=e=>C({...e,from:this.id}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({...e,from:this.id}),this.useParams=e=>E({...e,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id,strict:!1}),this.useLoaderData=e=>w({...e,from:this.id,strict:!1}),this.useNavigate=()=>p({from:f().routesById[this.id].fullPath}),this.notFound=e=>i({routeId:this.id,...e}),this.Link=v.forwardRef((e,t)=>{let n=f().routesById[this.id].fullPath;return(0,k.jsx)(u,{ref:t,from:n,...e})})}},M=class extends h{constructor(e){super(e),this.useMatch=e=>C({...e,from:this.id}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({...e,from:this.id}),this.useParams=e=>E({...e,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id}),this.useLoaderData=e=>w({...e,from:this.id}),this.useNavigate=()=>p({from:this.fullPath}),this.Link=v.forwardRef((e,t)=>(0,k.jsx)(u,{ref:t,from:this.fullPath,...e}))}};function N(e){return new M(e)}function P(){return e=>I(e)}var F=class extends _{constructor(e){super(e),this.useMatch=e=>C({...e,from:this.id}),this.useRouteContext=e=>O({...e,from:this.id}),this.useSearch=e=>D({...e,from:this.id}),this.useParams=e=>E({...e,from:this.id}),this.useLoaderDeps=e=>T({...e,from:this.id}),this.useLoaderData=e=>w({...e,from:this.id}),this.useNavigate=()=>p({from:this.fullPath}),this.Link=v.forwardRef((e,t)=>(0,k.jsx)(u,{ref:t,from:this.fullPath,...e}))}};function I(e){return new F(e)}export{y as a,S as i,N as n,m as o,A as r,P as t};