"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["393"],{77773:function(t,e,a){a.d(e,{A:function(){return i}});const n=t=>t<10?`0${t}`:t;function i(t){const e=Math.floor(t/3600),a=Math.floor(t%3600/60),i=Math.floor(t%3600%60);return e>0?`${e}:${n(a)}:${n(i)}`:a>0?`${a}:${n(i)}`:i>0?""+i:null}},84745:function(t,e,a){a.d(e,{ls:function(){return r},PF:function(){return s},CR:function(){return i}});a(12977),a(65315),a(37089);var n=a(77773);const i=(t,e)=>t.callWS(Object.assign({type:"timer/create"},e)),r=t=>{if(!t.attributes.remaining)return;let e=function(t){const e=t.split(":").map(Number);return 3600*e[0]+60*e[1]+e[2]}(t.attributes.remaining);if("active"===t.state){const a=(new Date).getTime(),n=new Date(t.attributes.finishes_at).getTime();e=Math.max((n-a)/1e3,0)}return e},s=(t,e,a)=>{if(!e)return null;if("idle"===e.state||0===a)return t.formatEntityState(e);let i=(0,n.A)(a||0)||"0";return"paused"===e.state&&(i=`${i} (${t.formatEntityState(e)})`),i}},28384:function(t,e,a){a.r(e);var n=a(69868),i=a(84922),r=a(11991),s=a(84745);class l extends i.mN{createRenderRoot(){return this}update(t){var e;super.update(t),this.innerHTML=null!==(e=(0,s.PF)(this.hass,this.stateObj,this.timeRemaining))&&void 0!==e?e:"-"}connectedCallback(){super.connectedCallback(),this.stateObj&&this._startInterval(this.stateObj)}disconnectedCallback(){super.disconnectedCallback(),this._clearInterval()}willUpdate(t){super.willUpdate(t),t.has("stateObj")&&this._startInterval(this.stateObj)}_clearInterval(){this._updateRemaining&&(clearInterval(this._updateRemaining),this._updateRemaining=null)}_startInterval(t){this._clearInterval(),this._calculateRemaining(t),"active"===t.state&&(this._updateRemaining=setInterval(()=>this._calculateRemaining(this.stateObj),1e3))}_calculateRemaining(t){this.timeRemaining=(0,s.ls)(t)}}(0,n.__decorate)([(0,r.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,n.__decorate)([(0,r.MZ)({attribute:!1})],l.prototype,"stateObj",void 0),(0,n.__decorate)([(0,r.wk)()],l.prototype,"timeRemaining",void 0),l=(0,n.__decorate)([(0,r.EM)("ha-timer-remaining-time")],l)}}]);
//# sourceMappingURL=393.7f269125e1a90c67.js.map