import{a as D}from"./chunk-6Y2DN35X.js";import{a as d}from"./chunk-AFI6Z2RM.js";import{a as v,c as w}from"./chunk-VJ6OJDTB.js";import{b as p}from"./chunk-CYVMZNT7.js";import{f as c}from"./chunk-S332DHRQ.js";import{g as f}from"./chunk-JSG72ZNQ.js";import{m as _}from"./chunk-OWZ5YAMH.js";import{S as m,fa as T,la as A,pa as l}from"./chunk-ISMRT7VU.js";import{a as h,b as g}from"./chunk-M5TX2NVG.js";var k=(()=>{class a{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(h({},e),{take:t})).pipe(T(r=>this._store.dispatch(new v(r.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,r=new Date){if(!t||!e)return!1;let n=D(t,"HH:mm:ss",new Date),i=D(e,"HH:mm:ss",new Date),s=p(n,c(n)),u=p(i,c(i)),o=p(r,c(r));return s<u?o>=s&&o<=u:o>=s||o<=u}isNowWithinDateRange(t,e,r=new Date){if(!t)return!1;let n=c(new Date(t)),i=e?d(new Date(e)):null,s=c(new Date(r));if(!i)return s.getTime()>=n.getTime();let u=n<=i?n:i,o=n<=i?i:n,S=s.getTime();return S>=u.getTime()&&S<=o.getTime()}_formatTime(t){return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}:00`}_toRequestModel(t){return{percent:t.discountPercent,startDate:f(t.startDate),endDate:t.endDate?f(d(t.endDate)):null,startTime:t.startTime?this._formatTime(t.startTime):null,endTime:t.endTime?this._formatTime(t.endTime):null,nomenclatureIds:t.positions.map(e=>e.product.id)}}static{this.\u0275fac=function(e){return new(e||a)(l(w),l(_))}}static{this.\u0275prov=A({token:a,factory:a.\u0275fac,providedIn:"root"})}}return a})();export{k as a};
//# sourceMappingURL=chunk-7BKWIOGD.js.map
