import{a as P,b as $,c as V}from"./chunk-65ZGL2UQ.js";import{b as j,d as D,e as N,f as O,h as w,i as g,j as x,l as y,m as F,n as v,o as K,p as m,r as L}from"./chunk-WMRP6X7F.js";import{K as A,da as l,fd as S,ja as d,na as b,pa as k}from"./chunk-A4WWLITB.js";import{b as u,i as U}from"./chunk-QOJKCMZT.js";import{a as h}from"./chunk-K4ALXBGI.js";U();var c=class I{static warehouses(s){return s.warehouses}static mainWarehouseId(s){return s.mainWarehouseId}static selectedWarehouseId(s){return s.selectedWarehouseId}setWarehouses(s,e){s.setState({warehouses:e.warehouses,selectedWarehouseId:s.getState().selectedWarehouseId,mainWarehouseId:s.getState().mainWarehouseId})}setMainWarehouse(s,e){s.setState({warehouses:s.getState().warehouses,selectedWarehouseId:s.getState().selectedWarehouseId,mainWarehouseId:e.warehouseId})}setSelectedWarehouse(s,e){s.setState({warehouses:s.getState().warehouses,selectedWarehouseId:e.warehouseId,mainWarehouseId:s.getState().mainWarehouseId})}static{this.\u0275fac=function(e){return new(e||I)}}static{this.\u0275prov=l({token:I,factory:I.\u0275fac})}};u([v(P)],c.prototype,"setWarehouses",null);u([v($)],c.prototype,"setMainWarehouse",null);u([v(V)],c.prototype,"setSelectedWarehouse",null);u([m()],c,"warehouses",null);u([m()],c,"mainWarehouseId",null);u([m()],c,"selectedWarehouseId",null);c=u([K({name:"warehouse",defaults:{warehouses:[],selectedWarehouseId:null,mainWarehouseId:null}})],c);function _(){return()=>{}}var T=(()=>{class r{initialState;static \u0275fac=function(t){return new(t||r)};static \u0275prov=l({token:r,factory:r.\u0275fac})}return r})(),C=(()=>{class r{actions$;store;resetService;constructor(e,t,a){this.actions$=e,this.store=t,this.resetService=a,this.actions$.pipe(y(D),A(1)).subscribe(()=>this.resetService.initialState=this.store.snapshot()),this.actions$.pipe(y(N)).subscribe(({addedStates:o})=>this.resetService.initialState=h(h({},this.resetService.initialState),o))}static \u0275fac=function(t){return new(t||r)(d(x),d(F),d(T))};static \u0275prov=l({token:r,factory:r.\u0275fac})}return r})(),q=(()=>{class r{static type="@@CLEAR_STATE";statesToKeep;constructor(...e){let t=M(S());this.statesToKeep=e.reduce(t,[])}}return r})(),z=(()=>{class r{static type="@@RESET_STATE";statesToReset;constructor(...e){let t=M(S());this.statesToReset=e.reduce(t,[])}}return r})(),B=(()=>{class r{static type="@@RESET_STATE_ALL";statesToKeep;constructor(...e){let t=M(S());this.statesToKeep=e.reduce(t,[])}}return r})(),G=(()=>{class r{static type="@@OVERWRITE_STATE";statesToOverwrite;values;constructor(...e){let t=H(S()),[a,o]=e.reduce(t,[[],[]]);this.statesToOverwrite=a,this.values=o}}return r})();function R(r,s){let e=new Object(j(r));return!(e.name&&"defaults"in e)&&s===-2?(console.warn(`Reset Plugin Warning: ${e.name} is not a state class.`),null):e}function M(r){return(s,e)=>{let t=R(e,~r);return t?s.concat(t):s}}function H(r){return(s,[e,t])=>{let a=R(e,~r);return a?[s[0].concat(a),s[1].concat(t)]:s}}var J=(()=>{class r{resetService;constructor(e){this.resetService=e}clearStates(e,t){return t.reduce((a,o)=>{let n=W(o);if(!n)return a;let i=n.split("."),p=g(e,n);return i.reduceRight((E,f)=>f in a?{[f]:h(h({},a[f]),E)}:{[f]:E},p)},{})}overwriteStates(e,t,a){return t.forEach((o,n)=>{let i=W(o);i&&(e=w(e,i,a[n]))}),e}resetStates(e,t){return t.forEach(a=>{let o=W(a);o&&(e=w(e,o,typeof a.defaults>"u"?{}:a.defaults),a.children&&(e=this.resetStates(e,a.children.map(R))))}),e}resetStatesAll(e,t){let[a,o]=t.reduce((n,i)=>{let p=W(i);return p&&(n[0].push(i),n[1].push(g(e,p))),n},[[],[]]);return this.overwriteStates(this.resetService.initialState,a,o)}handle(e,t,a){switch(O(t)){case q.type:e=this.clearStates(e,t.statesToKeep);break;case z.type:e=this.resetStates(e,t.statesToReset);break;case B.type:e=this.resetStatesAll(e,t.statesToKeep);break;case G.type:let{statesToOverwrite:n,values:i}=t;e=this.overwriteStates(e,n,i);break;default:break}return a(e,t)}static \u0275fac=function(t){return new(t||r)(d(T))};static \u0275prov=l({token:r,factory:r.\u0275fac})}return r})();function W(r){return r.path}function ie(){return k([L(J),T,C,{provide:b,useFactory:_,deps:[C],multi:!0}])}export{c as a,z as b,ie as c};
