"use strict";(self.webpackChunkplugin_store_frontend=self.webpackChunkplugin_store_frontend||[]).push([[1054],{3527:function(t,e,n){n.d(e,{A:function(){return i}});n(81027);var a=function(t){return t<10?"0".concat(t):t};function i(t){var e=Math.floor(t/3600),n=Math.floor(t%3600/60),i=Math.floor(t%3600%60);return e>0?"".concat(e,":").concat(a(n),":").concat(a(i)):n>0?"".concat(n,":").concat(a(i)):i>0?""+i:null}},88399:function(t,e,n){n.d(e,{PF:function(){return u},CR:function(){return i},ls:function(){return r}});n(81027),n(26098),n(97741),n(29193),n(16891);var a=n(3527),i=function(t,e){return t.callWS(Object.assign({type:"timer/create"},e))},r=function(t){if(t.attributes.remaining){var e,n,a=(e=t.attributes.remaining,3600*(n=e.split(":").map(Number))[0]+60*n[1]+n[2]);if("active"===t.state){var i=(new Date).getTime(),r=new Date(t.last_changed).getTime();a=Math.max(a-(i-r)/1e3,0)}return a}},u=function(t,e,n){if(!e)return null;if("idle"===e.state||0===n)return t.formatEntityState(e);var i=(0,a.A)(n||0)||"0";return"paused"===e.state&&(i="".concat(i," (").concat(t.formatEntityState(e),")")),i}},51054:function(t,e,n){n.r(e);var a=n(35806),i=n(71008),r=n(62193),u=n(2816),c=n(27927),o=n(35890),l=(n(81027),n(50289)),s=n(29818),d=n(88399);(0,c.A)([(0,s.EM)("ha-timer-remaining-time")],(function(t,e){var n=function(e){function n(){var e;(0,i.A)(this,n);for(var a=arguments.length,u=new Array(a),c=0;c<a;c++)u[c]=arguments[c];return e=(0,r.A)(this,n,[].concat(u)),t(e),e}return(0,u.A)(n,e),(0,a.A)(n)}(e);return{F:n,d:[{kind:"field",decorators:[(0,s.MZ)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,s.MZ)({attribute:!1})],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,s.wk)()],key:"timeRemaining",value:void 0},{kind:"field",key:"_updateRemaining",value:void 0},{kind:"method",key:"createRenderRoot",value:function(){return this}},{kind:"method",key:"update",value:function(t){var e;(0,o.A)(n,"update",this,3)([t]),this.innerHTML=null!==(e=(0,d.PF)(this.hass,this.stateObj,this.timeRemaining))&&void 0!==e?e:"-"}},{kind:"method",key:"connectedCallback",value:function(){(0,o.A)(n,"connectedCallback",this,3)([]),this.stateObj&&this._startInterval(this.stateObj)}},{kind:"method",key:"disconnectedCallback",value:function(){(0,o.A)(n,"disconnectedCallback",this,3)([]),this._clearInterval()}},{kind:"method",key:"willUpdate",value:function(t){(0,o.A)(n,"willUpdate",this,3)([t]),t.has("stateObj")&&this._startInterval(this.stateObj)}},{kind:"method",key:"_clearInterval",value:function(){this._updateRemaining&&(clearInterval(this._updateRemaining),this._updateRemaining=null)}},{kind:"method",key:"_startInterval",value:function(t){var e=this;this._clearInterval(),this._calculateRemaining(t),"active"===t.state&&(this._updateRemaining=setInterval((function(){return e._calculateRemaining(e.stateObj)}),1e3))}},{kind:"method",key:"_calculateRemaining",value:function(t){this.timeRemaining=(0,d.ls)(t)}}]}}),l.mN)}}]);
//# sourceMappingURL=1054.2sGa23u2BVA.js.map