"use strict";(self.webpackChunkknx_frontend=self.webpackChunkknx_frontend||[]).push([[1126],{53935:function(t,e,n){n.d(e,{A:function(){return i}});n(77052);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}},25705:function(t,e,n){n.d(e,{PF:function(){return c},CR:function(){return i},ls:function(){return r}});n(77052),n(43859),n(36724),n(650),n(98168);var a=n(53935),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}},c=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}},61126:function(t,e,n){n.r(e);var a=n(36683),i=n(89231),r=n(29864),c=n(83647),u=n(8364),o=n(27526),l=(n(77052),n(98597)),s=n(196),d=n(25705);(0,u.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,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];return e=(0,r.A)(this,n,[].concat(c)),t(e),e}return(0,c.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)}}]);