import{b as v,c as _}from"./chunk-ZJ56VDA3.js";import{a as d}from"./chunk-2RGQU2W2.js";import{d as g}from"./chunk-CZPAHUJN.js";import{a as W}from"./chunk-Y4KZVCMP.js";import{c as n}from"./chunk-SRKRR7GV.js";import{a as m}from"./chunk-TWAW6QQO.js";import{o as u}from"./chunk-AEEDSABA.js";import{J as i,_ as h,fa as f,ka as o,la as l,q as S}from"./chunk-4HRPSKID.js";import{d as a,n as y}from"./chunk-INB5GR2I.js";y();var t,c=(t=class{get warehouseOptions(){let e=this._stores.find(r=>r.id===this._storeId);return e?e.warehouses:[]}constructor(e,r,s,p){this._warehouseServiceApi=e,this._permissionService=r,this._retailStoreService=s,this._store=p,this._store$=l(u).select(n.selectedStoreId)}getWarehouses(e=!1){return this._warehouseServiceApi.getWarehouses(e).pipe(h(r=>this._store.dispatch(new W(r))),i(1))}getWarehouseAll(){return this._warehouseServiceApi.getWarehouseAll().pipe(i(1))}createWarehouse(e){return this._warehouseServiceApi.createWarehouse(e).pipe(h(()=>this.getWarehouses().subscribe()),i(1))}editWarehouse(e,r){return this._warehouseServiceApi.editWarehouse(e,r).pipe(h(()=>{this.getWarehouses().subscribe(),this._retailStoreService.getStores().subscribe()}),i(1))}syncWarehouse(){return this._warehouseServiceApi.syncWarehouse().pipe(i(1))}getWarehouseRemains(e,r,s=!1){let p={criteria:{filter:{nomenclatureIds:r,viewArchived:!0},search:null},take:r.length??100,skip:0,isAscending:!0,orderBy:"id"};return this._warehouseServiceApi.getWarehouseRemains(e,p,s).pipe(S(w=>w.data),i(1))}getWarehouseOptionByPermission(e){let r=[];return this._store$.pipe(i(1)).subscribe(s=>{r=this.filterWarehousesByPermission(this.getStoreById(s).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)}},t.\u0275fac=function(r){return new(r||t)(o(v),o(g),o(_),o(u))},t.\u0275prov=f({token:t,factory:t.\u0275fac}),t);a([m(n.stores)],c.prototype,"_stores",void 0);a([m(n.selectedStoreId)],c.prototype,"_storeId",void 0);c=a([d()],c);export{c as a};
//# sourceMappingURL=chunk-5SXN6XJU.js.map
