import{a as m}from"./chunk-7SSPIKUV.js";import{a as c}from"./chunk-NF4G3L36.js";import{b as R}from"./chunk-CYVMZNT7.js";import{c as b}from"./chunk-RMVUOGNJ.js";import{g as S,t as r}from"./chunk-TL6VKVO7.js";import{e as E}from"./chunk-RCWJCOBH.js";import{a as _,b as $}from"./chunk-IGFM5CCE.js";import{c as M}from"./chunk-J7KKTDSX.js";import{c as l}from"./chunk-7R42RYQZ.js";import{a as d}from"./chunk-LJUR6GAC.js";import{p as v}from"./chunk-7WGMNLRJ.js";import{Z as h,g as f,ga as x,la as u,ma as D,q as g}from"./chunk-I3FGJX2C.js";import{d as a,n as w}from"./chunk-INB5GR2I.js";w();var n,y=(n=class{get statusStore$(){return this._statusTrigger$$.pipe(h(()=>this._selectedStore$.pipe($(this),g(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e,t){this._retailStoreService=e,this._localizationService=t,this._selectedStore$=D(v).select(l.selectedStoreId),this._statusTrigger$$=new f}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e){if(e==null)return{name:"",status:m.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:c.None};let t=new Date,o=new Date(e.currentExpiring),i=new Date(e.allExpiring),T=R(i,t),p=S(o,t),s=S(i,t);return T<=0?{name:e.name,status:m.Expired,daysRemaining:null,commonDaysRemaining:i?`${r(i,"dd.MM.yy")}`:null,days:null,commonDays:s?`(${s} ${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:c.Expired}:s<=3?{name:e.name,status:m.ExpiredSoon,daysRemaining:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${r(i,"dd.MM.yy")}`,commonDays:`(${s} ${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:c.Warning}:{name:e.name,status:m.Active,daysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${r(o,"dd.MM.yy")}`,commonDaysRemaining:`${r(i,"dd.MM.yy")}`,days:`(${p} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDays:`(${s} ${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:c.Success}}updateStores(e=3){e<=0||this._retailStoreService.getStores().subscribe(t=>{this._statusTrigger$$.next(),t.every(o=>!o?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?e.filter(o=>o.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)}},n.\u0275fac=function(t){return new(t||n)(u(b),u(E))},n.\u0275prov=x({token:n,factory:n.\u0275fac}),n);a([d(l.stores)],y.prototype,"_stores",void 0);a([d(l.selectedStoreId)],y.prototype,"_selectedStoreId",void 0);a([d(M.cashboxes)],y.prototype,"_cashboxes",void 0);y=a([_()],y);export{y as a};
//# sourceMappingURL=chunk-N4WJOX2S.js.map
