import{a as m}from"./chunk-6Y2DN35X.js";import{t as o}from"./chunk-S332DHRQ.js";import{a as l}from"./chunk-KXX3UDJ3.js";import{j as a}from"./chunk-GQAU5ACB.js";import{la as s,pa as n}from"./chunk-ISMRT7VU.js";var p=(()=>{class i{constructor(t){this._http=t}getById(t){return this._http.get("/api/sell-restriction",{params:{cashboxId:t}})}create(t){return this._http.post("/api/sell-restriction/category-time",t)}delete(t){return this._http.delete(`/api/sell-restriction/${t}`)}sync(t){return this._http.post(`/api/sell-restriction/${t}/sync`,{},{headers:l})}static{this.\u0275fac=function(e){return new(e||i)(n(a))}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac,providedIn:"root"})}}return i})();var S=(()=>{class i{constructor(t){this._sellRestrictionServiceApi=t}getSellRestriction(t){return this._sellRestrictionServiceApi.getById(t)}createSellRestriction(t){return this._sellRestrictionServiceApi.create(t)}buildCreateRequest(t,e){if(!e.categoryId||!e.startTime||!e.endTime)return null;let r=`${this._formatTimeToString(e.startTime)}:00`,c=`${this._formatTimeToString(e.endTime)}:00`;return this._createRestrictionRequest(t,e.categoryId,r,c)}deleteSellRestriction(t){return this._sellRestrictionServiceApi.delete(t)}sync(t){return this._sellRestrictionServiceApi.sync(t)}isRestrictionActive(t,e){let r=o(new Date,"HH:mm:ss");return t<=e?r>=t&&r<=e:r>=t||r<=e}getActiveSellRestriction(t){return t?.find(e=>this.isRestrictionActive(e.startTime,e.endTime))}hasActiveSellRestriction(t){return!!this.getActiveSellRestriction(t)}formatRestrictionTime(t){return o(m(t,"HH:mm:ss",new Date),"HH:mm")}getRestrictionBadgeText(t,e){let r=this.getActiveSellRestriction(t);return r?`${e("\u0417\u0430\u043F\u0440\u0435\u0442 \u0434\u043E")} ${this.formatRestrictionTime(r.endTime)}`:""}_formatTimeToString(t){return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}_createRestrictionRequest(t,e,r,c){return{cashboxId:t,categoryId:e,startTime:r,endTime:c}}static{this.\u0275fac=function(e){return new(e||i)(n(p))}}static{this.\u0275prov=s({token:i,factory:i.\u0275fac})}}return i})();export{S as a};
//# sourceMappingURL=chunk-DVRTUVCM.js.map
