(self.webpackJsonp=self.webpackJsonp||[]).push([[212],{504:function(t,e,i){"use strict";i.d(e,"a",function(){return s});const s=(t,e)=>{const i=e.operator||"==",s=e.value||e,n=e.attribute?t.attributes[e.attribute]:t.state;switch(i){case"==":return n===s;case"<=":return n<=s;case"<":return n<s;case">=":return n>=s;case">":return n>s;case"!=":return n!==s;case"regex":return n.match(s);default:return!1}}},848:function(t,e,i){"use strict";i.r(e);var s=i(504),n=i(305),r=i(433);function o(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}customElements.define("hui-entity-filter-badge",class extends HTMLElement{constructor(...t){super(...t),o(this,"_elements",void 0),o(this,"_config",void 0),o(this,"_configEntities",void 0),o(this,"_hass",void 0),o(this,"_oldEntities",void 0)}setConfig(t){if(!t.entities||!Array.isArray(t.entities))throw new Error("entities must be specified.");if(!(t.state_filter&&Array.isArray(t.state_filter)||t.entities.every(t=>"object"==typeof t&&t.state_filter&&Array.isArray(t.state_filter))))throw new Error("Incorrect filter config.");this._config=t,this._configEntities=void 0,this.lastChild&&(this.removeChild(this.lastChild),this._elements=void 0)}set hass(t){if(!t||!this._config)return;if(this._elements)for(const i of this._elements)i.hass=t;if(!this.haveEntitiesChanged(t))return void(this._hass=t);this._hass=t,this._configEntities||(this._configEntities=Object(n.a)(this._config.entities));const e=this._configEntities.filter(e=>{const i=t.states[e.entity];if(!i)return!1;if(e.state_filter){for(const t of e.state_filter)if(Object(s.a)(i,t))return!0}else for(const t of this._config.state_filter)if(Object(s.a)(i,t))return!0;return!1});if(0!==e.length){if(!this._oldEntities||e.length!==this._oldEntities.length||!e.every((t,e)=>t===this._oldEntities[e])){this._elements=[];for(const i of e){const e=Object(r.a)(i);e.hass=t,this._elements.push(e)}this._oldEntities=e}if(this._elements){for(;this.lastChild;)this.removeChild(this.lastChild);for(const t of this._elements)this.appendChild(t);this.style.display="inline"}}else this.style.display="none"}haveEntitiesChanged(t){if(!this._hass)return!0;if(!this._configEntities||this._hass.localize!==t.localize)return!0;for(const e of this._configEntities)if(this._hass.states[e.entity]!==t.states[e.entity])return!0;return!1}})}}]);
//# sourceMappingURL=chunk.a7421453c219a869e323.js.map