import{a as l}from"./chunk-MJT556FT.js";import{a as d}from"./chunk-NF4G3L36.js";import{g,t as n}from"./chunk-W3BEWLBM.js";import{g as S}from"./chunk-LINAD4CC.js";import{c as I}from"./chunk-4WBIDQ26.js";import{d as z}from"./chunk-N2FMBWO7.js";import{a as $,b as v}from"./chunk-VXSBHXCN.js";import{b as R}from"./chunk-X6G2MEQP.js";import{c as y}from"./chunk-BYOG7O4N.js";import{a as p}from"./chunk-4QCIIFWS.js";import{n as E}from"./chunk-DC6G5OHZ.js";import{_ as D,g as h,ia as M,na as f,oa as _,q as x}from"./chunk-C2QKZJOP.js";import{d as c,n as C}from"./chunk-INB5GR2I.js";function b(s,e){return+S(s)-+S(e)}C();function T(s){return e=>{let r=(s?Math[s]:Math.trunc)(e);return r===0?0:r}}function w(s,e,t){let r=b(s,e)/1e3;return T(t?.roundingMethod)(r)}var o,m=(o=class{get statusStore$(){return this._statusTrigger$$.pipe(D(()=>this._selectedStore$.pipe(v(this),x(e=>this.getStatus(this._getStore(e)?.license)))))}constructor(e,t){this._retailStoreService=e,this._localizationService=t,this._selectedStore$=_(E).select(y.selectedStoreId),this._statusTrigger$$=new h}getStatusCashbox(e){return this.getStatus(this._getCashbox(e)?.license)}getStatus(e){if(e==null)return{name:"",status:l.None,daysRemaining:null,commonDaysRemaining:null,days:null,commonDays:null,prefix:null,class:"license-status-none",type:d.None};let t=new Date,r=new Date(e.currentExpiring),i=new Date(e.allExpiring),j=w(i,t),u=g(r,t),a=g(i,t);return j<=0?{name:e.name,status:l.Expired,daysRemaining:null,commonDaysRemaining:i?`${this._localizationService.getSync("\u0434\u043E")} ${n(i,"dd.MM.yy")}`:null,days:null,commonDays:a?`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`:null,prefix:e.prefix,class:"license-status-expired",commonExpiringDate:n(i,"dd.MM.yyyy"),expiringDate:n(new Date(e.currentExpiring),"dd.MM.yyyy"),type:d.Expired}:a<=3?{name:e.name,status:l.ExpiredSoon,daysRemaining:`(${u} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${n(i,"dd.MM.yy")}`,commonDays:`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`,days:`(${u} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-expired-soon",commonExpiringDate:n(i,"dd.MM.yyyy"),expiringDate:n(new Date(e.currentExpiring),"dd.MM.yyyy"),type:d.Warning}:{name:e.name,status:l.Active,daysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${n(r,"dd.MM.yy")}`,commonDaysRemaining:`${this._localizationService.getSync("\u0434\u043E")} ${n(i,"dd.MM.yy")}`,days:`(${u} ${this._localizationService.getSync("\u0434\u043D.")})`,commonDays:`(${a} ${this._localizationService.getSync("\u0434\u043D.")})`,prefix:e.prefix,class:"license-status-active",commonExpiringDate:n(i,"dd.MM.yyyy"),expiringDate:n(new Date(e.currentExpiring),"dd.MM.yyyy"),type:d.Success}}updateStores(e=3){e<=0||this._retailStoreService.getStores().subscribe(t=>{this._statusTrigger$$.next(),t.every(r=>!r?.license)&&setTimeout(()=>this.updateStores(e-1),1e4)})}filteredItems(e){let t=this._getStore(this._selectedStoreId)?.license?.prefix;return t?e.filter(r=>r.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)}},o.\u0275fac=function(t){return new(t||o)(f(I),f(z))},o.\u0275prov=M({token:o,factory:o.\u0275fac}),o);c([p(y.stores)],m.prototype,"_stores",void 0);c([p(y.selectedStoreId)],m.prototype,"_selectedStoreId",void 0);c([p(R.cashboxes)],m.prototype,"_cashboxes",void 0);m=c([$()],m);export{T as a,b,w as c,m as d};
//# sourceMappingURL=chunk-5WEBYVUG.js.map
