export const __rspack_esm_id="73618";export const __rspack_esm_ids=["73618"];export const __webpack_modules__={62284(e,t,s){s.a(e,async function(e,i){try{s.r(t),s.d(t,{HuiEnergyCompareCard:()=>u});var a=s(62826),r=s(6946),o=s(73983),h=s(96196),n=s(97735),c=s(72487),p=s(38114),l=s(54706),d=s(784),_=s(38962),y=s(1087),g=s(14503),m=e([_,c,p]);[_,c,p]=m.then?(await m)():m;class u extends((0,l.E)(h.WF)){static async getConfigElement(){return await s.e("79062").then(s.bind(s,54197)),document.createElement("hui-energy-graph-card-editor")}static getStubConfig(e,t,s){return{type:"energy-compare"}}getCardSize(){return 1}setConfig(e){e.collection_key&&(0,p.s8)(e.collection_key),this._config=e}hassSubscribe(){return[(0,p.tb)(this.hass,{key:this._config.collection_key}).subscribe(e=>this._update(e))]}shouldUpdate(e){return(0,d.xP)(this,e)||e.has("preview")||e.size>1||!e.has("hass")}update(e){super.update(e),e.has("preview")&&this._checkVisibility()}render(){if(this.preview)return h.qy` <ha-alert> ${this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.info",{start:h.qy`<b>${(0,c.Yq)(new Date,this.hass.locale,this.hass.config)}</b>`,end:h.qy`<b>${(0,c.Yq)(new Date,this.hass.locale,this.hass.config)}</b> <span>(${this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_preview")})</span>`})} </ha-alert> `;if(!this._startCompare||!this._endCompare)return h.s6;const e=(0,r.c)(this._endCompare,this._startCompare);return h.qy` <ha-alert dismissable @alert-dismissed-clicked="${this._stopCompare}"> ${this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.info",{start:h.qy`<b>${(0,c.Yq)(this._start,this.hass.locale,this.hass.config)}${e>0?` -\n          ${(0,c.Yq)(this._end||(0,o.D)(new Date),this.hass.locale,this.hass.config)}`:""}</b>`,end:h.qy`<b>${(0,c.Yq)(this._startCompare,this.hass.locale,this.hass.config)}${e>0?` -\n          ${(0,c.Yq)(this._endCompare,this.hass.locale,this.hass.config)}`:""}</b> <button class="link" @click="${this._changeCompareMode}"> (${this._compareMode===p.lh.PREVIOUS?this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_previous_year"):this.hass.localize("ui.panel.lovelace.cards.energy.energy_compare.compare_previous_period")}) </button>`})} </ha-alert> `}_changeCompareMode(){const e=(0,p.tb)(this.hass,{key:this._config.collection_key});e.setCompare(this._compareMode===p.lh.PREVIOUS?p.lh.YOY:p.lh.PREVIOUS),e.refresh()}_update(e){this._start=e.start,this._end=e.end,this._startCompare=e.startCompare,this._endCompare=e.endCompare,this._compareMode=e.compareMode,this._checkVisibility()}_checkVisibility(){const e=this.hidden;this.hidden=!this._startCompare&&!this.preview,e!==this.hidden&&(0,y.r)(this,"card-visibility-changed")}_stopCompare(){const e=(0,p.tb)(this.hass,{key:this._config.collection_key});e.setCompare(p.lh.NONE),e.refresh()}constructor(...e){super(...e),this.hidden=!0,this.preview=!1,this.connectedWhileHidden=!0,this.hassSubscribeRequiredHostProps=["_config"]}}u.styles=[g.og],(0,a.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,a.Cg)([(0,n.wk)()],u.prototype,"_config",void 0),(0,a.Cg)([(0,n.wk)()],u.prototype,"_start",void 0),(0,a.Cg)([(0,n.wk)()],u.prototype,"_end",void 0),(0,a.Cg)([(0,n.wk)()],u.prototype,"_startCompare",void 0),(0,a.Cg)([(0,n.wk)()],u.prototype,"_endCompare",void 0),(0,a.Cg)([(0,n.wk)()],u.prototype,"_compareMode",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],u.prototype,"hidden",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"preview",void 0),u=(0,a.Cg)([(0,n.EM)("hui-energy-compare-card")],u),i()}catch(e){i(e)}})},56434(e,t,s){s.d(t,{e:()=>a});var i=s(81977);function a(e,t,s){return(0,i.P)(e,12*t,s)}}};
//# sourceMappingURL=73618.3ab3ec0d0134fd80.js.map