export const __webpack_id__="393";export const __webpack_ids__=["393"];export const __webpack_modules__={77773:function(t,e,a){a.d(e,{A:()=>n});const i=t=>t<10?`0${t}`:t;function n(t){const e=Math.floor(t/3600),a=Math.floor(t%3600/60),n=Math.floor(t%3600%60);return e>0?`${e}:${i(a)}:${i(n)}`:a>0?`${a}:${i(n)}`:n>0?""+n:null}},84745:function(t,e,a){a.d(e,{ls:()=>r,PF:()=>s,CR:()=>n});a(65315),a(37089);var i=a(77773);const n=(t,e)=>t.callWS({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(),i=new Date(t.attributes.finishes_at).getTime();e=Math.max((i-a)/1e3,0)}return e},s=(t,e,a)=>{if(!e)return null;if("idle"===e.state||0===a)return t.formatEntityState(e);let n=(0,i.A)(a||0)||"0";return"paused"===e.state&&(n=`${n} (${t.formatEntityState(e)})`),n}},28384:function(t,e,a){a.r(e);var i=a(69868),n=a(84922),r=a(11991),s=a(84745);class l extends n.mN{createRenderRoot(){return this}update(t){super.update(t),this.innerHTML=(0,s.PF)(this.hass,this.stateObj,this.timeRemaining)??"-"}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,i.__decorate)([(0,r.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,i.__decorate)([(0,r.MZ)({attribute:!1})],l.prototype,"stateObj",void 0),(0,i.__decorate)([(0,r.wk)()],l.prototype,"timeRemaining",void 0),l=(0,i.__decorate)([(0,r.EM)("ha-timer-remaining-time")],l)}};
//# sourceMappingURL=393.5e2975380b2181a3.js.map