export const __rspack_esm_id="20283";export const __rspack_esm_ids=["20283"];export const __webpack_modules__={27167(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}},57337(t,e,a){a.d(e,{ls:()=>c,kL:()=>n,pZ:()=>l,r9:()=>r,PF:()=>o,CR:()=>s});a(18111),a(61701);var i=a(27167);const n=t=>t.callWS({type:"timer/list"}),s=(t,e)=>t.callWS({type:"timer/create",...e}),r=(t,e,a)=>t.callWS({type:"timer/update",timer_id:e,...a}),l=(t,e)=>t.callWS({type:"timer/delete",timer_id:e}),c=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},o=(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}},5078(t,e,a){a.r(e);var i=a(62826),n=a(96196),s=a(44457),r=a(57337);class l extends n.mN{createRenderRoot(){return this}update(t){super.update(t),this.innerHTML=(0,r.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,r.ls)(t)}}(0,i.Cg)([(0,s.MZ)({attribute:!1})],l.prototype,"hass",void 0),(0,i.Cg)([(0,s.MZ)({attribute:!1})],l.prototype,"stateObj",void 0),(0,i.Cg)([(0,s.wk)()],l.prototype,"timeRemaining",void 0),l=(0,i.Cg)([(0,s.EM)("ha-timer-remaining-time")],l)}};
//# sourceMappingURL=20283.bf472c1799aa64d0.js.map