@real-router/vue 0.19.48 → 0.19.50

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 b}from"@real-router/core";import{getRouteUtils as ee,startsWithSegment as te}from"@real-router/route-utils";import{createActiveSource as ne,createDismissableError as re,createRouteEnterGate as ie,createRouteNodeSource as ae,createRouteSource as oe,getTransitionSource as x,guardLeaveListener as se,primeErrorSource as ce}from"@real-router/sources";import{getPluginApi as le}from"@real-router/core/api";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}),ue=new Set([C,w,T]),de=new Set([!0,``,`keep-alive`]);function fe(e,t,n){return n?e===t:te(e,t)}function E(e){return de.has(e)}function D(e){if(Array.isArray(e)){let t=[];for(let n of e)Array.isArray(n)?t.push(...D(n)):d(n)&&t.push(n);return t}return d(e)?[e]:[]}function O(e,t){let n=D(e);for(let e of n)ue.has(e.type)?t.push(e):e.type===i&&O(e.children,t)}function pe(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):!1}function me(e,t,n){let r=e.props,i=r?.segment??``,a=r?.exact??!1;return{isActive:fe(t,n?`${n}.${i}`:i,a),fallback:r?.fallback}}function he(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 ge(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(pe(c,r)||i)continue;let e=me(c,t,n);e.isActive&&(i=!0,a=e.fallback,s.push(c))}return i||(a=he(s,t,n,r)),{rendered:s,activeMatchFound:i,fallback:a,hasPerMatchKA:o}}function k(e){let t=_(e.getSnapshot());return h(e.subscribe(()=>{t.value=e.getSnapshot()})),t}const A=()=>{let t=u(e);if(!t)throw Error(`useRouter must be used within a RouterProvider`);return t};function j(e){let t=A(),n=k(ae(t,e));return{navigator:b(t),route:s(()=>n.value.route),previousRoute:s(()=>n.value.previousRoute)}}function M(e){return e.children?.default?.()??null}function N(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 P(e,t){if(t===void 0)return e;let n=typeof t==`function`?t():t;return l(o,{},{default:()=>e,fallback:()=>n})}let _e=null;function ve(){return _e??=f(c({name:`KeepAlive-placeholder`,render(){return null}})),_e}function ye(e,t,n){let r=e.props?.segment??`__not-found__`,i=N(t,r),o=M(e)??[];return P(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=N(t,n),s=M(e)??[];return l(i,[l(a,null,{default:()=>l(o,{key:n},{default:()=>s})})])}let o=M(e);return o?l(i,[l(a,null,{default:()=>l(ve())}),P(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=j(e.nodeName),r=new Map;return()=>{let a=n.route.value;if(!a)return null;let o=t.default?.(),s=[];O(o,s);let{rendered:c,fallback:u,hasPerMatchKA:d}=ge(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=M(f);return p?P(l(i,p),u):null}}}),Se=Object.assign(xe,{Match:C,Self:w,NotFound:T}),Ce=Object.freeze({}),we=Object.freeze({}),F=`data-real-router-announcer`,Te=Object.freeze({destroy:()=>{}});let I=0,L=0;function Ee(e,t){if(typeof document>`u`)return Te;let n=t?.prefix??`Navigated to `,r=t?.getAnnouncementText,i=!0,a=!1,o=!1,s=``,c=null,l,{element:u,generation:d}=De();I+=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(){o||(o=!0,m(),clearTimeout(l),clearTimeout(p),d===L&&(--I,I===0&&Oe(u)))}}}function De(){let e=document.querySelector(`[${F}]`);if(e)return{element:e,generation:L};I=0,L+=1;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(F,``),(document.body??document.documentElement).prepend(t),{element:t,generation:L}}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 R=Object.create,je=Object.keys,z=Object.freeze({destroy:()=>{}});function Me(e,t){if(globalThis.window===void 0)return z;let n=t?.mode??`restore`;if(n===`native`)return z;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(R(null),t)}catch{s=R(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=e=>{if(!i){globalThis.scrollTo({top:e,left:0,behavior:a});return}let t=0,n=()=>{if(h)return;let r=i();if(r){if(r.scrollTo({top:e,left:0,behavior:a}),a!==`smooth`&&Math.abs(r.scrollTop-e)<=1)return}else globalThis.scrollTo({top:e,left:0,behavior:a});t>=10||(t+=1,requestAnimationFrame(n))};n()},m=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)},h=!1,g=!1,_=!0,v=e=>{try{return Ne(e)}catch{return g||(g=!0,console.error(`[real-router] scroll-restore: route "${e.name}" has params that cannot be canonicalized (e.g. BigInt or cyclic structure). Scroll position will not be captured or restored for this route.`)),null}},y=e.subscribe(({route:e,previousRoute:t})=>{let r=e.context.navigation;if(t&&_){let e=v(t);e!==null&&l(e,d())}_=!1,requestAnimationFrame(()=>{if(!h){if(_=!0,n===`top`){m(e);return}if(e.transition?.reload||r?.navigationType===`reload`){let t=v(e);p(t===null?0:c()[t]??0);return}if(r?.direction===`back`||r?.navigationType===`traverse`){let t=v(e);p(t===null?0:c()[t]??0);return}e.transition?.replace||r?.navigationType===`replace`||m(e)}})}),b=()=>{let t=e.getState();if(t){let e=v(t);e!==null&&l(e,d())}};return globalThis.addEventListener(`pagehide`,b),{destroy:()=>{h=!0,y(),globalThis.removeEventListener(`pagehide`,b);try{history.scrollRestoration=u}catch{}}}}const B=new WeakMap;function Ne(e){let t=B.get(e);if(t!==void 0)return t;let n=`${e.name}:${Pe({...e.params,...e.search})}`;return B.set(e,n),n}function Pe(e){return JSON.stringify(e,Fe)}function Fe(e,t){if(typeof t==`function`)return`<fn>`;if(typeof t==`symbol`)return`<sym>`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=R(null),n=je(t).sort((e,t)=>e.localeCompare(t));for(let r of n)e[r]=t[r];return e}return t}const V=Object.freeze({destroy:()=>{}}),H=e=>e.context?.url,Ie=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},Le=(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}}},Re=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()}}},ze=(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)}}},Be=(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 Ve(e,t){if(typeof document>`u`||typeof IntersectionObserver>`u`)return V;let{selector:n}=t;if(!n)return V;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=x(e),f=Le(e,()=>{s=!0}),p=Re(a),m=ze(()=>{u?.()},150),h=Be(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=Ie(h.pending.values());if(h.pending.clear(),!t)return;let n=t.target.id;if(!n)return;let r=e.getState();if(!r||n===H(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(),H(e)?.hashChanged&&p.start())});return{destroy(){o=!0,g(),h.destroy(),m.destroy(),p.destroy(),f.destroy()}}}const He=Object.freeze({destroy:()=>{}});function Ue(e){if(typeof document>`u`||typeof document.startViewTransition!=`function`)return He;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 U=Object.keys;function W(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 G(e){return e.button===0&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey}function We(e){return encodeURI(e).replaceAll(`#`,`%23`)}function Ge(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=e.buildPath(t,n,r);if(typeof s!=`string`||s.length===0){console.error(`[real-router] Route "${t}" yielded an empty path. The element will render without an href attribute.`);return}return a?`${s}#${We(a)}`:s}catch{console.error(`[real-router] Route "${t}" is not defined. The element will render without an href attribute.`);return}}function Ke(e,t,n,r,i,a){let o={...a};i!==void 0&&(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 qe=/\s/,Je=/\S+/g;function K(e){return qe.test(e)?e.match(Je)??[]:[e]}function Ye(e,t,n){if(e&&t){let e=K(t);if(e.length===0)return n??void 0;if(!n)return e.join(` `);let r=K(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=U(e);if(n.length!==U(t).length)return!1;let r=e,i=t;for(let e of n)if(!Object.prototype.hasOwnProperty.call(t,e)||!Object.is(r[e],i[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 q(e,t){try{e(t)}catch(e){console.error(`[real-router] A <Link> @click handler threw; navigation is unaffected.`,e)}}function Qe(e,t){if(typeof e==`function`){q(e,t);return}if(Array.isArray(e)){let n=e;for(let e of n)if(typeof e==`function`&&(q(e,t),t.defaultPrevented))return}}const $e=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:()=>we},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=A(),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=W(a,e??``,t,n),f=ne(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=W(e.to,e.routeName??``,o.value,e.routeSearch);return Ge(r,t.name,t.params??Ce,t.search,e.hash)}),u=s(()=>Ye(i.value,e.activeClassName,e.class)),d=t=>{if(n.onClick!==void 0&&n.onClick!==null&&(Qe(n.onClick,t),t.defaultPrevented)||!G(t)||e.target===`_blank`)return;t.preventDefault();let i=W(e.to,e.routeName??``,e.routeParams,e.routeSearch);Ke(r,i.name,i.params??Ce,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?.())}}}),et=c({name:`RouterErrorBoundary`,props:{fallback:{type:Function,required:!0},onError:{type:Function,default:void 0}},setup(e,{slots:t}){let n=k(re(A()));return v(()=>n.value.version,()=>{n.value.error&&e.onError?.(n.value.error,n.value.toRoute,n.value.fromRoute)},{immediate:!0}),()=>{let r=t.default?.()??[],a=n.value.error?e.fallback(n.value.error,n.value.resetError):null;return l(i,null,[...r,a])}}}),J=[];function Y(e){return J.push(e),()=>{let t=J.lastIndexOf(e);t!==-1&&J.splice(t,1)}}function X(){let e=J.at(-1);if(!e)throw Error(`v-link directive requires a RouterProvider ancestor. Make sure RouterProvider is mounted.`);return e}const Z=new WeakMap;function Q(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`?!0:(console.error("[real-router] v-link directive value is missing a string `name` field. The element will not be wired for navigation."),!1)}function tt(e,t){return n=>{G(n)&&(n.preventDefault(),e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{}))}}function nt(e,t,n){return r=>{r.key===`Enter`&&!(n instanceof HTMLButtonElement)&&e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{})}}function rt(e,t,n){let r=tt(t,n),i=nt(t,n,e);e.addEventListener(`click`,r),e.addEventListener(`keydown`,i),Z.set(e,{click:r,keydown:i})}function it(e){let t=Z.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),Z.delete(e))}const at={mounted(e,t){let n=X();Ze(e),e.style.cursor=`pointer`,Q(t.value)&&rt(e,n,t.value)},updated(e,t){if(t.value===t.oldValue)return;let n=X();it(e),Q(t.value)&&rt(e,n,t.value)},beforeUnmount(e){it(e)}},ot=()=>{let e=u(n);if(!e)throw Error(`useNavigator must be used within a RouterProvider`);return e},st=()=>ee(le(A()).getTree());function ct(){return k(x(A()))}function lt(e,t){let n=A(),r=t?.skipSameRoute??!0,i=!1;p(()=>{i=!1}),m(()=>{i=!0});let a=se(e,{skipSameRoute:r});h(n.subscribeLeave(e=>{if(!i)return a(e)}))}function ut(e,t){let{route:n,previousRoute:i}=r(),a=t?.skipSameRoute??!0,o=ie(),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 dt(e){let t=b(e),n=oe(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 ft(r){return{install(i){let a=Y(r),{navigator:o,route:s,previousRoute:c,unsubscribe:l}=dt(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 pt=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?Ee(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 Me(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 Ve(e,{selector:n,rootMargin:i,scrollContainer:r.scrollSpy?.scrollContainer})}),$(()=>[r.router,r.viewTransitions],([e,t])=>t?Ue(e):void 0);let a=typeof document>`u`?void 0:Y(r.router);a&&h(a),ce(r.router);let{navigator:o,route:s,previousRoute:c,unsubscribe:l}=dt(r.router);return h(l),g(e,r.router),g(n,o),g(t,{navigator:o,route:s,previousRoute:c}),()=>i.default?.()}});export{$e as Link,n as NavigatorKey,t as RouteKey,Se as RouteView,et as RouterErrorBoundary,e as RouterKey,pt as RouterProvider,ft as createRouterPlugin,ot as useNavigator,r as useRoute,ut as useRouteEnter,lt as useRouteExit,j as useRouteNode,st as useRouteUtils,A as useRouter,ct as useRouterTransition,at 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 b}from"@real-router/core";import{getRouteUtils as ee,startsWithSegment as te}from"@real-router/route-utils";import{createActiveSource as ne,createDismissableError as re,createRouteEnterGate as ie,createRouteNodeSource as ae,createRouteSource as oe,getTransitionSource as x,guardLeaveListener as se,primeErrorSource as ce}from"@real-router/sources";import{getPluginApi as le}from"@real-router/core/api";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}),ue=new Set([C,w,T]),de=new Set([!0,``,`keep-alive`]);function fe(e,t,n){return n?e===t:te(e,t)}function E(e){return de.has(e)}function D(e){if(Array.isArray(e)){let t=[];for(let n of e)Array.isArray(n)?t.push(...D(n)):d(n)&&t.push(n);return t}return d(e)?[e]:[]}function O(e,t){let n=D(e);for(let e of n)ue.has(e.type)?t.push(e):e.type===i&&O(e.children,t)}function pe(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):!1}function me(e,t,n){let r=e.props,i=r?.segment??``,a=r?.exact??!1;return{isActive:fe(t,n?`${n}.${i}`:i,a),fallback:r?.fallback}}function he(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 ge(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(pe(c,r)||i)continue;let e=me(c,t,n);e.isActive&&(i=!0,a=e.fallback,s.push(c))}return i||(a=he(s,t,n,r)),{rendered:s,activeMatchFound:i,fallback:a,hasPerMatchKA:o}}function k(e){let t=_(e.getSnapshot());return h(e.subscribe(()=>{t.value=e.getSnapshot()})),t}const A=()=>{let t=u(e);if(!t)throw Error(`useRouter must be used within a RouterProvider`);return t};function j(e){let t=A(),n=k(ae(t,e));return{navigator:b(t),route:s(()=>n.value.route),previousRoute:s(()=>n.value.previousRoute)}}function M(e){return e.children?.default?.()??null}function N(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 P(e,t){if(t===void 0)return e;let n=typeof t==`function`?t():t;return l(o,{},{default:()=>e,fallback:()=>n})}let _e=null;function ve(){return _e??=f(c({name:`KeepAlive-placeholder`,render(){return null}})),_e}function ye(e,t,n){let r=e.props?.segment??`__not-found__`,i=N(t,r),o=M(e)??[];return P(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=N(t,n),s=M(e)??[];return l(i,[l(a,null,{default:()=>l(o,{key:n},{default:()=>s})})])}let o=M(e);return o?l(i,[l(a,null,{default:()=>l(ve())}),P(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=j(e.nodeName),r=new Map;return()=>{let a=n.route.value;if(!a)return null;let o=t.default?.(),s=[];O(o,s);let{rendered:c,fallback:u,hasPerMatchKA:d}=ge(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=M(f);return p?P(l(i,p),u):null}}}),Se=Object.assign(xe,{Match:C,Self:w,NotFound:T}),Ce=Object.freeze({}),we=Object.freeze({}),F=`data-real-router-announcer`,Te=Object.freeze({destroy:()=>{}});let I=0,L=0;function Ee(e,t){if(typeof document>`u`)return Te;let n=t?.prefix??`Navigated to `,r=t?.getAnnouncementText,i=!0,a=!1,o=!1,s=``,c=null,l,{element:u,generation:d}=De();I+=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(){o||(o=!0,m(),clearTimeout(l),clearTimeout(p),d===L&&(--I,I===0&&Oe(u)))}}}function De(){let e=document.querySelector(`[${F}]`);if(e)return{element:e,generation:L};I=0,L+=1;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(F,``),(document.body??document.documentElement).prepend(t),{element:t,generation:L}}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 R=Object.create,je=Object.keys,z=Object.freeze({destroy:()=>{}});function Me(e,t){if(globalThis.window===void 0)return z;let n=t?.mode??`restore`;if(n===`native`)return z;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(R(null),t)}catch{s=R(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=e=>{if(!i){globalThis.scrollTo({top:e,left:0,behavior:a});return}let t=0,n=()=>{if(h)return;let r=i();if(r){if(r.scrollTo({top:e,left:0,behavior:a}),a!==`smooth`&&Math.abs(r.scrollTop-e)<=1)return}else globalThis.scrollTo({top:e,left:0,behavior:a});t>=10||(t+=1,requestAnimationFrame(n))};n()},m=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)},h=!1,g=!1,_=!0,v=e=>{try{return Ne(e)}catch{return g||(g=!0,console.error(`[real-router] scroll-restore: route "${e.name}" has params that cannot be canonicalized (e.g. BigInt or cyclic structure). Scroll position will not be captured or restored for this route.`)),null}},y=e.subscribe(({route:e,previousRoute:t})=>{let r=e.context.navigation;if(t&&_){let e=v(t);e!==null&&l(e,d())}_=!1,requestAnimationFrame(()=>{if(!h){if(_=!0,n===`top`){m(e);return}if(e.transition?.reload||r?.navigationType===`reload`){let t=v(e);p(t===null?0:c()[t]??0);return}if(r?.direction===`back`||r?.navigationType===`traverse`){let t=v(e);p(t===null?0:c()[t]??0);return}e.transition?.replace||r?.navigationType===`replace`||m(e)}})}),b=()=>{let t=e.getState();if(t){let e=v(t);e!==null&&l(e,d())}};return globalThis.addEventListener(`pagehide`,b),{destroy:()=>{h=!0,y(),globalThis.removeEventListener(`pagehide`,b);try{history.scrollRestoration=u}catch{}}}}const B=new WeakMap;function Ne(e){let t=B.get(e);if(t!==void 0)return t;let n=`${e.name}:${Pe({...e.params,...e.search})}`;return B.set(e,n),n}function Pe(e){return JSON.stringify(e,Fe)}function Fe(e,t){if(typeof t==`function`)return`<fn>`;if(typeof t==`symbol`)return`<sym>`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=R(null),n=je(t).sort((e,t)=>e.localeCompare(t));for(let r of n)e[r]=t[r];return e}return t}const V=Object.freeze({destroy:()=>{}}),H=e=>e.context?.url,Ie=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},Le=(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}}},Re=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()}}},ze=(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)}}},Be=(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 Ve(e,t){if(typeof document>`u`||typeof IntersectionObserver>`u`)return V;let{selector:n}=t;if(!n)return V;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=x(e),f=Le(e,()=>{s=!0}),p=Re(a),m=ze(()=>{u?.()},150),h=Be(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=Ie(h.pending.values());if(h.pending.clear(),!t)return;let n=t.target.id;if(!n)return;let r=e.getState();if(!r||n===H(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(),H(e)?.hashChanged&&p.start())});return{destroy(){o=!0,g(),h.destroy(),m.destroy(),p.destroy(),f.destroy()}}}const He=Object.freeze({destroy:()=>{}});function Ue(e){if(typeof document>`u`||typeof document.startViewTransition!=`function`)return He;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 U=Object.keys;function W(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 G(e){return e.button===0&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey}function We(e){return encodeURI(e).replaceAll(`#`,`%23`)}function Ge(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=e.buildPath(t,n,r);if(typeof s!=`string`||s.length===0){console.error(`[real-router] Route "${t}" yielded an empty path. The element will render without an href attribute.`);return}return a?`${s}#${We(a)}`:s}catch{console.error(`[real-router] Route "${t}" is not defined. The element will render without an href attribute.`);return}}function Ke(e,t,n,r,i,a){let o={...a};i!==void 0&&(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 qe=/\s/,Je=/\S+/g;function K(e){return qe.test(e)?e.match(Je)??[]:[e]}function Ye(e,t,n){if(e&&t){let e=K(t);if(e.length===0)return n??void 0;if(!n)return e.join(` `);let r=K(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=U(e),r=U(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 q(e,t){try{e(t)}catch(e){console.error(`[real-router] A <Link> @click handler threw; navigation is unaffected.`,e)}}function Qe(e,t){if(typeof e==`function`){q(e,t);return}if(Array.isArray(e)){let n=e;for(let e of n)if(typeof e==`function`&&(q(e,t),t.defaultPrevented))return}}const $e=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:()=>we},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=A(),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=W(a,e??``,t,n),f=ne(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=W(e.to,e.routeName??``,o.value,e.routeSearch);return Ge(r,t.name,t.params??Ce,t.search,e.hash)}),u=s(()=>Ye(i.value,e.activeClassName,e.class)),d=t=>{if(n.onClick!==void 0&&n.onClick!==null&&(Qe(n.onClick,t),t.defaultPrevented)||!G(t)||e.target===`_blank`)return;t.preventDefault();let i=W(e.to,e.routeName??``,e.routeParams,e.routeSearch);Ke(r,i.name,i.params??Ce,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?.())}}}),et=c({name:`RouterErrorBoundary`,props:{fallback:{type:Function,required:!0},onError:{type:Function,default:void 0}},setup(e,{slots:t}){let n=k(re(A()));return v(()=>n.value.version,()=>{n.value.error&&e.onError?.(n.value.error,n.value.toRoute,n.value.fromRoute)},{immediate:!0}),()=>{let r=t.default?.()??[],a=n.value.error?e.fallback(n.value.error,n.value.resetError):null;return l(i,null,[...r,a])}}}),J=[];function Y(e){return J.push(e),()=>{let t=J.lastIndexOf(e);t!==-1&&J.splice(t,1)}}function X(){let e=J.at(-1);if(!e)throw Error(`v-link directive requires a RouterProvider ancestor. Make sure RouterProvider is mounted.`);return e}const Z=new WeakMap;function Q(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`?!0:(console.error("[real-router] v-link directive value is missing a string `name` field. The element will not be wired for navigation."),!1)}function tt(e,t){return n=>{G(n)&&(n.preventDefault(),e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{}))}}function nt(e,t,n){return r=>{r.key===`Enter`&&!(n instanceof HTMLButtonElement)&&e.navigate(t.name,t.params??{},void 0,t.options??{}).catch(()=>{})}}function rt(e,t,n){let r=tt(t,n),i=nt(t,n,e);e.addEventListener(`click`,r),e.addEventListener(`keydown`,i),Z.set(e,{click:r,keydown:i})}function it(e){let t=Z.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),Z.delete(e))}const at={mounted(e,t){let n=X();Ze(e),e.style.cursor=`pointer`,Q(t.value)&&rt(e,n,t.value)},updated(e,t){if(t.value===t.oldValue)return;let n=X();it(e),Q(t.value)&&rt(e,n,t.value)},beforeUnmount(e){it(e)}},ot=()=>{let e=u(n);if(!e)throw Error(`useNavigator must be used within a RouterProvider`);return e},st=()=>ee(le(A()).getTree());function ct(){return k(x(A()))}function lt(e,t){let n=A(),r=t?.skipSameRoute??!0,i=!1;p(()=>{i=!1}),m(()=>{i=!0});let a=se(e,{skipSameRoute:r});h(n.subscribeLeave(e=>{if(!i)return a(e)}))}function ut(e,t){let{route:n,previousRoute:i}=r(),a=t?.skipSameRoute??!0,o=ie(),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 dt(e){let t=b(e),n=oe(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 ft(r){return{install(i){let a=Y(r),{navigator:o,route:s,previousRoute:c,unsubscribe:l}=dt(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 pt=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?Ee(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 Me(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 Ve(e,{selector:n,rootMargin:i,scrollContainer:r.scrollSpy?.scrollContainer})}),$(()=>[r.router,r.viewTransitions],([e,t])=>t?Ue(e):void 0);let a=typeof document>`u`?void 0:Y(r.router);a&&h(a),ce(r.router);let{navigator:o,route:s,previousRoute:c,unsubscribe:l}=dt(r.router);return h(l),g(e,r.router),g(n,o),g(t,{navigator:o,route:s,previousRoute:c}),()=>i.default?.()}});export{$e as Link,n as NavigatorKey,t as RouteKey,Se as RouteView,et as RouterErrorBoundary,e as RouterKey,pt as RouterProvider,ft as createRouterPlugin,ot as useNavigator,r as useRoute,ut as useRouteEnter,lt as useRouteExit,j as useRouteNode,st as useRouteUtils,A as useRouter,ct as useRouterTransition,at as vLink};
2
2
  //# sourceMappingURL=index.mjs.map