import{a as h}from"./chunk-WAMXHNDN.js";import{a as D}from"./chunk-AFI6Z2RM.js";import{a as H,c as N}from"./chunk-L2GBFYSY.js";import{a as S}from"./chunk-OR5WJ2OD.js";import{b as l}from"./chunk-CYVMZNT7.js";import{f as a,t as f}from"./chunk-W3BEWLBM.js";import{o as y}from"./chunk-GW2OL5S3.js";import{I as u,Z as v,ea as w,ja as d}from"./chunk-DYUFV4HF.js";import{a as T,b as A}from"./chunk-B7YGBANW.js";var F=(()=>{let i=class i{constructor(e,t){this._nomenclatureDiscountServiceApi=e,this._store=t}getAllNomenclatureDiscounts(e){return this._nomenclatureDiscountServiceApi.getAll(e)}getAllNomenclatureDiscountsForStore(e=1e3){let t=this._nomenclatureDiscountServiceApi.defaultFilter;return this._nomenclatureDiscountServiceApi.getAll(A(T({},t),{take:e})).pipe(v(o=>this._store.dispatch(new H(o.data))))}upsertNomenclatureDiscount(e){return this._nomenclatureDiscountServiceApi.upsert(this._toRequestModel(e)).pipe(u(1))}deleteNomenclatureDiscount(e){return this._nomenclatureDiscountServiceApi.delete(e).pipe(u(1))}sync(){return this._nomenclatureDiscountServiceApi.sync().pipe(u(1))}convertToNomenclature(e){return{id:e.nomenclatureId,name:e.name,barcode:e.barcode,purchasePrice:0,sellPrice:e.sellPrice,unit:e.unit,category:e.category}}isNowWithinTimeRange(e,t,o=new Date){if(!e||!t)return!1;let n=h(e,"HH:mm:ss",new Date),r=h(t,"HH:mm:ss",new Date),s=l(n,a(n)),m=l(r,a(r)),c=l(o,a(o));return s<m?c>=s&&c<=m:c>=s||c<=m}isNowWithinDateRange(e,t,o=new Date){if(!e)return!1;let n=a(new Date(e)),r=t?D(new Date(t)):null,s=a(new Date(o));if(!r)return s.getTime()>=n.getTime();let m=n<=r?n:r,c=n<=r?r:n,g=s.getTime();return g>=m.getTime()&&g<=c.getTime()}_toRequestModel(e){return{percent:e.discountPercent,startDate:S(e.startDate),endDate:e.endDate?S(D(e.endDate)):null,startTime:e.startTime?f(e.startTime,"HH:mm:ss"):null,endTime:e.endTime?f(e.endTime,"HH:mm:ss"):null,nomenclatureIds:e.positions.map(t=>t.product.id)}}};i.\u0275fac=function(t){return new(t||i)(d(N),d(y))},i.\u0275prov=w({token:i,factory:i.\u0275fac,providedIn:"root"});let p=i;return p})();export{F as a};
//# sourceMappingURL=chunk-3IFK7VAW.js.map
