import{b as g}from"./chunk-GDZZ2BEY.js";import{b as v,c as _}from"./chunk-L7HVTKKS.js";import{a as d}from"./chunk-EK6YV2TW.js";import{a as W}from"./chunk-Y4KZVCMP.js";import{c as n}from"./chunk-VJXA7ZH3.js";import{a as m}from"./chunk-Y75MWVBQ.js";import{o as u}from"./chunk-GW2OL5S3.js";import{I as i,Z as h,ea as f,ja as o,ka as l,q as S}from"./chunk-DYUFV4HF.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-5SFZUEAO.js.map
