import{a as h}from"./chunk-JOIQPM2P.js";import{a as D}from"./chunk-AFI6Z2RM.js";import{a as y,c as N}from"./chunk-HQXFQCLE.js";import{b as p}from"./chunk-CYVMZNT7.js";import{f as a,t as f}from"./chunk-TL6VKVO7.js";import{c as S}from"./chunk-AMCGKSO5.js";import{p as H}from"./chunk-7WGMNLRJ.js";import{$ as w,K as m,ga as v,la as d}from"./chunk-I3FGJX2C.js";import{a as T,b as g}from"./chunk-B7YGBANW.js";var q=(()=>{let r=class r{constructor(t,e){this._nomenclatureDiscountServiceApi=t,this._store=e}getAllNomenclatureDiscounts(t){return this._nomenclatureDiscountServiceApi.getAll(t)}getAllNomenclatureDiscountsForStore(t=1e3){let e=this._nomenclatureDiscountServiceApi.defaultFilter;return this._nomenclatureDiscountServiceApi.getAll(g(T({},e),{take:t})).pipe(w(s=>this._store.dispatch(new y(s.data))))}upsertNomenclatureDiscount(t){return this._nomenclatureDiscountServiceApi.upsert(this._toRequestModel(t)).pipe(m(1))}deleteNomenclatureDiscount(t){return this._nomenclatureDiscountServiceApi.delete(t).pipe(m(1))}sync(){return this._nomenclatureDiscountServiceApi.sync().pipe(m(1))}isNowWithinTimeRange(t,e,s=new Date){if(!t||!e)return!1;let n=h(t,"HH:mm:ss",new Date),i=h(e,"HH:mm:ss",new Date),o=p(n,a(n)),u=p(i,a(i)),c=p(s,a(s));return o<u?c>=o&&c<=u:c>=o||c<=u}isNowWithinDateRange(t,e,s=new Date){if(!t)return!1;let n=a(new Date(t)),i=e?D(new Date(e)):null,o=a(new Date(s));if(!i)return o.getTime()>=n.getTime();let u=n<=i?n:i,c=n<=i?i:n,A=o.getTime();return A>=u.getTime()&&A<=c.getTime()}_toRequestModel(t){return{percent:t.discountPercent,startDate:S(t.startDate),endDate:t.endDate?S(D(t.endDate)):null,startTime:t.startTime?f(t.startTime,"HH:mm:ss"):null,endTime:t.endTime?f(t.endTime,"HH:mm:ss"):null,nomenclatureIds:t.positions.map(e=>e.product.id)}}};r.\u0275fac=function(e){return new(e||r)(d(N),d(H))},r.\u0275prov=v({token:r,factory:r.\u0275fac,providedIn:"root"});let l=r;return l})();export{q as a};
//# sourceMappingURL=chunk-KKEENRJ5.js.map
