import{d,e as p,k as K,s as V,t as _,u as G,v as a,w as m}from"./chunk-QYQ7WNYU.js";import{c as A,d as L,e as Q,g as T,h as O,k}from"./chunk-GW55Q7ZA.js";import{Ga as S,La as x,Ld as D,Oa as y,Qa as h,Ra as F,Va as j,a as N,ab as q,b,ob as w}from"./chunk-HC2G7LSI.js";var $="@ngrx/router-store/request",Nt=d($,p()),P="@ngrx/router-store/navigation",St=d(P,p()),U="@ngrx/router-store/cancel",yt=d(U,p()),z="@ngrx/router-store/error",At=d(z,p()),J="@ngrx/router-store/navigated",Tt=d(J,p());function Ot(e,t){let n=t;switch(n.type){case P:case z:case U:return{state:n.payload.routerState,navigationId:n.payload.event.id};default:return e}}var E=class{serialize(t){return{root:this.serializeRoute(t.root),url:t.url}}serializeRoute(t){let n=t.children.map(r=>this.serializeRoute(r));return{params:t.params,data:t.data,url:t.url,outlet:t.outlet,title:t.title,routeConfig:t.routeConfig?{path:t.routeConfig.path,pathMatch:t.routeConfig.pathMatch,redirectTo:t.routeConfig.redirectTo,outlet:t.routeConfig.outlet,title:typeof t.routeConfig.title=="string"?t.routeConfig.title:void 0}:null,queryParams:t.queryParams,fragment:t.fragment,firstChild:n[0],children:n}}},I=function(e){return e[e.PreActivation=1]="PreActivation",e[e.PostActivation=2]="PostActivation",e}(I||{}),W="router",H=new y("@ngrx/router-store Internal Configuration"),X=new y("@ngrx/router-store Configuration");function it(e){return N({stateKey:W,serializer:E,navigationActionTiming:I.PreActivation},e)}var v=class{serialize(t){return{root:this.serializeRoute(t.root),url:t.url}}serializeRoute(t){let n=t.children.map(r=>this.serializeRoute(r));return{params:t.params,paramMap:t.paramMap,data:t.data,url:t.url,outlet:t.outlet,title:t.title,routeConfig:t.routeConfig?{component:t.routeConfig.component,path:t.routeConfig.path,pathMatch:t.routeConfig.pathMatch,redirectTo:t.routeConfig.redirectTo,outlet:t.routeConfig.outlet,title:t.routeConfig.title}:null,queryParams:t.queryParams,queryParamMap:t.queryParamMap,fragment:t.fragment,component:t.routeConfig?t.routeConfig.component:void 0,root:void 0,parent:void 0,firstChild:n[0],pathFromRoot:void 0,children:n}}},C=class{},u=function(e){return e[e.NONE=1]="NONE",e[e.ROUTER=2]="ROUTER",e[e.STORE=3]="STORE",e}(u||{}),B=(()=>{let t=class t{constructor(r,s,o,l,g,R){this.store=r,this.router=s,this.serializer=o,this.errorHandler=l,this.config=g,this.activeRuntimeChecks=R,this.lastEvent=null,this.routerState=null,this.trigger=u.NONE,this.stateKey=this.config.stateKey,!G()&&D()&&(R?.strictActionSerializability||R?.strictStateSerializability)&&this.serializer instanceof v&&console.warn("@ngrx/router-store: The serializability runtime checks cannot be enabled with the FullRouterStateSerializer. The FullRouterStateSerializer has an unserializable router state and actions that are not serializable. To use the serializability runtime checks either use the MinimalRouterStateSerializer or implement a custom router state serializer."),this.setUpStoreStateListener(),this.setUpRouterEventsListener()}setUpStoreStateListener(){this.store.pipe(_(this.stateKey),S(this.store)).subscribe(([r,s])=>{this.navigateIfNeeded(r,s)})}navigateIfNeeded(r,s){if(!r||!r.state||this.trigger===u.ROUTER||this.lastEvent instanceof A)return;let o=r.state.url;st(this.router.url,o)||(this.storeState=s,this.trigger=u.STORE,this.router.navigateByUrl(o).catch(l=>{this.errorHandler.handleError(l)}))}setUpRouterEventsListener(){let r=this.config.navigationActionTiming===I.PostActivation,s;this.router.events.pipe(S(this.store)).subscribe(([o,l])=>{this.lastEvent=o,o instanceof A?(this.routerState=this.serializer.serialize(this.router.routerState.snapshot),this.trigger!==u.STORE&&(this.storeState=l,this.dispatchRouterRequest(o))):o instanceof O?(s=o,!r&&this.trigger!==u.STORE&&this.dispatchRouterNavigation(o)):o instanceof Q?(this.dispatchRouterCancel(o),this.reset()):o instanceof T?(this.dispatchRouterError(o),this.reset()):o instanceof L&&(this.trigger!==u.STORE&&(r&&this.dispatchRouterNavigation(s),this.dispatchRouterNavigated(o)),this.reset())})}dispatchRouterRequest(r){this.dispatchRouterAction($,{event:r})}dispatchRouterNavigation(r){let s=this.serializer.serialize(r.state);this.dispatchRouterAction(P,{routerState:s,event:new O(r.id,r.url,r.urlAfterRedirects,s)})}dispatchRouterCancel(r){this.dispatchRouterAction(U,{storeState:this.storeState,event:r})}dispatchRouterError(r){this.dispatchRouterAction(z,{storeState:this.storeState,event:new T(r.id,r.url,`${r}`)})}dispatchRouterNavigated(r){let s=this.serializer.serialize(this.router.routerState.snapshot);this.dispatchRouterAction(J,{event:r,routerState:s})}dispatchRouterAction(r,s){this.trigger=u.ROUTER;try{this.store.dispatch({type:r,payload:b(N({routerState:this.routerState},s),{event:this.config.routerState===0?s.event:{id:s.event.id,url:s.event.url,urlAfterRedirects:s.event.urlAfterRedirects}})})}finally{this.trigger=u.NONE}}reset(){this.trigger=u.NONE,this.storeState=null,this.routerState=null}};t.\u0275fac=function(s){return new(s||t)(h(V),h(k),h(C),h(w),h(X),h(K))},t.\u0275prov=x({token:t,factory:t.\u0275fac});let e=t;return e})();function st(e,t){return Z(e)===Z(t)}function Z(e){return e?.length>0&&e[e.length-1]==="/"?e.substring(0,e.length-1):e}function Pt(e={}){return q([{provide:H,useValue:e},{provide:X,useFactory:it,deps:[H]},{provide:C,useClass:e.serializer?e.serializer:e.routerState===0?v:E},{provide:j,multi:!0,useFactory(){return()=>F(B)}},B])}function ot(){return m(W)}function Y(e=ot()){let t=a(e,i=>i&&i.state),n=a(t,i=>i&&i.root),r=a(n,i=>{if(!i)return;let c=i;for(;c.firstChild;)c=c.firstChild;return c}),s=a(n,i=>i&&i.fragment),o=a(n,i=>i&&i.queryParams),l=i=>a(o,c=>c&&c[i]),g=a(r,i=>i&&i.params),R=i=>a(g,c=>c&&c[i]),M=a(r,i=>i&&i.data),tt=i=>a(M,c=>c&&c[i]),et=a(t,i=>i&&i.url),rt=a(r,i=>{if(i?.routeConfig)return typeof i.routeConfig.title=="string"?i.routeConfig.title:i.title});return{selectCurrentRoute:r,selectFragment:s,selectQueryParams:o,selectQueryParam:l,selectRouteParams:g,selectRouteParam:R,selectRouteData:M,selectRouteDataParam:tt,selectUrl:et,selectTitle:rt}}var at=m("router"),f=Y(at),bt=f.selectCurrentRoute,xt=f.selectQueryParams,Ft=f.selectQueryParam,nt=f.selectRouteParams,jt=f.selectRouteParam,qt=f.selectRouteData,ct=f.selectUrl,wt=a(nt,ct,(e,t)=>({params:e,url:t}));export{P as a,Tt as b,Ot as c,Pt as d,Y as e,xt as f,Ft as g,nt as h,jt as i,qt as j,ct as k,wt as l};