"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["94097"],{27167:function(t,n,e){e.d(n,{A:function(){return a}});e(28706);var i=function(t){return t<10?"0".concat(t):t};function a(t){var n=Math.floor(t/3600),e=Math.floor(t%3600/60),a=Math.floor(t%3600%60);return n>0?"".concat(n,":").concat(i(e),":").concat(i(a)):e>0?"".concat(e,":").concat(i(a)):a>0?""+a:null}},57337:function(t,n,e){e.d(n,{ls:function(){return c},kL:function(){return a},pZ:function(){return u},r9:function(){return s},PF:function(){return o},CR:function(){return r}});e(28706),e(69085),e(62062),e(18111),e(61701),e(2892),e(26099);var i=e(27167),a=function(t){return t.callWS({type:"timer/list"})},r=function(t,n){return t.callWS(Object.assign({type:"timer/create"},n))},s=function(t,n,e){return t.callWS(Object.assign({type:"timer/update",timer_id:n},e))},u=function(t,n){return t.callWS({type:"timer/delete",timer_id:n})},c=function(t){if(t.attributes.remaining){var n,e,i=(n=t.attributes.remaining,3600*(e=n.split(":").map(Number))[0]+60*e[1]+e[2]);if("active"===t.state){var a=(new Date).getTime(),r=new Date(t.attributes.finishes_at).getTime();i=Math.max((r-a)/1e3,0)}return i}},o=function(t,n,e){if(!n)return null;if("idle"===n.state||0===e)return t.formatEntityState(n);var a=(0,i.A)(e||0)||"0";return"paused"===n.state&&(a="".concat(a," (").concat(t.formatEntityState(n),")")),a}},6344:function(t,n,e){e.a(t,async function(t,i){try{e.r(n);var a,r,s=e(72153),u=e(44734),c=e(43080),o=e(69683),h=e(6454),l=(e(16280),e(40445)),f=e(96196),v=e(77845),m=(e(5078),e(784)),g=e(79757),d=e(85979),p=t([g]);g=(p.then?(await p)():p)[0];var y=function(t){function n(){return(0,u.A)(this,n),(0,o.A)(this,n,arguments)}return(0,h.A)(n,t),(0,c.A)(n,[{key:"setConfig",value:function(t){if(!t)throw new Error("Invalid configuration");this._config=t}},{key:"render",value:function(){if(!this._config||!this.hass)return f.s6;var t=this.hass.states[this._config.entity];return t?(0,f.qy)(r||(r=(0,s.A)([' <hui-generic-entity-row .hass="','" .config="','"> <div class="text-content"> <ha-timer-remaining-time .hass="','" .stateObj="','"></ha-timer-remaining-time> </div> </hui-generic-entity-row> '])),this.hass,this._config,this.hass,t):(0,f.qy)(a||(a=(0,s.A)([' <hui-warning .hass="','"> '," </hui-warning> "])),this.hass,(0,d.j)(this.hass,this._config.entity))}},{key:"shouldUpdate",value:function(t){return(0,m.LX)(this,t)}}])}(f.WF);(0,l.Cg)([(0,v.MZ)({attribute:!1})],y.prototype,"hass",void 0),(0,l.Cg)([(0,v.wk)()],y.prototype,"_config",void 0),y=(0,l.Cg)([(0,v.EM)("hui-timer-entity-row")],y),i()}catch(_){i(_)}})},5078:function(t,n,e){e.r(n);var i=e(44734),a=e(43080),r=e(69683),s=e(25460),u=e(6454),c=e(40445),o=e(96196),h=e(77845),l=e(57337),f=function(t){function n(){return(0,i.A)(this,n),(0,r.A)(this,n,arguments)}return(0,u.A)(n,t),(0,a.A)(n,[{key:"createRenderRoot",value:function(){return this}},{key:"update",value:function(t){var e;(0,s.A)(n,"update",this,3)([t]),this.innerHTML=null!==(e=(0,l.PF)(this.hass,this.stateObj,this.timeRemaining))&&void 0!==e?e:"-"}},{key:"connectedCallback",value:function(){(0,s.A)(n,"connectedCallback",this,3)([]),this.stateObj&&this._startInterval(this.stateObj)}},{key:"disconnectedCallback",value:function(){(0,s.A)(n,"disconnectedCallback",this,3)([]),this._clearInterval()}},{key:"willUpdate",value:function(t){(0,s.A)(n,"willUpdate",this,3)([t]),t.has("stateObj")&&this._startInterval(this.stateObj)}},{key:"_clearInterval",value:function(){this._updateRemaining&&(clearInterval(this._updateRemaining),this._updateRemaining=null)}},{key:"_startInterval",value:function(t){var n=this;this._clearInterval(),this._calculateRemaining(t),"active"===t.state&&(this._updateRemaining=setInterval(function(){return n._calculateRemaining(n.stateObj)},1e3))}},{key:"_calculateRemaining",value:function(t){this.timeRemaining=(0,l.ls)(t)}}])}(o.mN);(0,c.Cg)([(0,h.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,c.Cg)([(0,h.MZ)({attribute:!1})],f.prototype,"stateObj",void 0),(0,c.Cg)([(0,h.wk)()],f.prototype,"timeRemaining",void 0),f=(0,c.Cg)([(0,h.EM)("ha-timer-remaining-time")],f)}}]);
//# sourceMappingURL=94097.9bc84e0b80acbfd1.js.map