import{b as W,c as _}from"./chunk-5QUMV2KP.js";import{d as v}from"./chunk-OC7PGGXC.js";import{a as d}from"./chunk-OCLYE42A.js";import{a as m}from"./chunk-HEWBVLHR.js";import{c as h}from"./chunk-WXQVX7WD.js";import{m as a}from"./chunk-OWZ5YAMH.js";import{S as t,fa as o,k as p,la as f,pa as s,qa as l,x as S}from"./chunk-ISMRT7VU.js";var u=class n{get warehouseOptions(){let e=this._stores.find(r=>r.id===this._storeId);return e?e.warehouses:[]}constructor(e,r,i,c){this._warehouseServiceApi=e,this._permissionService=r,this._retailStoreService=i,this._store=c,this._store$=l(a).select(h.selectedStoreId)}getWarehouses(e=!1){return this._warehouseServiceApi.getWarehouses(e).pipe(o(r=>this._store.dispatch(new d(r))),t(1))}getWarehouseAll(){return this._warehouseServiceApi.getWarehouseAll().pipe(t(1))}createWarehouse(e){return this._warehouseServiceApi.createWarehouse(e).pipe(o(()=>this.getWarehouses().subscribe()),t(1))}editWarehouse(e,r){return this._warehouseServiceApi.editWarehouse(e,r).pipe(o(()=>{this.getWarehouses().subscribe(),this._retailStoreService.getStores().subscribe()}),t(1))}syncWarehouse(){return this._warehouseServiceApi.syncWarehouse().pipe(t(1))}getWarehouseRemains(e,r,i=!1){let c={criteria:{filter:{nomenclatureIds:r,viewArchived:!0},search:null},take:r.length??100,skip:0,isAscending:!0,orderBy:"id"};return this._warehouseServiceApi.getWarehouseRemains(e,c,i).pipe(S(g=>g.data),t(1))}getWarehouseOptionByPermission(e){let r=[];return this._store$.pipe(t(1)).subscribe(i=>{r=this.filterWarehousesByPermission(this.getStoreById(i).warehouses,e)}),r}getStoresWarehouses(e){return e?e.warehouses:[]}filterWarehousesByPermission(e,r){return r?e.filter(()=>this._permissionService.hasPermissions(r)):e}getStoreById(e){return this._stores.find(r=>r.id===e)}static{this.\u0275fac=function(r){return new(r||n)(s(W),s(v),s(_),s(a))}}static{this.\u0275prov=f({token:n,factory:n.\u0275fac})}};p([m(h.stores)],u.prototype,"_stores",void 0);p([m(h.selectedStoreId)],u.prototype,"_storeId",void 0);export{u as a};
//# sourceMappingURL=chunk-2JBQM4A4.js.map
