export const __rspack_esm_id="28696";export const __rspack_esm_ids=["28696"];export const __webpack_modules__={12150(t,e,s){s.a(t,async function(t,a){try{s.r(e),s.d(e,{HuiPowerTotalBadge:()=>u});s(18111),s(7588),s(17642),s(58004),s(33853),s(45876),s(32475),s(15024),s(31698);var r=s(62826),i=s(96196),o=s(97735),n=s(20058),c=(s(24671),s(67094),s(38114)),h=s(54706),_=t([c,n]);[c,n]=_.then?(await _)():_;const l="M12 3L2 12H5V20H19V12H22L12 3M11.5 18V14H9L12.5 7V11H15L11.5 18Z";class u extends((0,h.E)(i.WF)){setConfig(t){this._config=t}hassSubscribe(){return[(0,c.tb)(this.hass,{key:this._config?.collection_key}).subscribe(t=>{this._data=t})]}shouldUpdate(t){if(t.has("_config")||t.has("_data"))return!0;if(t.has("hass")){const e=t.get("hass");if(!e||!this._entities.size)return!0;for(const t of this._entities)if(e.states[t]!==this.hass?.states[t])return!0}return!1}_getCurrentPower(t){return this._entities.add(t),(0,c.h4)(this.hass.states[t])??0}_computeTotalPower(t){this._entities.clear();let e=0,s=0,a=0,r=0,i=0;t.energy_sources.forEach(t=>{if("solar"===t.type&&t.stat_rate){const s=this._getCurrentPower(t.stat_rate);s>0&&(e+=s)}else if("grid"===t.type&&t.stat_rate){const e=this._getCurrentPower(t.stat_rate);e>0?s+=e:e<0&&(a+=Math.abs(e))}else if("battery"===t.type&&t.stat_rate){const e=this._getCurrentPower(t.stat_rate);e>0?r+=e:e<0&&(i+=Math.abs(e))}});const o=s+e+r-a-i;return Math.max(0,o)}render(){if(!this._config||!this._data)return i.s6;const t=this._computeTotalPower(this._data.prefs);let e="";e=t>=1e3?`${(0,n.ZV)(t/1e3,this.hass.locale,{maximumFractionDigits:2})} kW`:`${(0,n.ZV)(t,this.hass.locale,{maximumFractionDigits:0})} W`;const s=this._config.title||this.hass.localize("ui.panel.lovelace.cards.energy.power_total_title");return i.qy` <ha-badge .label="${s}"> <ha-svg-icon slot="icon" .path="${l}"></ha-svg-icon> ${e} </ha-badge> `}constructor(...t){super(...t),this._entities=new Set,this.hassSubscribeRequiredHostProps=["_config"]}}u.styles=i.AH`ha-badge{--badge-color:var(--primary-color)}`,(0,r.Cg)([(0,o.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,r.Cg)([(0,o.wk)()],u.prototype,"_config",void 0),(0,r.Cg)([(0,o.wk)()],u.prototype,"_data",void 0),u=(0,r.Cg)([(0,o.EM)("hui-power-total-badge")],u),a()}catch(t){a(t)}})},56434(t,e,s){s.d(e,{e:()=>r});var a=s(81977);function r(t,e,s){return(0,a.P)(t,12*e,s)}}};
//# sourceMappingURL=28696.5fd29b2735d8e48f.js.map