"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["33427"],{67806:function(t,i,e){e.a(t,async function(t,n){try{e.r(i),e.d(i,{HuiGraphHeaderFooter:function(){return q}});var s,o,r,a,c,u=e(61397),h=e(50264),d=e(7739),l=e(72153),_=e(44734),f=e(43080),b=e(69683),v=e(25460),y=e(6454),p=(e(16280),e(74423),e(23792),e(2892),e(69085),e(26099),e(3362),e(47764),e(62953),e(40445)),g=e(96196),m=e(77845),k=e(36312),w=e(71727),A=e(65829),C=e(25064),x=e(13632),H=e(18721),M=(e(46658),t([A,C]));[A,C]=M.then?(await M)():M;var N=["counter","input_number","number","sensor"],q=function(t){function i(){return(0,_.A)(this,i),(0,b.A)(this,i,arguments)}return(0,y.A)(i,t),(0,f.A)(i,[{key:"getCardSize",value:function(){return 3}},{key:"setConfig",value:function(t){if(null==t||!t.entity||!N.includes((0,w.m)(t.entity)))throw new Error("Specify an entity from within the sensor domain");var i=Object.assign({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}},{key:"render",value:function(){return this._config&&this.hass?this._error?(0,g.qy)(s||(s=(0,l.A)(['<div class="errors">',"</div>"])),this._error):this._coordinates?this._coordinates.length?(0,g.qy)(a||(a=(0,l.A)([' <hui-graph-base .coordinates="','"></hui-graph-base> '])),this._coordinates):(0,g.qy)(r||(r=(0,l.A)([' <div class="container"> <div class="info">No state history found.</div> </div> ']))):(0,g.qy)(o||(o=(0,l.A)([' <div class="container"> <ha-spinner size="small"></ha-spinner> </div> ']))):g.s6}},{key:"connectedCallback",value:function(){(0,v.A)(i,"connectedCallback",this,3)([]),this.hasUpdated&&this._config&&this._subscribeHistory()}},{key:"disconnectedCallback",value:function(){(0,v.A)(i,"disconnectedCallback",this,3)([]),this._unsubscribeHistory()}},{key:"_subscribeHistory",value:function(){var t=this;(0,k.x)(this.hass,"history")&&!this._subscribed&&this._config&&(this._subscribed=(0,C.IQ)(this.hass,function(i){var e,n;if(t._subscribed&&t._config){var s=t.clientWidth||t.offsetWidth,o=Math.max(10,t._config.detail>1?Math.max(s/5,t._config.hours_to_show):t._config.hours_to_show),r=2!==t._config.detail,a=(0,H.a)(i[t._config.entity],s,s/5,o,{minY:null===(e=t._config.limits)||void 0===e?void 0:e.min,maxY:null===(n=t._config.limits)||void 0===n?void 0:n.max},r).points;t._coordinates=a}},this._config.hours_to_show,[this._config.entity]).catch(function(i){t._subscribed=void 0,t._error=i}),this._setRedrawTimer())}},{key:"_redrawGraph",value:function(){this._coordinates&&(this._coordinates=(0,d.A)(this._coordinates))}},{key:"_setRedrawTimer",value:function(){var t=this;clearInterval(this._interval),this._interval=window.setInterval(function(){return t._redrawGraph()},this._config.hours_to_show>24?36e5:6e4)}},{key:"_unsubscribeHistory",value:function(){clearInterval(this._interval),this._subscribed&&(this._subscribed.then(function(t){return null==t?void 0:t()}),this._subscribed=void 0)}},{key:"updated",value:function(t){if(this._config&&this.hass&&t.has("_config")){var i=t.get("_config");i&&this._subscribed&&i.entity===this._config.entity||(this._unsubscribeHistory(),this._subscribeHistory())}}}],[{key:"getConfigElement",value:(n=(0,h.A)((0,u.A)().m(function t(){return(0,u.A)().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,Promise.all([e.e("44533"),e.e("92769"),e.e("44966"),e.e("52242"),e.e("15069"),e.e("7592"),e.e("39005"),e.e("44838"),e.e("51704")]).then(e.bind(e,87031));case 1:return t.a(2,document.createElement("hui-graph-footer-editor"))}},t)})),function(){return n.apply(this,arguments)})},{key:"getStubConfig",value:function(t,i,e){return{type:"graph",entity:(0,x.B)(t,1,i,e,N,function(t){return!isNaN(Number(t.state))&&!!t.attributes.unit_of_measurement})[0]||""}}}]);var n}(g.WF);q.styles=(0,g.AH)(c||(c=(0,l.A)([":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,p.Cg)([(0,m.MZ)({attribute:!1})],q.prototype,"hass",void 0),(0,p.Cg)([(0,m.MZ)()],q.prototype,"type",void 0),(0,p.Cg)([(0,m.wk)()],q.prototype,"_config",void 0),(0,p.Cg)([(0,m.wk)()],q.prototype,"_coordinates",void 0),q=(0,p.Cg)([(0,m.EM)("hui-graph-header-footer")],q),n()}catch(E){n(E)}})}}]);
//# sourceMappingURL=33427.870b00890a767d0e.js.map