export const __rspack_esm_id="94097";export const __rspack_esm_ids=["94097"];export const __webpack_modules__={90409(t,e,i){i.d(e,{A:()=>a});i(18111),i(61701);function a(t){const e=t.split(":").map(Number);return 3600*e[0]+60*e[1]+e[2]}},27167(t,e,i){i.d(e,{A:()=>s});const a=t=>t<10?`0${t}`:t;function s(t){const e=Math.floor(t/3600),i=Math.floor(t%3600/60),s=Math.floor(t%3600%60);return e>0?`${e}:${a(i)}:${a(s)}`:i>0?`${i}:${a(s)}`:s>0?""+s:null}},49141(t,e,i){i.d(e,{CR:()=>r,PF:()=>l,kL:()=>n,ls:()=>o,pZ:()=>h,r9:()=>c});var a=i(90409),s=i(27167);const n=t=>t.callWS({type:"timer/list"}),r=(t,e)=>t.callWS({type:"timer/create",...e}),c=(t,e,i)=>t.callWS({type:"timer/update",timer_id:e,...i}),h=(t,e)=>t.callWS({type:"timer/delete",timer_id:e}),o=t=>{if(!t.attributes.remaining)return;let e=(0,a.A)(t.attributes.remaining);if("active"===t.state){const i=(new Date).getTime(),a=new Date(t.attributes.finishes_at).getTime();e=Math.max((a-i)/1e3,0)}return e},l=(t,e,i)=>{if(!e)return null;if("idle"===e.state||0===i)return t.formatEntityState(e);let a=(0,s.A)(i||0)||"0";return"paused"===e.state&&(a=`${a} (${t.formatEntityState(e)})`),a}},6344(t,e,i){i.a(t,async function(t,a){try{i.r(e);var s=i(62826),n=i(96196),r=i(97735),c=(i(5078),i(784)),h=i(79757),o=i(85979),l=t([h,o]);[h,o]=l.then?(await l)():l;class u extends n.WF{setConfig(t){if(!t)throw new Error("Invalid configuration");this._config=t}render(){if(!this._config||!this.hass)return n.s6;const t=this.hass.states[this._config.entity];return t?n.qy` <hui-generic-entity-row .hass="${this.hass}" .config="${this._config}"> <div class="text-content"> <ha-timer-remaining-time .hass="${this.hass}" .stateObj="${t}"></ha-timer-remaining-time> </div> </hui-generic-entity-row> `:n.qy` <hui-warning .hass="${this.hass}"> ${(0,o.j)(this.hass,this._config.entity)} </hui-warning> `}shouldUpdate(t){return(0,c.LX)(this,t)}}(0,s.Cg)([(0,r.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,s.Cg)([(0,r.wk)()],u.prototype,"_config",void 0),u=(0,s.Cg)([(0,r.EM)("hui-timer-entity-row")],u),a()}catch(t){a(t)}})},5078(t,e,i){i.r(e);var a=i(62826),s=i(96196),n=i(97735),r=i(49141);class c extends s.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,a.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"stateObj",void 0),(0,a.Cg)([(0,n.wk)()],c.prototype,"timeRemaining",void 0),c=(0,a.Cg)([(0,n.EM)("ha-timer-remaining-time")],c)}};
//# sourceMappingURL=94097.8542eba087049ea4.js.map