@real-router/vue 0.17.0 → 0.17.1

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,createRouteNodeSource as ie,createRouteSource as ae,getTransitionSource as x,primeErrorSource as oe}from"@real-router/sources";import{getPluginApi as se}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}),ce=new Set([C,w,T]),le=new Set([!0,``,`keep-alive`]);function ue(e,t,n){return n?e===t:te(e,t)}function E(e){return le.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)ce.has(e.type)?t.push(e):e.type===i&&O(e.children,t)}function de(e,t){return e.type===T?(t.notFoundChildren=e.children,!0):e.type===w?(t.selfVNode===null&&(t.selfVNode=e,t.selfFallback=e.props?.fallback),!0):!1}function fe(e,t,n){let r=e.props,i=r?.segment??``,a=r?.exact??!1;return{isActive:ue(t,n?`${n}.${i}`:i,a),fallback:r?.fallback}}function pe(e,t,n,r,i){if(r.selfVNode!==null&&t===n)return e.push(r.selfVNode),r.selfFallback;if(t===y&&r.notFoundChildren!==null){let t=i.filter(e=>e.type===T).at(-1);t&&e.push(t)}}function me(e,t,n){let r={selfVNode:null,selfFallback:void 0,notFoundChildren: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(de(c,r)||i)continue;let e=fe(c,t,n);e.isActive&&(i=!0,a=e.fallback,s.push(c))}return i||(a=pe(s,t,n,r,e)),{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(ie(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 F=null;function he(){return F??=f(c({name:`KeepAlive-placeholder`,render(){return null}})),F}function ge(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 _e(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(he())}),P(l(i,o),n)]):null}const ve=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}=me(s,a.name,e.nodeName);if(c.length===0)return null;let f=c[0];if(e.keepAlive)return ge(f,r,u);if(f.type!==C&&f.type!==w&&f.type!==T)return null;if(d)return _e(f,r,u);let p=M(f);return p?P(l(i,p),u):null}}}),ye=Object.assign(ve,{Match:C,Self:w,NotFound:T}),I=Object.freeze({}),be=Object.freeze({}),L=`data-real-router-announcer`,xe=Object.freeze({destroy:()=>{}});let R=0,z=0;function Se(e,t){if(typeof document>`u`)return xe;let n=t?.prefix??`Navigated to `,r=t?.getAnnouncementText,i=!0,a=!1,o=!1,s=``,c=null,l,{element:u,generation:d}=Ce();R+=1;let f=(e,t)=>{s=e,clearTimeout(l),u.textContent=e,l=setTimeout(()=>{u.textContent=``,s=``},7e3),Ee(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=Te(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===z&&(--R,R===0&&we(u)))}}}function Ce(){let e=document.querySelector(`[${L}]`);if(e)return{element:e,generation:z};R=0,z+=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(L,``),(document.body??document.documentElement).prepend(t),{element:t,generation:z}}function we(e){e.remove()}function Te(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 Ee(e){e&&(e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`-1`),e.focus({preventScroll:!0}))}const B=Object.freeze({destroy:()=>{}});function De(e,t){if(globalThis.window===void 0)return B;let n=t?.mode??`restore`;if(n===`native`)return B;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);s=e?JSON.parse(e):{}}catch{s={}}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 Oe(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 V=new WeakMap;function Oe(e){let t=V.get(e);if(t!==void 0)return t;let n=`${e.name}:${ke(e.params)}`;return V.set(e,n),n}function ke(e){return JSON.stringify(e,Ae)}function Ae(e,t){if(typeof t==`function`)return`<fn>`;if(typeof t==`symbol`)return`<sym>`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=Object.create(null),n=Object.keys(t).sort((e,t)=>e.localeCompare(t));for(let r of n)e[r]=t[r];return e}return t}const H=Object.freeze({destroy:()=>{}}),U=e=>e.context?.url,je=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},Me=(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}}},Ne=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()}}},Pe=(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)}}},Fe=(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 Ie(e,t){if(typeof document>`u`||typeof IntersectionObserver>`u`)return H;let{selector:n}=t;if(!n)return H;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=Me(e,()=>{s=!0}),p=Ne(a),m=Pe(()=>{u?.()},150),h=Fe(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=je(h.pending.values());if(h.pending.clear(),!t)return;let n=t.target.id;if(!n)return;let r=e.getState();if(!r||n===U(r)?.hash)return;let i={hash:n,replace:!0,force:!0,hashChange:!0};c=!0,e.navigate(r.name,r.params,i).catch(()=>{}).finally(()=>{c=!1})};let g=e.subscribe(({route:e})=>{c||(h.isContainerDetached()&&h.reconcile(),U(e)?.hashChanged&&p.start())});return{destroy(){o=!0,g(),h.destroy(),m.destroy(),p.destroy(),f.destroy()}}}const Le=Object.freeze({destroy:()=>{}});function Re(e){if(typeof document>`u`||typeof document.startViewTransition!=`function`)return Le;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()}}}function W(e){return e.button===0&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey}function ze(e){return encodeURI(e).replaceAll(`#`,`%23`)}function Be(e,t,n,r){try{let i=r?.hash,a;i!==void 0&&(a=i.startsWith(`#`)?i.slice(1):i);let o=e.buildUrl;if(o){let e=o(t,n,a===void 0?void 0:{hash:a});if(typeof e==`string`&&e.length>0)return e}let s=e.buildPath(t,n);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}#${ze(a)}`:s}catch{console.error(`[real-router] Route "${t}" is not defined. The element will render without an href attribute.`);return}}function Ve(e,t,n,r,i){let a={...i};r!==void 0&&(a.hash=r);let o=e.getState();if(o?.name===t&&K(o.params,n)){let e=o.context?.url?.hash??``;e!==(r??e)&&(a.force=!0,a.hashChange=!0)}return e.navigate(t,n,a)}const He=/\s/,Ue=/\S+/g;function G(e){return He.test(e)?e.match(Ue)??[]:[e]}function We(e,t,n){if(e&&t){let e=G(t);if(e.length===0)return n??void 0;if(!n)return e.join(` `);let r=G(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 K(e,t){if(Object.is(e,t))return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(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 Ge(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 Ke(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 qe=c({name:`Link`,inheritAttrs:!1,props:{routeName:{type:String,required:!0},routeParams:{type:Object,default:void 0},routeOptions:{type:Object,default:()=>be},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 K(a,t)||(a=t),a});v(()=>[e.routeName,o.value,e.activeStrict,e.ignoreQueryParams,e.hash],([e,t,n,a,o],s,c)=>{let l=ne(r,e,t,n,a,o);i.value=l.getSnapshot(),c(l.subscribe(()=>{i.value=l.getSnapshot()}))},{immediate:!0,flush:`sync`});let c=s(()=>Be(r,e.routeName,o.value??I,e.hash===void 0?void 0:{hash:e.hash})),u=s(()=>We(i.value,e.activeClassName,e.class)),d=t=>{n.onClick!==void 0&&n.onClick!==null&&(Ke(n.onClick,t),t.defaultPrevented)||!W(t)||e.target===`_blank`||(t.preventDefault(),Ve(r,e.routeName,e.routeParams??I,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?.())}}}),Je=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 Ye(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 Xe(e,t){return n=>{W(n)&&(n.preventDefault(),e.navigate(t.name,t.params??{},t.options??{}).catch(()=>{}))}}function Ze(e,t,n){return r=>{r.key===`Enter`&&!(n instanceof HTMLButtonElement)&&e.navigate(t.name,t.params??{},t.options??{}).catch(()=>{})}}function Qe(e,t,n){let r=Xe(t,n),i=Ze(t,n,e);e.addEventListener(`click`,r),e.addEventListener(`keydown`,i),Z.set(e,{click:r,keydown:i})}function $e(e){let t=Z.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),Z.delete(e))}const et={mounted(e,t){let n=X();Ge(e),e.style.cursor=`pointer`,Ye(t.value)&&Qe(e,n,t.value)},updated(e,t){if(t.value===t.oldValue)return;let n=X();$e(e),Ye(t.value)&&Qe(e,n,t.value)},beforeUnmount(e){$e(e)}},tt=()=>{let e=u(n);if(!e)throw Error(`useNavigator must be used within a RouterProvider`);return e},nt=()=>ee(se(A()).getTree());function rt(){return k(x(A()))}function it(e,t){let n=A(),r=t?.skipSameRoute??!0,i=!1;p(()=>{i=!1}),m(()=>{i=!0}),h(n.subscribeLeave(({route:t,nextRoute:n,signal:a})=>{if(!i&&!(r&&t.name===n.name)&&!a.aborted)return e({route:t,nextRoute:n,signal:a})}))}function at(e,t){let{route:n,previousRoute:i}=r(),a=t?.skipSameRoute??!0,o=null,s=!1;p(()=>{s=!1}),m(()=>{s=!0}),v(n,t=>{if(s)return;let n=i.value;t.transition.from&&(a&&t.transition.from===t.name||o===t||!n||(o=t,e({route:t,previousRoute:n})))})}function Q(e){let t=b(e),n=ae(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 ot(r){return{install(i){let a=Y(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 st=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?Se(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 De(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 Ie(e,{selector:n,rootMargin:i,scrollContainer:r.scrollSpy?.scrollContainer})}),$(()=>[r.router,r.viewTransitions],([e,t])=>t?Re(e):void 0);let a=typeof document>`u`?void 0:Y(r.router);a&&h(a),oe(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{qe as Link,n as NavigatorKey,t as RouteKey,ye as RouteView,Je as RouterErrorBoundary,e as RouterKey,st as RouterProvider,ot as createRouterPlugin,tt as useNavigator,r as useRoute,at as useRouteEnter,it as useRouteExit,j as useRouteNode,nt as useRouteUtils,A as useRouter,rt as useRouterTransition,et 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,createRouteNodeSource as ie,createRouteSource as ae,getTransitionSource as x,primeErrorSource as oe}from"@real-router/sources";import{getPluginApi as se}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}),ce=new Set([C,w,T]),le=new Set([!0,``,`keep-alive`]);function ue(e,t,n){return n?e===t:te(e,t)}function E(e){return le.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)ce.has(e.type)?t.push(e):e.type===i&&O(e.children,t)}function de(e,t){return e.type===T?(t.notFoundChildren=e.children,!0):e.type===w?(t.selfVNode===null&&(t.selfVNode=e,t.selfFallback=e.props?.fallback),!0):!1}function fe(e,t,n){let r=e.props,i=r?.segment??``,a=r?.exact??!1;return{isActive:ue(t,n?`${n}.${i}`:i,a),fallback:r?.fallback}}function pe(e,t,n,r,i){if(r.selfVNode!==null&&t===n)return e.push(r.selfVNode),r.selfFallback;if(t===y&&r.notFoundChildren!==null){let t=i.filter(e=>e.type===T).at(-1);t&&e.push(t)}}function me(e,t,n){let r={selfVNode:null,selfFallback:void 0,notFoundChildren: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(de(c,r)||i)continue;let e=fe(c,t,n);e.isActive&&(i=!0,a=e.fallback,s.push(c))}return i||(a=pe(s,t,n,r,e)),{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(ie(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 F=null;function he(){return F??=f(c({name:`KeepAlive-placeholder`,render(){return null}})),F}function ge(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 _e(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(he())}),P(l(i,o),n)]):null}const ve=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}=me(s,a.name,e.nodeName);if(c.length===0)return null;let f=c[0];if(e.keepAlive)return ge(f,r,u);if(f.type!==C&&f.type!==w&&f.type!==T)return null;if(d)return _e(f,r,u);let p=M(f);return p?P(l(i,p),u):null}}}),ye=Object.assign(ve,{Match:C,Self:w,NotFound:T}),I=Object.freeze({}),be=Object.freeze({}),L=`data-real-router-announcer`,xe=Object.freeze({destroy:()=>{}});let R=0,z=0;function Se(e,t){if(typeof document>`u`)return xe;let n=t?.prefix??`Navigated to `,r=t?.getAnnouncementText,i=!0,a=!1,o=!1,s=``,c=null,l,{element:u,generation:d}=Ce();R+=1;let f=(e,t)=>{s=e,clearTimeout(l),u.textContent=e,l=setTimeout(()=>{u.textContent=``,s=``},7e3),Ee(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=Te(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===z&&(--R,R===0&&we(u)))}}}function Ce(){let e=document.querySelector(`[${L}]`);if(e)return{element:e,generation:z};R=0,z+=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(L,``),(document.body??document.documentElement).prepend(t),{element:t,generation:z}}function we(e){e.remove()}function Te(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 Ee(e){e&&(e.hasAttribute(`tabindex`)||e.setAttribute(`tabindex`,`-1`),e.focus({preventScroll:!0}))}const B=Object.freeze({destroy:()=>{}});function De(e,t){if(globalThis.window===void 0)return B;let n=t?.mode??`restore`;if(n===`native`)return B;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);s=e?JSON.parse(e):{}}catch{s={}}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 Oe(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 V=new WeakMap;function Oe(e){let t=V.get(e);if(t!==void 0)return t;let n=`${e.name}:${ke(e.params)}`;return V.set(e,n),n}function ke(e){return JSON.stringify(e,Ae)}function Ae(e,t){if(typeof t==`function`)return`<fn>`;if(typeof t==`symbol`)return`<sym>`;if(typeof t==`object`&&t&&!Array.isArray(t)){let e=Object.create(null),n=Object.keys(t).sort((e,t)=>e.localeCompare(t));for(let r of n)e[r]=t[r];return e}return t}const H=Object.freeze({destroy:()=>{}}),U=e=>e.context?.url,je=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},Me=(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}}},Ne=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()}}},Pe=(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)}}},Fe=(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 Ie(e,t){if(typeof document>`u`||typeof IntersectionObserver>`u`)return H;let{selector:n}=t;if(!n)return H;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=Me(e,()=>{s=!0}),p=Ne(a),m=Pe(()=>{u?.()},150),h=Fe(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=je(h.pending.values());if(h.pending.clear(),!t)return;let n=t.target.id;if(!n)return;let r=e.getState();if(!r||n===U(r)?.hash)return;let i={hash:n,replace:!0,force:!0,hashChange:!0};c=!0,e.navigate(r.name,r.params,i).catch(()=>{}).finally(()=>{c=!1})};let g=e.subscribe(({route:e})=>{c||(h.isContainerDetached()&&h.reconcile(),U(e)?.hashChanged&&p.start())});return{destroy(){o=!0,g(),h.destroy(),m.destroy(),p.destroy(),f.destroy()}}}const Le=Object.freeze({destroy:()=>{}});function Re(e){if(typeof document>`u`||typeof document.startViewTransition!=`function`)return Le;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()}}}function W(e){return e.button===0&&!e.metaKey&&!e.altKey&&!e.ctrlKey&&!e.shiftKey}function ze(e){return encodeURI(e).replaceAll(`#`,`%23`)}function Be(e,t,n,r){try{let i;r!==void 0&&(i=r.startsWith(`#`)?r.slice(1):r);let a=e.buildUrl;if(a){let e=a(t,n,i===void 0?void 0:{hash:i});if(typeof e==`string`&&e.length>0)return e}let o=e.buildPath(t,n);if(typeof o!=`string`||o.length===0){console.error(`[real-router] Route "${t}" yielded an empty path. The element will render without an href attribute.`);return}return i?`${o}#${ze(i)}`:o}catch{console.error(`[real-router] Route "${t}" is not defined. The element will render without an href attribute.`);return}}function Ve(e,t,n,r,i){let a={...i};r!==void 0&&(a.hash=r);let o=e.getState();if(o?.name===t&&K(o.params,n)){let e=o.context?.url?.hash??``;e!==(r??e)&&(a.force=!0,a.hashChange=!0)}return e.navigate(t,n,a)}const He=/\s/,Ue=/\S+/g;function G(e){return He.test(e)?e.match(Ue)??[]:[e]}function We(e,t,n){if(e&&t){let e=G(t);if(e.length===0)return n??void 0;if(!n)return e.join(` `);let r=G(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 K(e,t){if(Object.is(e,t))return!0;if(!e||!t)return!1;let n=Object.keys(e);if(n.length!==Object.keys(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 Ge(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 Ke(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 qe=c({name:`Link`,inheritAttrs:!1,props:{routeName:{type:String,required:!0},routeParams:{type:Object,default:void 0},routeOptions:{type:Object,default:()=>be},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 K(a,t)||(a=t),a});v(()=>[e.routeName,o.value,e.activeStrict,e.ignoreQueryParams,e.hash],([e,t,n,a,o],s,c)=>{let l=ne(r,e,t,n,a,o);i.value=l.getSnapshot(),c(l.subscribe(()=>{i.value=l.getSnapshot()}))},{immediate:!0,flush:`sync`});let c=s(()=>Be(r,e.routeName,o.value??I,e.hash)),u=s(()=>We(i.value,e.activeClassName,e.class)),d=t=>{n.onClick!==void 0&&n.onClick!==null&&(Ke(n.onClick,t),t.defaultPrevented)||!W(t)||e.target===`_blank`||(t.preventDefault(),Ve(r,e.routeName,e.routeParams??I,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?.())}}}),Je=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 Ye(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 Xe(e,t){return n=>{W(n)&&(n.preventDefault(),e.navigate(t.name,t.params??{},t.options??{}).catch(()=>{}))}}function Ze(e,t,n){return r=>{r.key===`Enter`&&!(n instanceof HTMLButtonElement)&&e.navigate(t.name,t.params??{},t.options??{}).catch(()=>{})}}function Qe(e,t,n){let r=Xe(t,n),i=Ze(t,n,e);e.addEventListener(`click`,r),e.addEventListener(`keydown`,i),Z.set(e,{click:r,keydown:i})}function $e(e){let t=Z.get(e);t&&(e.removeEventListener(`click`,t.click),e.removeEventListener(`keydown`,t.keydown),Z.delete(e))}const et={mounted(e,t){let n=X();Ge(e),e.style.cursor=`pointer`,Ye(t.value)&&Qe(e,n,t.value)},updated(e,t){if(t.value===t.oldValue)return;let n=X();$e(e),Ye(t.value)&&Qe(e,n,t.value)},beforeUnmount(e){$e(e)}},tt=()=>{let e=u(n);if(!e)throw Error(`useNavigator must be used within a RouterProvider`);return e},nt=()=>ee(se(A()).getTree());function rt(){return k(x(A()))}function it(e,t){let n=A(),r=t?.skipSameRoute??!0,i=!1;p(()=>{i=!1}),m(()=>{i=!0}),h(n.subscribeLeave(({route:t,nextRoute:n,signal:a})=>{if(!i&&!(r&&t.name===n.name)&&!a.aborted)return e({route:t,nextRoute:n,signal:a})}))}function at(e,t){let{route:n,previousRoute:i}=r(),a=t?.skipSameRoute??!0,o=null,s=!1;p(()=>{s=!1}),m(()=>{s=!0}),v(n,t=>{if(s)return;let n=i.value;t.transition.from&&(a&&t.transition.from===t.name||o===t||!n||(o=t,e({route:t,previousRoute:n})))})}function Q(e){let t=b(e),n=ae(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 ot(r){return{install(i){let a=Y(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 st=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?Se(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 De(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 Ie(e,{selector:n,rootMargin:i,scrollContainer:r.scrollSpy?.scrollContainer})}),$(()=>[r.router,r.viewTransitions],([e,t])=>t?Re(e):void 0);let a=typeof document>`u`?void 0:Y(r.router);a&&h(a),oe(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{qe as Link,n as NavigatorKey,t as RouteKey,ye as RouteView,Je as RouterErrorBoundary,e as RouterKey,st as RouterProvider,ot as createRouterPlugin,tt as useNavigator,r as useRoute,at as useRouteEnter,it as useRouteExit,j as useRouteNode,nt as useRouteUtils,A as useRouter,rt as useRouterTransition,et as vLink};
2
2
  //# sourceMappingURL=index.mjs.map