export const __rspack_esm_id="99104";export const __rspack_esm_ids=["99104"];export const __webpack_modules__={6275(t,e,i){i.a(t,async function(t,s){try{i.r(e),i.d(e,{HuiEntityFilterCard:()=>_});i(18111),i(81148),i(22489),i(61701),i(13579);var r=i(62826),n=i(96196),o=i(97735),a=i(1087),h=i(33121),c=i(68289),l=i(13632),d=i(20939),f=i(14487),u=t([f]);f=(u.then?(await u)():u)[0];class _ extends n.mN{static getStubConfig(t,e,i){const s=(0,l.B)(t,3,e,i,["light","switch","sensor"]);return{type:"entity-filter",entities:s,conditions:s[0]?[{condition:"state",state:t.states[s[0]].state}]:[],card:{type:"entities"}}}getCardSize(){return this._element?(0,h.Z)(this._element):1}setConfig(t){if(!t.entities||!t.entities.length||!Array.isArray(t.entities))throw new Error("Entities must be specified");if(!t.conditions&&!t.state_filter&&!t.entities.some(t=>"object"==typeof t&&(t.state_filter||t.conditions)))throw new Error("At least one conditions or state_filter is required");if(t.conditions&&!Array.isArray(t.conditions)||t.state_filter&&!Array.isArray(t.state_filter)||t.entities.some(t=>"object"==typeof t&&(t.state_filter&&!Array.isArray(t.state_filter)||t.conditions&&!Array.isArray(t.conditions))))throw new Error("Conditions or state_filter must be an array");if(t.conditions&&t.state_filter||t.entities.some(t=>"object"==typeof t&&t.state_filter&&t.conditions))throw new Error("Conditions and state_filter may not be simultaneously defined");this._configEntities=(0,d.L)(t.entities),this._config=t,this._baseCardConfig={type:"entities",entities:[],...this._config.card},this.lastChild&&this.removeChild(this.lastChild),this._element=this._createCardElement(this._baseCardConfig)}createRenderRoot(){return this}shouldUpdate(t){return this._element&&(this._element.hass=this.hass,this._element.preview=this.preview,this._element.layout=this.layout),!(!t.has("_config")&&!t.has("preview"))||!!t.has("hass")&&this._haveEntitiesChanged(t.get("hass"))}update(t){if(super.update(t),!(this.hass&&this._config&&this._configEntities&&this._element))return;const e=this._configEntities.filter(t=>{const e=this.hass.states[t.entity];if(!e)return!1;const i=t.conditions??this._config.conditions;if(i&&!t.state_filter){const e=i.map(e=>(0,f.lB)(e,t.entity));return(0,f.XH)(e,this.hass)}const s=t.state_filter??this._config.state_filter;return!s||s.some(t=>(0,c.J)(e,t))});if(0!==e.length||!1!==this._config.show_empty||this.preview){if(this.lastChild){this._oldEntities&&e.length===this._oldEntities.length&&e.every((t,e)=>t===this._oldEntities[e])||(this._oldEntities=e,this._element.config={...this._baseCardConfig,entities:e})}else this._element.config={...this._baseCardConfig,entities:e},this._oldEntities=e;this.lastChild||this.appendChild(this._element),this.hidden&&(this.style.display="block",this.toggleAttribute("hidden",!1),(0,a.r)(this,"card-visibility-changed",{value:!0}))}else this.hidden||(this.style.display="none",this.toggleAttribute("hidden",!0),(0,a.r)(this,"card-visibility-changed",{value:!1}))}_haveEntitiesChanged(t){if(!this.hass||!t)return!0;if(!this._configEntities)return!0;if(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;if(e.conditions){const i=(0,f.Wx)(e.conditions);for(const e of i)if(this.hass.states[e]!==t.states[e])return!0}}if(this._config?.conditions){const e=(0,f.Wx)(this._config?.conditions);for(const i of e)if(this.hass.states[i]!==t.states[i])return!0}return!1}_createCardElement(t){const e=document.createElement("hui-card");return e.hass=this.hass,e.preview=this.preview,e.config=t,e.load(),e}constructor(...t){super(...t),this.preview=!1}}(0,r.Cg)([(0,o.MZ)({attribute:!1})],_.prototype,"hass",void 0),(0,r.Cg)([(0,o.MZ)({attribute:!1})],_.prototype,"layout",void 0),(0,r.Cg)([(0,o.MZ)({type:Boolean})],_.prototype,"preview",void 0),(0,r.Cg)([(0,o.wk)()],_.prototype,"_config",void 0),_=(0,r.Cg)([(0,o.EM)("hui-entity-filter-card")],_),s()}catch(t){s(t)}})},68289(t,e,i){i.d(e,{J:()=>s});i(18111),i(61701),i(33110);const s=(t,e)=>{let i,s,r;if("object"==typeof e?(i=e.operator,s=e.value,r=e.attribute?t.attributes[e.attribute]:t.state):(i="==",s=e,r=t.state),"=="===i||"!="===i){const t="number"==typeof s||"string"==typeof s&&s.trim()&&!isNaN(Number(s)),e="number"==typeof r||"string"==typeof r&&r.trim()&&!isNaN(Number(r));t&&e&&(s=Number(s),r=Number(r))}switch(i){case"==":return r===s;case"<=":return r<=s;case"<":return r<s;case">=":return r>=s;case">":return r>s;case"!=":return r!==s;case"in":return!(!Array.isArray(s)&&"string"!=typeof s)&&(Array.isArray(s)&&(s=s.map(t=>`${t}`)),s.includes(r));case"not in":return!(!Array.isArray(s)&&"string"!=typeof s)&&(Array.isArray(s)&&(s=s.map(t=>`${t}`)),!s.includes(r));case"regex":return"string"==typeof s&&(null!==r&&"object"==typeof r?RegExp(s).test(JSON.stringify(r)):RegExp(s).test(r));default:return!1}}}};
//# sourceMappingURL=99104.adef807f13d7db06.js.map