@real-router/vue 0.22.2 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{a as e,i as t,r as n,t as r}from"./useRoute-BBfRYSpV.mjs";import{Fragment as i,KeepAlive as a,Suspense as o,computed as s,defineComponent as c,h as l,inject as u,isVNode as d,markRaw as f,onActivated as p,onDeactivated as m,onScopeDispose as h,provide as g,shallowRef as _,watch as v}from"vue";import{UNKNOWN_ROUTE as y,getNavigator as ee}from"@real-router/core";import{getRouteUtils as te,startsWithSegment as ne}from"@real-router/route-utils";import{createActiveSource as re,createDismissableError as ie,createRouteEnterGate as ae,createRouteNodeSource as oe,createRouteSource as se,getTransitionSource as b,guardLeaveListener as ce,primeErrorSource as le}from"@real-router/sources";import{getPluginApi as x}from"@real-router/core/api";import{putField as ue}from"@real-router/core/utils";function S(){return null}const C=c({name:`RouteView.Match`,props:{segment:{type:String,required:!0},exact:{type:Boolean,default:!1},fallback:{type:[Object,Function],default:void 0},keepAlive:{type:Boolean,default:!1}},render:S}),w=c({name:`RouteView.Self`,props:{fallback:{type:[Object,Function],default:void 0}},render:S}),T=c({name:`RouteView.NotFound`,render:S}),de=new Set([C,w,T]),fe=new Set([!0,``,`keep-alive`]);function pe(e,t,n){return n?e===t:ne(e,t)}function E(e){return fe.has(e)}function D(e,t){if(Array.isArray(e))for(let n of e)D(n,t);else if(d(e)){let{type:n}=e;de.has(n)?t.push(e):n===i&&D(e.children,t)}}function me(e,t){return e.type===T?(t.notFoundVNode??=e,!0):e.type===w&&(t.selfVNode===null&&(t.selfVNode=e,t.selfFallback=e.props?.fallback),!0)}function he(e,t,n){let r=e.props,i=r?.segment??``,a=r?.exact??!1;return{isActive:pe(t,n?`${n}.${i}`:i,a),fallback:r?.fallback}}function ge(e,t,n,r){if(r.selfVNode!==null&&t===n)return e.push(r.selfVNode),r.selfFallback;t===y&&r.notFoundVNode!==null&&e.push(r.notFoundVNode)}function _e(e,t,n){let r={selfVNode:null,selfFallback:void 0,notFoundVNode:null},i=!1,a,o=!1,s=[];for(let c of e){if(!o&&c.type===C){let e=c.props;E(e?.keepAlive)&&(o=!0)}if(me(c,r)||i)continue;let e=he(c,t,n);e.isActive&&(i=!0,a=e.fallback,s.push(c))}return i||(a=ge(s,t,n,r)),{rendered:s,activeMatchFound:i,fallback:a,hasPerMatchKA:o}}function O(e){let t=_(e.getSnapshot()),n=e.subscribe(()=>{t.value=e.getSnapshot()});return h(n),t}const k=()=>{let t=u(e);if(!t)throw Error(`useRouter must be used within a RouterProvider`);return t};function A(e){let t=k(),n=O(oe(t,e));return{navigator:ee(t),route:s(()=>n.value.route),previousRoute:s(()=>n.value.previousRoute)}}function j(e){return e.children?.default?.()??null}function M(e,t){let n=e.get(t);if(n)return n;let r=f(c({name:`KeepAlive-${t}`,setup(e,t){return()=>t.slots.default?.()}}));return e.set(t,r),r}function N(e,t){if(t===void 0)return e;let n=typeof t==`function`?t():t;return l(o,{},{default:()=>e,fallback:()=>n})}let P=null;function ve(){return P??=f(c({name:`KeepAlive-placeholder`,render(){return null}})),P}function ye(e,t,n){let r=e.props?.segment??`__not-found__`,i=M(t,r),o=j(e)??[];return N(l(a,null,{default:()=>l(i,{key:r},{default:()=>o})}),n)}function be(e,t,n){let r=e.props;if(E(r?.keepAlive)&&e.type===C){let n=r?.segment??`__not-found__`,o=M(t,n),s=j(e)??[];return l(i,[l(a,null,{default:()=>l(o,{key:n},{default:()=>s})})])}let o=j(e);return o?l(i,[l(a,null,{default:()=>l(ve())}),N(l(i,o),n)]):null}const xe=c({name:`RouteView`,props:{nodeName:{type:String,required:!0},keepAlive:{type:Boolean,default:!1}},setup(e,{slots:t}){let n=A(e.nodeName),r=new Map;return()=>{let a=n.route.value;if(!a)return null;let o=t.default?.(),s=[];D(o,s);let{rendered:c,fallback:u,hasPerMatchKA:d}=_e(s,a.name,e.nodeName);if(c.length===0)return null;let f=c[0];if(e.keepAlive)return ye(f,r,u);if(f.type!==C&&f.type!==w&&f.type!==T)return null;if(d)return be(f,r,u);let p=j(f);return p?N(l(i,p),u):null}}}),Se=Object.assign(xe,{Match:C,Self:w,NotFound:T}),F=Object.freeze({}),Ce=Object.freeze({}),I=`data-real-router-announcer`,we=Object.freeze({destroy:()=>{}}),L=`data-rr-announcer-refs`,R=`data-rr-announcer-generation`;function z(e){return Number(e.getAttribute(L))}function B(e,t){e.setAttribute(L,String(t))}function Te(e,t){if(typeof document>`u`)return we;let n=t?.prefix??`Navigated to `,r=t?.getAnnouncementText,i=!0,a=!1,o=!1,s=``,c=null,l,{element:u,generation:d}=De();B(u,z(u)+1);let f=(e,t)=>{s=e,clearTimeout(l),u.textContent=e,l=setTimeout(()=>{u.textContent=``,s=``},7e3),Ae(t)},p=setTimeout(()=>{if(a=!0,c!==null&&!o){let e=c;c=null,f(e,document.querySelector(`h1`))}},100),m=e.subscribe(({route:e})=>{if(i){i=!1;return}requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(o)return;let t=document.querySelector(`h1`),i=ke(e,n,r,t);if(i&&i!==s){if(!a){c=i;return}f(i,t)}})})});return{destroy(){if(o||(o=!0,m(),clearTimeout(l),clearTimeout(p),d!==V()))return;let e=z(u)-1;B(u,e),e===0&&Oe(u)}}}function V(){return Number(document.documentElement.getAttribute(R))}function Ee(){let e=document.documentElement,t=V()+1;return e.setAttribute(R,String(t)),t}function De(){let e=document.querySelector(`[${I}]`);if(e)return{element:e,generation:Number(e.getAttribute(R))};let t=document.createElement(`div`);return t.setAttribute(`style`,`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0`),t.setAttribute(`aria-live`,`assertive`),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(I,``),B(t,0),t.setAttribute(R,String(Ee())),(document.body??document.documentElement).prepend(t),{element:t,generation:Number(t.getAttribute(R))}}function Oe(e){e.remove()}function ke(e,t,n,r){if(n)try{let t=n(e);if(t)return t}catch(e){console.error(`[real-router] getAnnouncementText threw; falling back to default resolution.`,e)}let i=(r?.textContent??``).trim(),a=e.name.startsWith(`@@`)?``:e.name;return`${t}${i||document.title||a||globalThis.location.pathname}`}function Ae(e){e&&(e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`-1`),e.focus({preventScroll:!0}))}const H=Object.create,U=Object.freeze({destroy:()=>{}});function je(e,t){if(globalThis.window===void 0)return U;let n=t?.mode??`restore`;if(n===`native`)return U;let r=t?.anchorScrolling??!0,i=t?.scrollContainer,a=t?.behavior??`auto`,o=t?.storageKey??`real-router:scroll`,s,c=()=>{if(s!==void 0)return s;try{let e=sessionStorage.getItem(o),t=e?JSON.parse(e):void 0;s=Object.assign(H(null),t)}catch{s=H(null)}return s},l=(e,t)=>{try{let n=c();if(n[e]===t)return;n[e]=t,sessionStorage.setItem(o,JSON.stringify(n))}catch{}},u=history.scrollRestoration;try{history.scrollRestoration=`manual`}catch{}let d=()=>{let e=i?.();return e?e.scrollTop:globalThis.scrollY},f=e=>{let t=i?.();t?t.scrollTo({top:e,left:0,behavior:a}):globalThis.scrollTo({top:e,left:0,behavior:a})},p=0,m=e=>{if(!i){globalThis.scrollTo({top:e,left:0,behavior:a});return}let t=0,n=p+=1,r=()=>{if(g||n!==p)return;let o=i();if(o){if(o.scrollTo({top:e,left:0,behavior:a}),a!==`smooth`&&Math.abs(o.scrollTop-e)<=1)return}else globalThis.scrollTo({top:e,left:0,behavior:a});t>=10||(t+=1,requestAnimationFrame(r))};r()},h=e=>{let t=e.context?.url?.hash;if(t!==void 0){if(r&&t.length>0){let e=document.getElementById(t);if(e){e.scrollIntoView({behavior:a});return}}f(0);return}let n=globalThis.location.hash;if(r&&n.length>1){let e;try{e=decodeURIComponent(n.slice(1))}catch{e=n.slice(1)}let t=document.getElementById(e);if(t){t.scrollIntoView({behavior:a});return}}f(0)},g=!1,_=!0,v=e.subscribe(({route:e,previousRoute:t})=>{let r=e.context.navigation;t&&_&&l(W(t),d()),_=!1,requestAnimationFrame(()=>{if(!g){if(_=!0,n===`top`){h(e);return}if(e.transition?.reload||r?.navigationType===`reload`){m(c()[W(e)]??0);return}if(r?.direction===`back`||r?.navigationType===`traverse`){m(c()[W(e)]??0);return}e.transition?.replace||r?.navigationType===`replace`||h(e)}})}),y=()=>{let t=e.getState();t&&l(W(t),d())};return globalThis.addEventListener(`pagehide`,y),{destroy:()=>{g=!0,v(),globalThis.removeEventListener(`pagehide`,y);try{history.scrollRestoration=u}catch{}}}}function W(e){return e.path}const G=Object.freeze({destroy:()=>{}}),K=e=>e.context?.url,Me=e=>{let t=null,n=1/0,r=null,i=-1/0;for(let a of e){if(!a.isIntersecting)continue;let e=a.rootBounds?.top??0,o=a.boundingClientRect.top-e;o>=0?o<n&&(t=a,n=o):o>i&&(r=a,i=o)}return t??r},Ne=(e,t)=>{let n=null,r=e=>{let n=e.context;n&&n.url===void 0&&(console.warn(`[real-router] scroll-spy: state.context.url is not claimed. Spy requires browser-plugin or navigation-plugin. Disabling.`),t())},i=e.getState();if(i)r(i);else{let t=!1;n=e.subscribe(({route:e})=>{t||(t=!0,r(e),n?.(),n=null)})}return{destroy(){n?.(),n=null}}},Pe=e=>{let t=!1,n=null,r=null,i=null,a=()=>{n!==null&&(clearTimeout(n),n=null),i&&(r??globalThis).removeEventListener(`scrollend`,i),i=null,r=null,t=!1};return{get active(){return t},start(){a(),t=!0;let o=()=>{a()};i=o,r=e(),(r??globalThis).addEventListener(`scrollend`,o,{once:!0}),n=setTimeout(o,500)},destroy(){a()}}},Fe=(e,t)=>{let n=null,r=null;return{schedule(){n===null&&(n=requestAnimationFrame(()=>{n=null,r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,e()},t)}))},destroy(){n!==null&&(cancelAnimationFrame(n),n=null),r!==null&&(clearTimeout(r),r=null)}}},Ie=(e,t,n,r,i,a)=>{let o=new Set,s=new Map,c=!1,l=null,u=e=>{if(!a()){for(let t of e)s.set(t.target,t);r()}},d=e=>new IntersectionObserver(u,{root:e,rootMargin:t,threshold:0}),f=n(),p=d(f),m=()=>{let t=n()??document,r;try{r=t.querySelectorAll(e)}catch{i();return}let a=new Set;for(let e of r){let t=e.id;t&&!c&&(a.has(t)&&(c=!0,console.warn(`[real-router] scroll-spy: duplicate id "${t}" observed. Selection picks the topmost visible match deterministically.`)),a.add(t)),!o.has(e)&&(p.observe(e),o.add(e))}},h={childList:!0,subtree:!0,attributes:!0,attributeFilter:[`id`]},g=null,_=()=>{for(let e of o)e.isConnected||(p.unobserve(e),o.delete(e),s.delete(e));let e=n();e!==f&&(f=e,p.disconnect(),p=d(e),o.clear(),s.clear(),g?.disconnect(),g?.observe(e??document.body,h)),m()};return m(),g=new MutationObserver(()=>{l!==null&&clearTimeout(l),l=setTimeout(()=>{l=null,_()},250)}),g.observe(f??document.body,h),{pending:s,isContainerDetached:()=>f!==null&&!f.isConnected,reconcile:_,destroy(){p.disconnect(),g.disconnect(),l!==null&&(clearTimeout(l),l=null),o.clear(),s.clear()}}};function Le(e,t){if(typeof document>`u`||typeof IntersectionObserver>`u`)return G;let{selector:n}=t;if(!n)return G;let r=t.rootMargin??`-20% 0px -60% 0px`,i=t.scrollContainer,a=()=>i?.()??null,o=!1,s=!1,c=!1,l=()=>s||o,u=null,d=b(e),f=Ne(e,()=>{s=!0}),p=Pe(a),m=Fe(()=>{u?.()},150),h=Ie(n,r,a,()=>{m.schedule()},()=>{s||(s=!0,console.warn(`[real-router] scroll-spy: invalid selector "${n}". Disabling.`))},l);u=()=>{if(o||s){h.pending.clear();return}if(d.getSnapshot().isTransitioning||p.active)return;let t=Me(h.pending.values());if(h.pending.clear(),!t)return;let n=t.target.id;if(!n)return;let r=e.getState();if(!r||n===K(r)?.hash)return;let i={hash:n,replace:!0,force:!0,hashChange:!0};c=!0,e.navigate(r.name,r.params,r.search,i).catch(()=>{}).finally(()=>{c=!1})};let g=e.subscribe(({route:e})=>{c||(h.isContainerDetached()&&h.reconcile(),K(e)?.hashChanged&&p.start())});return{destroy(){o=!0,g(),h.destroy(),m.destroy(),p.destroy(),f.destroy()}}}const Re=Object.freeze({destroy:()=>{}});function ze(e){if(typeof document>`u`||typeof document.startViewTransition!=`function`)return Re;let t=null,n=null,r=!1,i=()=>{t?.(),t=null},a=e.subscribeLeave(({signal:e})=>{if(!e.aborted)return r=!1,i(),new Promise(a=>{let o=new Promise(e=>{t=e});e.addEventListener(`abort`,()=>{r||(i(),n?.skipTransition?.(),a())},{once:!0});try{n=document.startViewTransition(()=>(a(),o))}catch{i(),a()}})}),o=e.subscribe(()=>{let e=t;if(r=!0,t=null,e===null)n=null;else{let t=n;setTimeout(()=>{e(),n===t&&(n=null)},0)}});return{destroy:()=>{a(),o(),n?.skipTransition?.(),n=null,i()}}}const q=Object.keys;function J(e,t,n,r){return e===void 0?{name:t,params:n,search:r}:((t!==``||n!==void 0||r!==void 0)&&console.warn("[real-router] <Link> received both `to` and channel props (routeName / routeParams / routeSearch). `to` wins; the channel props are ignored. Use one form or the other."),{name:e.name,params:e.params,search:e.search})}function Be(e){return e.button===0&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey}function Ve(e){return!!e&&e!==`_self`}function He(e){return e?.tagName===`A`&&Ve(e.getAttribute(`target`))}function Ue(e){return encodeURI(e).replaceAll(`#`,`%23`)}function We(e,t,n,r,i){try{let a;i!==void 0&&(a=i.startsWith(`#`)?i.slice(1):i);let o=e.buildUrl;if(o){let e=o(t,n,r,a===void 0?void 0:{hash:a});if(typeof e==`string`&&e.length>0)return e}let s;try{let i=x(e).forwardState(t,n,r);s=e.buildPath(i.name,i.params,i.search)}catch{s=void 0}let c=s??e.buildPath(t,n,r);if(typeof c!=`string`||c.length===0){console.error(`[real-router] Route "${t}" yielded an empty path. The element will render without an href attribute.`);return}return a?`${c}#${Ue(a)}`:c}catch{console.error(`[real-router] Route "${t}" is not defined. The element will render without an href attribute.`);return}}function Ge(e,t,n,r,i,a){let o={...a};i!==void 0&&ue(o,`hash`,i);let s=e.getState(),c=r;if(s!==void 0){let a=r??s.search;if(e.isActiveRoute(t,n,a,!0,!1)){let e=s.context?.url?.hash??``;e!==(i??e)&&(o.force=!0,o.hashChange=!0,c=a)}}return e.navigate(t,n,c,o)}const Ke=/\s/,qe=/\S+/g;function Je(e){return Ke.test(e)?e.match(qe)??[]:[e]}function Ye(e,t,n){if(e&&t){let e=Je(t);if(e.length===0)return n??void 0;if(!n)return e.join(` `);let r=Je(n),i=new Set(r);for(let t of e)i.has(t)||(i.add(t),r.push(t));return r.join(` `)}return n??void 0}function Xe(e,t){if(Object.is(e,t))return!0;if(!e||!t)return!1;let n=q(e),r=q(t);if(n.length!==r.length)return!1;let i=e,a=t;for(let e of n)if(!r.includes(e)||!Object.is(i[e],a[e]))return!1;return!0}function Ze(e){if(!e)return;let t=e.tagName;t!==`A`&&t!==`BUTTON`&&(e.hasAttribute(`role`)||e.setAttribute(`role`,`link`),e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`))}function Qe(e,t){try{e(t)}catch(e){console.error(`[real-router] A <Link> @click handler threw; navigation is unaffected.`,e)}}function $e(e,t){if(typeof e==`function`){Qe(e,t);return}if(Array.isArray(e)){let n=e;for(let e of n)if(typeof e==`function`&&(Qe(e,t),t.defaultPrevented))return}}const et=c({name:`Link`,inheritAttrs:!1,props:{routeName:{type:String,default:void 0},to:{type:Object,default:void 0},routeParams:{type:Object,default:void 0},routeSearch:{type:Object,default:void 0},routeOptions:{type:Object,default:()=>Ce},class:{type:String,default:void 0},activeClassName:{type:String,default:`active`},activeStrict:{type:Boolean,default:!1},ignoreQueryParams:{type:Boolean,default:!0},target:{type:String,default:void 0},hash:{type:String,default:void 0}},setup(e,{slots:t,attrs:n}){let r=k(),i=_(!1),a=e.routeParams,o=s(()=>{let t=e.routeParams;return Xe(a,t)||(a=t),a});v(()=>[e.routeName,o.value,e.routeSearch,e.to,e.activeStrict,e.ignoreQueryParams,e.hash],([e,t,n,a,o,s,c],l,u)=>{let d=J(a,e??``,t,n),f=re(r,d.name,d.params,d.search,o,s,c);i.value=f.getSnapshot(),u(f.subscribe(()=>{i.value=f.getSnapshot()}))},{immediate:!0,flush:`sync`});let c=s(()=>{let t=J(e.to,e.routeName??``,o.value,e.routeSearch);return We(r,t.name,t.params??F,t.search,e.hash)}),u=s(()=>Ye(i.value,e.activeClassName,e.class)),d=t=>{if(n.onClick!==void 0&&n.onClick!==null&&($e(n.onClick,t),t.defaultPrevented)||!Be(t)||Ve(e.target))return;t.preventDefault();let i=J(e.to,e.routeName??``,e.routeParams,e.routeSearch);Ge(r,i.name,i.params??F,i.search,e.hash,e.routeOptions).catch(()=>{})};return()=>{let r={...n};return delete r.onClick,l(`a`,{...r,href:c.value,class:u.value,target:e.target,onClick:d},t.default?.())}}}),tt=c({name:`RouterErrorBoundary`,props:{fallback:{type:Function,required:!0},onError:{type:Function,default:void 0}},setup(e,{slots:t}){let n=k(),r=O(ie(n));return v(()=>r.value.version,()=>{r.value.error&&e.onError?.(r.value.error,r.value.toRoute,r.value.fromRoute)},{immediate:!0}),()=>{let n=t.default?.()??[],a=r.value.error?e.fallback(r.value.error,r.value.resetError):null;return l(i,null,[...n,a])}}}),Y=[];function nt(e){return Y.push(e),()=>{let t=Y.lastIndexOf(e);t!==-1&&Y.splice(t,1)}}function rt(){let e=Y.at(-1);if(!e)throw Error(`v-link directive requires a RouterProvider ancestor. Make sure RouterProvider is mounted.`);return e}const X=new WeakMap;function it(e){return e==null?(console.error(`[real-router] v-link directive received null/undefined value. The element will not be wired for navigation.`),!1):typeof e.name==`string`||(console.error("[real-router] v-link directive value is missing a string `name` field. The element will not be wired for navigation."),!1)}function at(e,t,n){return r=>{Be(r)&&!He(n)&&(r.preventDefault(),e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{}))}}function ot(e,t,n){return r=>{r.key===`Enter`&&!(n instanceof HTMLButtonElement)&&!He(n)&&e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{})}}function Z(e,t,n){let r=at(t,n,e),i=ot(t,n,e);e.addEventListener(`click`,r),e.addEventListener(`keydown`,i),X.set(e,{click:r,keydown:i})}function st(e){let t=X.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),X.delete(e))}const ct={mounted(e,t){let n=rt();Ze(e),e.style.cursor=`pointer`,it(t.value)&&Z(e,n,t.value)},updated(e,t){if(t.value===t.oldValue)return;let n=rt();st(e),it(t.value)&&Z(e,n,t.value)},beforeUnmount(e){st(e)}},lt=()=>{let e=u(n);if(!e)throw Error(`useNavigator must be used within a RouterProvider`);return e},ut=()=>{let e=k();return te(x(e).getTree())};function dt(){let e=k();return O(b(e))}function ft(e,t){let n=k(),r=t?.skipSameRoute??!0,i=!1;p(()=>{i=!1}),m(()=>{i=!0});let a=ce(e,{skipSameRoute:r}),o=n.subscribeLeave(e=>{if(!i)return a(e)});h(o)}function pt(e,t){let{route:n,previousRoute:i}=r(),a=t?.skipSameRoute??!0,o=ae(),s=!1;p(()=>{s=!1}),m(()=>{s=!0}),v(n,t=>{if(s)return;let n=o(t,i.value,a);n&&e(n)})}function Q(e){let t=ee(e),n=se(e),r=n.getSnapshot(),i=_(r.route),a=_(r.previousRoute);return{navigator:t,route:i,previousRoute:a,unsubscribe:n.subscribe(()=>{let e=n.getSnapshot();i.value=e.route,a.value=e.previousRoute})}}function mt(r){return{install(i){let a=nt(r),{navigator:o,route:s,previousRoute:c,unsubscribe:l}=Q(r);`onUnmount`in i&&i.onUnmount(()=>{a(),l()}),i.provide(e,r),i.provide(n,o),i.provide(t,{navigator:o,route:s,previousRoute:c})}}}function $(e,t){v(e,(e,n,r)=>{let i=t(e);i&&r(()=>{i.destroy()})},{immediate:!0})}const ht=c({name:`RouterProvider`,props:{router:{type:Object,required:!0},announceNavigation:{type:[Boolean,Object],default:!1},scrollRestoration:{type:Object},scrollSpy:{type:Object},viewTransitions:{type:Boolean,default:!1}},setup(r,{slots:i}){$(()=>{let e=r.announceNavigation,t=e!==!1,n=typeof e==`object`?e.prefix:void 0;return[r.router,t,n]},([e,t])=>{let n=r.announceNavigation;return t?Te(e,typeof n==`object`?n:void 0):void 0}),$(()=>[r.router,r.scrollRestoration!==void 0,r.scrollRestoration?.mode,r.scrollRestoration?.anchorScrolling,r.scrollRestoration?.behavior,r.scrollRestoration?.storageKey],([e,t,n,i,a,o])=>{if(t)return je(e,{mode:n,anchorScrolling:i,behavior:a,storageKey:o,scrollContainer:r.scrollRestoration?.scrollContainer})}),$(()=>[r.router,r.scrollSpy!==void 0&&r.scrollSpy.selector!==``,r.scrollSpy?.selector,r.scrollSpy?.rootMargin],([e,t,n,i])=>{if(t&&n)return Le(e,{selector:n,rootMargin:i,scrollContainer:r.scrollSpy?.scrollContainer})}),$(()=>[r.router,r.viewTransitions],([e,t])=>t?ze(e):void 0);let a=typeof document>`u`?void 0:nt(r.router);a&&h(a),le(r.router);let{navigator:o,route:s,previousRoute:c,unsubscribe:l}=Q(r.router);return h(l),g(e,r.router),g(n,o),g(t,{navigator:o,route:s,previousRoute:c}),()=>i.default?.()}});export{et as Link,n as NavigatorKey,t as RouteKey,Se as RouteView,tt as RouterErrorBoundary,e as RouterKey,ht as RouterProvider,mt as createRouterPlugin,lt as useNavigator,r as useRoute,pt as useRouteEnter,ft as useRouteExit,A as useRouteNode,ut as useRouteUtils,k as useRouter,dt as useRouterTransition,ct as vLink};
1
+ import{a as e,i as t,r as n,t as r}from"./useRoute-BBfRYSpV.mjs";import{Fragment as i,KeepAlive as a,Suspense as o,computed as s,defineComponent as c,h as l,inject as u,isVNode as d,markRaw as f,onActivated as p,onDeactivated as m,onScopeDispose as h,provide as g,shallowRef as _,watch as v}from"vue";import{UNKNOWN_ROUTE as y,getNavigator as ee}from"@real-router/core";import{getRouteUtils as te,startsWithSegment as ne}from"@real-router/route-utils";import{createActiveSource as re,createDismissableError as ie,createRouteEnterGate as ae,createRouteNodeSource as oe,createRouteSource as se,getTransitionSource as b,guardLeaveListener as ce,primeErrorSource as le}from"@real-router/sources";import{getPluginApi as x}from"@real-router/core/api";import{putField as ue}from"@real-router/core/utils";function S(){return null}const C=c({name:`RouteView.Match`,props:{segment:{type:String,required:!0},exact:{type:Boolean,default:!1},fallback:{type:[Object,Function],default:void 0},keepAlive:{type:Boolean,default:!1}},render:S}),w=c({name:`RouteView.Self`,props:{fallback:{type:[Object,Function],default:void 0}},render:S}),T=c({name:`RouteView.NotFound`,render:S}),de=new Set([C,w,T]),fe=new Set([!0,``,`keep-alive`]);function pe(e,t,n){return n?e===t:ne(e,t)}function E(e){return fe.has(e)}function D(e,t){if(Array.isArray(e))for(let n of e)D(n,t);else if(d(e)){let{type:n}=e;de.has(n)?t.push(e):n===i&&D(e.children,t)}}function me(e,t){return e.type===T?(t.notFoundVNode??=e,!0):e.type===w&&(t.selfVNode===null&&(t.selfVNode=e,t.selfFallback=e.props?.fallback),!0)}function he(e,t,n){let r=e.props,i=r?.segment??``,a=r?.exact??!1;return{isActive:pe(t,n?`${n}.${i}`:i,a),fallback:r?.fallback}}function ge(e,t,n,r){if(r.selfVNode!==null&&t===n)return e.push(r.selfVNode),r.selfFallback;t===y&&r.notFoundVNode!==null&&e.push(r.notFoundVNode)}function _e(e,t,n){let r={selfVNode:null,selfFallback:void 0,notFoundVNode:null},i=!1,a,o=!1,s=[];for(let c of e){if(!o&&c.type===C){let e=c.props;E(e?.keepAlive)&&(o=!0)}if(me(c,r)||i)continue;let e=he(c,t,n);e.isActive&&(i=!0,a=e.fallback,s.push(c))}return i||(a=ge(s,t,n,r)),{rendered:s,activeMatchFound:i,fallback:a,hasPerMatchKA:o}}function O(e){let t=_(e.getSnapshot()),n=e.subscribe(()=>{t.value=e.getSnapshot()});return h(n),t}const k=()=>{let t=u(e);if(!t)throw Error(`useRouter must be used within a RouterProvider`);return t};function A(e){let t=k(),n=O(oe(t,e));return{navigator:ee(t),route:s(()=>n.value.route),previousRoute:s(()=>n.value.previousRoute)}}function j(e){return e.children?.default?.()??null}function M(e,t){let n=e.get(t);if(n)return n;let r=f(c({name:`KeepAlive-${t}`,setup(e,t){return()=>t.slots.default?.()}}));return e.set(t,r),r}function N(e,t){if(t===void 0)return e;let n=typeof t==`function`?t():t;return l(o,{},{default:()=>e,fallback:()=>n})}let P=null;function ve(){return P??=f(c({name:`KeepAlive-placeholder`,render(){return null}})),P}function ye(e,t,n){let r=e.props?.segment??`__not-found__`,i=M(t,r),o=j(e)??[];return N(l(a,null,{default:()=>l(i,{key:r},{default:()=>o})}),n)}function be(e,t,n){let r=e.props;if(E(r?.keepAlive)&&e.type===C){let n=r?.segment??`__not-found__`,o=M(t,n),s=j(e)??[];return l(i,[l(a,null,{default:()=>l(o,{key:n},{default:()=>s})})])}let o=j(e);return o?l(i,[l(a,null,{default:()=>l(ve())}),N(l(i,o),n)]):null}const xe=c({name:`RouteView`,props:{nodeName:{type:String,required:!0},keepAlive:{type:Boolean,default:!1}},setup(e,{slots:t}){let n=A(e.nodeName),r=new Map;return()=>{let a=n.route.value;if(!a)return null;let o=t.default?.(),s=[];D(o,s);let{rendered:c,fallback:u,hasPerMatchKA:d}=_e(s,a.name,e.nodeName);if(c.length===0)return null;let f=c[0];if(e.keepAlive)return ye(f,r,u);if(f.type!==C&&f.type!==w&&f.type!==T)return null;if(d)return be(f,r,u);let p=j(f);return p?N(l(i,p),u):null}}}),Se=Object.assign(xe,{Match:C,Self:w,NotFound:T}),F=Object.freeze({}),Ce=Object.freeze({}),I=`data-real-router-announcer`,we=Object.freeze({destroy:()=>{}}),L=`data-rr-announcer-refs`,R=`data-rr-announcer-generation`;function z(e){return Number(e.getAttribute(L))}function B(e,t){e.setAttribute(L,String(t))}function Te(e,t){if(typeof document>`u`)return we;let n=t?.prefix??`Navigated to `,r=t?.getAnnouncementText,i=!0,a=!1,o=!1,s=``,c=null,l,{element:u,generation:d}=De();B(u,z(u)+1);let f=(e,t)=>{s=e,clearTimeout(l),u.textContent=e,l=setTimeout(()=>{u.textContent=``,s=``},7e3),Ae(t)},p=setTimeout(()=>{if(a=!0,c!==null&&!o){let e=c;c=null,f(e,document.querySelector(`h1`))}},100),m=e.subscribe(({route:e})=>{if(i){i=!1;return}requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(o)return;let t=document.querySelector(`h1`),i=ke(e,n,r,t);if(i&&i!==s){if(!a){c=i;return}f(i,t)}})})});return{destroy(){if(o||(o=!0,m(),clearTimeout(l),clearTimeout(p),d!==V()))return;let e=z(u)-1;B(u,e),e===0&&Oe(u)}}}function V(){return Number(document.documentElement.getAttribute(R))}function Ee(){let e=document.documentElement,t=V()+1;return e.setAttribute(R,String(t)),t}function De(){let e=document.querySelector(`[${I}]`);if(e)return{element:e,generation:Number(e.getAttribute(R))};let t=document.createElement(`div`);return t.setAttribute(`style`,`position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);clip-path:inset(50%);white-space:nowrap;border:0`),t.setAttribute(`aria-live`,`assertive`),t.setAttribute(`aria-atomic`,`true`),t.setAttribute(I,``),B(t,0),t.setAttribute(R,String(Ee())),(document.body??document.documentElement).prepend(t),{element:t,generation:Number(t.getAttribute(R))}}function Oe(e){e.remove()}function ke(e,t,n,r){if(n)try{let t=n(e);if(t)return t}catch(e){console.error(`[real-router] getAnnouncementText threw; falling back to default resolution.`,e)}let i=(r?.textContent??``).trim(),a=e.name.startsWith(`@@`)?``:e.name;return`${t}${i||document.title||a||globalThis.location.pathname}`}function Ae(e){e&&(e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`-1`),e.focus({preventScroll:!0}))}const H=Object.create,U=Object.freeze({destroy:()=>{}});function je(e,t){if(globalThis.window===void 0)return U;let n=t?.mode??`restore`;if(n===`native`)return U;let r=t?.anchorScrolling??!0,i=t?.scrollContainer,a=t?.behavior??`auto`,o=t?.storageKey??`real-router:scroll`,s,c=()=>{if(s!==void 0)return s;try{let e=sessionStorage.getItem(o),t=e?JSON.parse(e):void 0;s=Object.assign(H(null),t)}catch{s=H(null)}return s},l=(e,t)=>{try{let n=c();if(n[e]===t)return;n[e]=t,sessionStorage.setItem(o,JSON.stringify(n))}catch{}},u=history.scrollRestoration;try{history.scrollRestoration=`manual`}catch{}let d=()=>{let e=i?.();return e?e.scrollTop:globalThis.scrollY},f=e=>{let t=i?.();t?t.scrollTo({top:e,left:0,behavior:a}):globalThis.scrollTo({top:e,left:0,behavior:a})},p=0,m=e=>{if(!i){globalThis.scrollTo({top:e,left:0,behavior:a});return}let t=0,n=p+=1,r=()=>{if(g||n!==p)return;let o=i();if(o){if(o.scrollTo({top:e,left:0,behavior:a}),a!==`smooth`&&Math.abs(o.scrollTop-e)<=1)return}else globalThis.scrollTo({top:e,left:0,behavior:a});t>=10||(t+=1,requestAnimationFrame(r))};r()},h=e=>{let t=e.context?.url?.hash;if(t!==void 0){if(r&&t.length>0){let e=document.getElementById(t);if(e){e.scrollIntoView({behavior:a});return}}f(0);return}let n=globalThis.location.hash;if(r&&n.length>1){let e;try{e=decodeURIComponent(n.slice(1))}catch{e=n.slice(1)}let t=document.getElementById(e);if(t){t.scrollIntoView({behavior:a});return}}f(0)},g=!1,_=!0,v=e.subscribe(({route:e,previousRoute:t})=>{let r=e.context.navigation;t&&_&&l(W(t),d()),_=!1,requestAnimationFrame(()=>{if(!g){if(_=!0,n===`top`){h(e);return}if(e.transition?.reload||r?.navigationType===`reload`){m(c()[W(e)]??0);return}if(r?.direction===`back`||r?.navigationType===`traverse`){m(c()[W(e)]??0);return}e.transition?.replace||r?.navigationType===`replace`||h(e)}})}),y=()=>{let t=e.getState();t&&l(W(t),d())};return globalThis.addEventListener(`pagehide`,y),{destroy:()=>{g=!0,v(),globalThis.removeEventListener(`pagehide`,y);try{history.scrollRestoration=u}catch{}}}}function W(e){return e.path}const G=Object.freeze({destroy:()=>{}}),K=e=>e.context?.url,Me=e=>{let t=null,n=1/0,r=null,i=-1/0;for(let a of e){if(!a.isIntersecting)continue;let e=a.rootBounds?.top??0,o=a.boundingClientRect.top-e;o>=0?o<n&&(t=a,n=o):o>i&&(r=a,i=o)}return t??r},Ne=(e,t)=>{let n=null,r=e=>{let n=e.context;n&&n.url===void 0&&(console.warn(`[real-router] scroll-spy: state.context.url is not claimed. Spy requires browser-plugin or navigation-plugin. Disabling.`),t())},i=e.getState();if(i)r(i);else{let t=!1;n=e.subscribe(({route:e})=>{t||(t=!0,r(e),n?.(),n=null)})}return{destroy(){n?.(),n=null}}},Pe=e=>{let t=!1,n=null,r=null,i=null,a=()=>{n!==null&&(clearTimeout(n),n=null),i&&(r??globalThis).removeEventListener(`scrollend`,i),i=null,r=null,t=!1};return{get active(){return t},start(){a(),t=!0;let o=()=>{a()};i=o,r=e(),(r??globalThis).addEventListener(`scrollend`,o,{once:!0}),n=setTimeout(o,500)},destroy(){a()}}},Fe=(e,t)=>{let n=null,r=null;return{schedule(){n===null&&(n=requestAnimationFrame(()=>{n=null,r!==null&&clearTimeout(r),r=setTimeout(()=>{r=null,e()},t)}))},destroy(){n!==null&&(cancelAnimationFrame(n),n=null),r!==null&&(clearTimeout(r),r=null)}}},Ie=(e,t,n,r,i,a)=>{let o=new Set,s=new Map,c=!1,l=null,u=e=>{if(!a()){for(let t of e)s.set(t.target,t);r()}},d=e=>new IntersectionObserver(u,{root:e,rootMargin:t,threshold:0}),f=n(),p=d(f),m=()=>{let t=n()??document,r;try{r=t.querySelectorAll(e)}catch{i();return}let a=new Set;for(let e of r){let t=e.id;t&&!c&&(a.has(t)&&(c=!0,console.warn(`[real-router] scroll-spy: duplicate id "${t}" observed. Selection picks the topmost visible match deterministically.`)),a.add(t)),!o.has(e)&&(p.observe(e),o.add(e))}},h={childList:!0,subtree:!0,attributes:!0,attributeFilter:[`id`]},g=null,_=()=>{for(let e of o)e.isConnected||(p.unobserve(e),o.delete(e),s.delete(e));let e=n();e!==f&&(f=e,p.disconnect(),p=d(e),o.clear(),s.clear(),g?.disconnect(),g?.observe(e??document.body,h)),m()};return m(),g=new MutationObserver(()=>{l!==null&&clearTimeout(l),l=setTimeout(()=>{l=null,_()},250)}),g.observe(f??document.body,h),{pending:s,isContainerDetached:()=>f!==null&&!f.isConnected,reconcile:_,destroy(){p.disconnect(),g.disconnect(),l!==null&&(clearTimeout(l),l=null),o.clear(),s.clear()}}};function Le(e,t){if(typeof document>`u`||typeof IntersectionObserver>`u`)return G;let{selector:n}=t;if(!n)return G;let r=t.rootMargin??`-20% 0px -60% 0px`,i=t.scrollContainer,a=()=>i?.()??null,o=!1,s=!1,c=!1,l=()=>s||o,u=null,d=b(e),f=Ne(e,()=>{s=!0}),p=Pe(a),m=Fe(()=>{u?.()},150),h=Ie(n,r,a,()=>{m.schedule()},()=>{s||(s=!0,console.warn(`[real-router] scroll-spy: invalid selector "${n}". Disabling.`))},l);u=()=>{if(o||s){h.pending.clear();return}if(d.getSnapshot().isTransitioning||p.active)return;let t=Me(h.pending.values());if(h.pending.clear(),!t)return;let n=t.target.id;if(!n)return;let r=e.getState();if(!r||n===K(r)?.hash)return;let i={hash:n,replace:!0,force:!0,hashChange:!0};c=!0,e.navigate(r.name,r.params,r.search,i).catch(()=>{}).finally(()=>{c=!1})};let g=e.subscribe(({route:e})=>{c||(h.isContainerDetached()&&h.reconcile(),K(e)?.hashChanged&&p.start())});return{destroy(){o=!0,g(),h.destroy(),m.destroy(),p.destroy(),f.destroy()}}}const Re=Object.freeze({destroy:()=>{}});function ze(e){if(typeof document>`u`||typeof document.startViewTransition!=`function`)return Re;let t=null,n=null,r=!1,i=()=>{t?.(),t=null},a=e.subscribeLeave(({signal:e})=>{if(!e.aborted)return r=!1,i(),new Promise(a=>{let o=new Promise(e=>{t=e});e.addEventListener(`abort`,()=>{r||(i(),n?.skipTransition?.(),a())},{once:!0});try{n=document.startViewTransition(()=>(a(),o))}catch{i(),a()}})}),o=e.subscribe(()=>{let e=t;if(r=!0,t=null,e===null)n=null;else{let t=n;setTimeout(()=>{e(),n===t&&(n=null)},0)}});return{destroy:()=>{a(),o(),n?.skipTransition?.(),n=null,i()}}}const q=Object.keys;function J(e,t,n,r){return e===void 0?{name:t,params:n,search:r}:((t!==``||n!==void 0||r!==void 0)&&console.warn("[real-router] <Link> received both `to` and channel props (routeName / routeParams / routeSearch). `to` wins; the channel props are ignored. Use one form or the other."),{name:e.name,params:e.params,search:e.search})}function Be(e){return e.button===0&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey}function Ve(e){return!!e&&e!==`_self`}function He(e){return e?.tagName===`A`&&Ve(e.getAttribute(`target`))}function Ue(e){return encodeURI(e).replaceAll(`#`,`%23`)}function We(e,t,n,r,i){try{let a;i!==void 0&&(a=i.startsWith(`#`)?i.slice(1):i);let o=e.buildUrl;if(o){let e=o(t,n,r,a===void 0?void 0:{hash:a});if(typeof e==`string`&&e.length>0)return e}let s;try{let i=x(e),a=i.forwardState(t,n,r);s=i.buildPathResolved(a.name,a.params,a.search)}catch{s=void 0}let c=s??e.buildPath(t,n,r);if(typeof c!=`string`||c.length===0){console.error(`[real-router] Route "${t}" yielded an empty path. The element will render without an href attribute.`);return}return a?`${c}#${Ue(a)}`:c}catch{console.error(`[real-router] Route "${t}" is not defined. The element will render without an href attribute.`);return}}function Ge(e,t,n,r,i,a){let o={...a};i!==void 0&&ue(o,`hash`,i);let s=e.getState(),c=r;if(s!==void 0){let a=r??s.search;if(e.isActiveRoute(t,n,a,!0,!1)){let e=s.context?.url?.hash??``;e!==(i??e)&&(o.force=!0,o.hashChange=!0,c=a)}}return e.navigate(t,n,c,o)}const Ke=/\s/,qe=/\S+/g;function Je(e){return Ke.test(e)?e.match(qe)??[]:[e]}function Ye(e,t,n){if(e&&t){let e=Je(t);if(e.length===0)return n??void 0;if(!n)return e.join(` `);let r=Je(n),i=new Set(r);for(let t of e)i.has(t)||(i.add(t),r.push(t));return r.join(` `)}return n??void 0}function Xe(e,t){if(Object.is(e,t))return!0;if(!e||!t)return!1;let n=q(e),r=q(t);if(n.length!==r.length)return!1;let i=e,a=t;for(let e of n)if(!r.includes(e)||!Object.is(i[e],a[e]))return!1;return!0}function Ze(e){if(!e)return;let t=e.tagName;t!==`A`&&t!==`BUTTON`&&(e.hasAttribute(`role`)||e.setAttribute(`role`,`link`),e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`0`))}function Qe(e,t){try{e(t)}catch(e){console.error(`[real-router] A <Link> @click handler threw; navigation is unaffected.`,e)}}function $e(e,t){if(typeof e==`function`){Qe(e,t);return}if(Array.isArray(e)){let n=e;for(let e of n)if(typeof e==`function`&&(Qe(e,t),t.defaultPrevented))return}}const et=c({name:`Link`,inheritAttrs:!1,props:{routeName:{type:String,default:void 0},to:{type:Object,default:void 0},routeParams:{type:Object,default:void 0},routeSearch:{type:Object,default:void 0},routeOptions:{type:Object,default:()=>Ce},class:{type:String,default:void 0},activeClassName:{type:String,default:`active`},activeStrict:{type:Boolean,default:!1},ignoreQueryParams:{type:Boolean,default:!0},target:{type:String,default:void 0},hash:{type:String,default:void 0}},setup(e,{slots:t,attrs:n}){let r=k(),i=_(!1),a=e.routeParams,o=s(()=>{let t=e.routeParams;return Xe(a,t)||(a=t),a});v(()=>[e.routeName,o.value,e.routeSearch,e.to,e.activeStrict,e.ignoreQueryParams,e.hash],([e,t,n,a,o,s,c],l,u)=>{let d=J(a,e??``,t,n),f=re(r,d.name,d.params,d.search,o,s,c);i.value=f.getSnapshot(),u(f.subscribe(()=>{i.value=f.getSnapshot()}))},{immediate:!0,flush:`sync`});let c=s(()=>{let t=J(e.to,e.routeName??``,o.value,e.routeSearch);return We(r,t.name,t.params??F,t.search,e.hash)}),u=s(()=>Ye(i.value,e.activeClassName,e.class)),d=t=>{if(n.onClick!==void 0&&n.onClick!==null&&($e(n.onClick,t),t.defaultPrevented)||!Be(t)||Ve(e.target))return;t.preventDefault();let i=J(e.to,e.routeName??``,e.routeParams,e.routeSearch);Ge(r,i.name,i.params??F,i.search,e.hash,e.routeOptions).catch(()=>{})};return()=>{let r={...n};return delete r.onClick,l(`a`,{...r,href:c.value,class:u.value,target:e.target,onClick:d},t.default?.())}}}),tt=c({name:`RouterErrorBoundary`,props:{fallback:{type:Function,required:!0},onError:{type:Function,default:void 0}},setup(e,{slots:t}){let n=k(),r=O(ie(n));return v(()=>r.value.version,()=>{r.value.error&&e.onError?.(r.value.error,r.value.toRoute,r.value.fromRoute)},{immediate:!0}),()=>{let n=t.default?.()??[],a=r.value.error?e.fallback(r.value.error,r.value.resetError):null;return l(i,null,[...n,a])}}}),Y=[];function nt(e){return Y.push(e),()=>{let t=Y.lastIndexOf(e);t!==-1&&Y.splice(t,1)}}function rt(){let e=Y.at(-1);if(!e)throw Error(`v-link directive requires a RouterProvider ancestor. Make sure RouterProvider is mounted.`);return e}const X=new WeakMap;function it(e){return e==null?(console.error(`[real-router] v-link directive received null/undefined value. The element will not be wired for navigation.`),!1):typeof e.name==`string`||(console.error("[real-router] v-link directive value is missing a string `name` field. The element will not be wired for navigation."),!1)}function at(e,t,n){return r=>{Be(r)&&!He(n)&&(r.preventDefault(),e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{}))}}function ot(e,t,n){return r=>{r.key===`Enter`&&!(n instanceof HTMLButtonElement)&&!He(n)&&e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{})}}function Z(e,t,n){let r=at(t,n,e),i=ot(t,n,e);e.addEventListener(`click`,r),e.addEventListener(`keydown`,i),X.set(e,{click:r,keydown:i})}function st(e){let t=X.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),X.delete(e))}const ct={mounted(e,t){let n=rt();Ze(e),e.style.cursor=`pointer`,it(t.value)&&Z(e,n,t.value)},updated(e,t){if(t.value===t.oldValue)return;let n=rt();st(e),it(t.value)&&Z(e,n,t.value)},beforeUnmount(e){st(e)}},lt=()=>{let e=u(n);if(!e)throw Error(`useNavigator must be used within a RouterProvider`);return e},ut=()=>{let e=k();return te(x(e).getTree())};function dt(){let e=k();return O(b(e))}function ft(e,t){let n=k(),r=t?.skipSameRoute??!0,i=!1;p(()=>{i=!1}),m(()=>{i=!0});let a=ce(e,{skipSameRoute:r}),o=n.subscribeLeave(e=>{if(!i)return a(e)});h(o)}function pt(e,t){let{route:n,previousRoute:i}=r(),a=t?.skipSameRoute??!0,o=ae(),s=!1;p(()=>{s=!1}),m(()=>{s=!0}),v(n,t=>{if(s)return;let n=o(t,i.value,a);n&&e(n)})}function Q(e){let t=ee(e),n=se(e),r=n.getSnapshot(),i=_(r.route),a=_(r.previousRoute);return{navigator:t,route:i,previousRoute:a,unsubscribe:n.subscribe(()=>{let e=n.getSnapshot();i.value=e.route,a.value=e.previousRoute})}}function mt(r){return{install(i){let a=nt(r),{navigator:o,route:s,previousRoute:c,unsubscribe:l}=Q(r);`onUnmount`in i&&i.onUnmount(()=>{a(),l()}),i.provide(e,r),i.provide(n,o),i.provide(t,{navigator:o,route:s,previousRoute:c})}}}function $(e,t){v(e,(e,n,r)=>{let i=t(e);i&&r(()=>{i.destroy()})},{immediate:!0})}const ht=c({name:`RouterProvider`,props:{router:{type:Object,required:!0},announceNavigation:{type:[Boolean,Object],default:!1},scrollRestoration:{type:Object},scrollSpy:{type:Object},viewTransitions:{type:Boolean,default:!1}},setup(r,{slots:i}){$(()=>{let e=r.announceNavigation,t=e!==!1,n=typeof e==`object`?e.prefix:void 0;return[r.router,t,n]},([e,t])=>{let n=r.announceNavigation;return t?Te(e,typeof n==`object`?n:void 0):void 0}),$(()=>[r.router,r.scrollRestoration!==void 0,r.scrollRestoration?.mode,r.scrollRestoration?.anchorScrolling,r.scrollRestoration?.behavior,r.scrollRestoration?.storageKey],([e,t,n,i,a,o])=>{if(t)return je(e,{mode:n,anchorScrolling:i,behavior:a,storageKey:o,scrollContainer:r.scrollRestoration?.scrollContainer})}),$(()=>[r.router,r.scrollSpy!==void 0&&r.scrollSpy.selector!==``,r.scrollSpy?.selector,r.scrollSpy?.rootMargin],([e,t,n,i])=>{if(t&&n)return Le(e,{selector:n,rootMargin:i,scrollContainer:r.scrollSpy?.scrollContainer})}),$(()=>[r.router,r.viewTransitions],([e,t])=>t?ze(e):void 0);let a=typeof document>`u`?void 0:nt(r.router);a&&h(a),le(r.router);let{navigator:o,route:s,previousRoute:c,unsubscribe:l}=Q(r.router);return h(l),g(e,r.router),g(n,o),g(t,{navigator:o,route:s,previousRoute:c}),()=>i.default?.()}});export{et as Link,n as NavigatorKey,t as RouteKey,Se as RouteView,tt as RouterErrorBoundary,e as RouterKey,ht as RouterProvider,mt as createRouterPlugin,lt as useNavigator,r as useRoute,pt as useRouteEnter,ft as useRouteExit,A as useRouteNode,ut as useRouteUtils,k as useRouter,dt as useRouterTransition,ct as vLink};
2
2
  //# sourceMappingURL=index.mjs.map