import{a}from"./chunk-7SSPIKUV.js";import{b as R}from"./chunk-CYVMZNT7.js";import{g as S,t as r}from"./chunk-S332DHRQ.js";import{c as b}from"./chunk-5QUMV2KP.js";import{La as E}from"./chunk-QHAVDXDG.js";import{a as s}from"./chunk-NF4G3L36.js";import{f as v}from"./chunk-ZQPWXQD7.js";import{a as d}from"./chunk-HEWBVLHR.js";import{c as y}from"./chunk-WXQVX7WD.js";import{m as M}from"./chunk-OWZ5YAMH.js";import{z as $}from"./chunk-GQAU5ACB.js";import{Ea as _,da as x,e as g,k as m,la as D,pa as f,qa as u,x as h}from"./chunk-ISMRT7VU.js";var c=class l{get statusStore$(){return this._statusTrigger$$.pipe(x(()=>this._selectedStore$.pipe($(this.destroyRef),h(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e,t){this._retailStoreService=e,this._localizationService=t,this.destroyRef=u(_),this._selectedStore$=u(M).select(y.selectedStoreId),this._statusTrigger$$=new g}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e){if(e==null)return{name:"",status:a.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:s.None};let t=new Date,n=new Date(e.currentExpiring),i=new Date(e.allExpiring),T=R(i,t),p=S(n,t),o=S(i,t);return T<=0?{name:e.name,status:a.Expired,daysRemaining:null,commonDaysRemaining:i?`${r(i,"dd.MM.yy")}`:null,days:null,commonDays:o?`(${o} ${this._localizationService.getSync("\u0434\u043D.")})`:null,prefix:e.prefix,class:"license-status-expired",commonExpiringDate:r(i,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:s.Expired}:o<=3?{name:e.name,status:a.ExpiredSoon,daysRemaining:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${r(i,"dd.MM.yy")}`,commonDays:`(${o} ${this._localizationService.getSync("\u0434\u043D.")})`,days:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-expired-soon",commonExpiringDate:r(i,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:s.Warning}:{name:e.name,status:a.Active,daysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(n,"dd.MM.yy")}`,commonDaysRemaining:`${r(i,"dd.MM.yy")}`,days:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDays:`(${o} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-active",commonExpiringDate:r(i,"dd.MM.yyyy"),expiringDate:r(new Date(e.currentExpiring),"dd.MM.yyyy"),type:s.Success}}updateStores(e=3){e<=0||this._retailStoreService.getStores().subscribe(t=>{this._statusTrigger$$.next(),t.every(n=>!n?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?e.filter(n=>n.options.filter(i=>(i.visible=!i.licence||!i.licence.includes(t),i.visible)).length):e}_getStore(e){return this._stores.find(t=>t.id===e)}_getCashbox(e){return this._cashboxes.find(t=>t.id===e)}static{this.\u0275fac=function(t){return new(t||l)(f(b),f(E))}}static{this.\u0275prov=D({token:l,factory:l.\u0275fac})}};m([d(y.stores)],c.prototype,"_stores",void 0);m([d(y.selectedStoreId)],c.prototype,"_selectedStoreId",void 0);m([d(v.cashboxes)],c.prototype,"_cashboxes",void 0);export{c as a};
//# sourceMappingURL=chunk-3P6JRLEI.js.map
