export const __rspack_esm_id="33427";export const __rspack_esm_ids=["33427"];export const __webpack_modules__={67806(t,i,s){s.a(t,async function(t,e){try{s.r(i),s.d(i,{HuiGraphHeaderFooter:()=>g});var o=s(62826),r=s(96196),n=s(44457),a=s(36312),h=s(71727),c=s(65829),_=s(25064),d=s(13632),u=s(18721),l=(s(46658),t([c,_]));[c,_]=l.then?(await l)():l;const b=6e4,p=60*b,f=["counter","input_number","number","sensor"];class g extends r.WF{static async getConfigElement(){return await Promise.all([s.e("44533"),s.e("92769"),s.e("44966"),s.e("52242"),s.e("80445"),s.e("19656"),s.e("31833")]).then(s.bind(s,87031)),document.createElement("hui-graph-footer-editor")}static getStubConfig(t,i,s){return{type:"graph",entity:(0,d.B)(t,1,i,s,f,t=>!isNaN(Number(t.state))&&!!t.attributes.unit_of_measurement)[0]||""}}getCardSize(){return 3}setConfig(t){if(!t?.entity||!f.includes((0,h.m)(t.entity)))throw new Error("Specify an entity from within the sensor domain");const i={detail:1,hours_to_show:24,...t};i.hours_to_show=Number(i.hours_to_show),i.detail=1===i.detail||2===i.detail?i.detail:1,this._config=i}render(){return this._config&&this.hass?this._error?r.qy`<div class="errors">${this._error}</div>`:this._coordinates?this._coordinates.length?r.qy` <hui-graph-base .coordinates="${this._coordinates}"></hui-graph-base> `:r.qy` <div class="container"> <div class="info">No state history found.</div> </div> `:r.qy` <div class="container"> <ha-spinner size="small"></ha-spinner> </div> `:r.s6}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this._config&&this._subscribeHistory()}disconnectedCallback(){super.disconnectedCallback(),this._unsubscribeHistory()}_subscribeHistory(){(0,a.x)(this.hass,"history")&&!this._subscribed&&this._config&&(this._subscribed=(0,_.IQ)(this.hass,t=>{if(!this._subscribed||!this._config)return;const i=this.clientWidth||this.offsetWidth,s=Math.max(10,this._config.detail>1?Math.max(i/5,this._config.hours_to_show):this._config.hours_to_show),e=2!==this._config.detail,{points:o}=(0,u.a)(t[this._config.entity],i,i/5,s,{minY:this._config.limits?.min,maxY:this._config.limits?.max},e);this._coordinates=o},this._config.hours_to_show,[this._config.entity]).catch(t=>{this._subscribed=void 0,this._error=t}),this._setRedrawTimer())}_redrawGraph(){this._coordinates&&(this._coordinates=[...this._coordinates])}_setRedrawTimer(){clearInterval(this._interval),this._interval=window.setInterval(()=>this._redrawGraph(),this._config.hours_to_show>24?p:b)}_unsubscribeHistory(){clearInterval(this._interval),this._subscribed&&(this._subscribed.then(t=>t?.()),this._subscribed=void 0)}updated(t){if(!this._config||!this.hass||!t.has("_config"))return;const i=t.get("_config");i&&this._subscribed&&i.entity===this._config.entity||(this._unsubscribeHistory(),this._subscribeHistory())}}g.styles=r.AH`:host{display:block}ha-spinner{position:absolute;top:calc(50% - 14px)}.container{display:flex;justify-content:center;position:relative;padding-bottom:20%}.info{position:absolute;top:calc(50% - 16px);color:var(--secondary-text-color)}`,(0,o.Cg)([(0,n.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)()],g.prototype,"type",void 0),(0,o.Cg)([(0,n.wk)()],g.prototype,"_config",void 0),(0,o.Cg)([(0,n.wk)()],g.prototype,"_coordinates",void 0),g=(0,o.Cg)([(0,n.EM)("hui-graph-header-footer")],g),e()}catch(t){e(t)}})}};
//# sourceMappingURL=33427.f7a846a95a00cab4.js.map