"use strict";(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([["74981"],{98852:function(e,t,i){i.a(e,async function(e,n){try{i.r(t),i.d(t,{HuiConditionalElementEditor:function(){return k}});var o,s,a=i(72153),c=i(44734),l=i(43080),h=i(69683),d=i(6454),g=(i(28706),i(54554),i(69085),i(40445)),r=i(96196),u=i(77845),f=i(63533),m=i(1087),_=(i(52763),i(13898)),v=i(37258),b=i(81287),C=e([_,v,b]);[_,v,b]=C.then?(await C)():C;var E=(0,f.Ik)({type:(0,f.eu)("conditional"),conditions:(0,f.lq)((0,f.YO)((0,f.bz)())),elements:(0,f.lq)((0,f.YO)((0,f.bz)())),title:(0,f.lq)((0,f.Yj)())}),p=[{name:"title",selector:{text:{}}}],k=function(e){function t(){var e;(0,c.A)(this,t);for(var i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return(e=(0,h.A)(this,t,[].concat(n)))._computeLabelCallback=function(t){return e.hass.localize("ui.panel.lovelace.editor.card.generic.".concat(t.name))||e.hass.localize("ui.panel.lovelace.editor.elements.".concat(t.name))||t.name},e}return(0,d.A)(t,e),(0,l.A)(t,[{key:"setConfig",value:function(e){(0,f.vA)(e,E),this._config=e}},{key:"render",value:function(){return this.hass&&this._config?this._subElementEditorConfig?(0,r.qy)(o||(o=(0,a.A)([' <hui-sub-element-editor .hass="','" .config="','" @go-back="','" @config-changed="','"> </hui-sub-element-editor> '])),this.hass,this._subElementEditorConfig,this._goBack,this._handleSubElementChanged):(0,r.qy)(s||(s=(0,a.A)([' <ha-form .hass="','" .data="','" .schema="','" .computeLabel="','" @value-changed="','"></ha-form> <ha-card-conditions-editor .hass="','" .conditions="','" @value-changed="','"> </ha-card-conditions-editor> <hui-picture-elements-card-row-editor .hass="','" .elements="','" @elements-changed="','" @edit-detail-element="','"></hui-picture-elements-card-row-editor> '])),this.hass,this._config,p,this._computeLabelCallback,this._formChanged,this.hass,this._config.conditions||[],this._conditionChanged,this.hass,this._config.elements||[],this._elementsChanged,this._editDetailElement):r.s6}},{key:"_formChanged",value:function(e){(0,m.r)(this,"config-changed",{config:e.detail.value})}},{key:"_conditionChanged",value:function(e){if(e.stopPropagation(),this._config){var t=e.detail.value;this._config=Object.assign(Object.assign({},this._config),{},{conditions:t}),(0,m.r)(this,"config-changed",{config:this._config})}}},{key:"_elementsChanged",value:function(e){var t,i;e.stopPropagation();var n=(null===(t=this._config)||void 0===t||null===(t=t.elements)||void 0===t?void 0:t.length)||0,o=Object.assign(Object.assign({},this._config),{},{elements:e.detail.elements});(0,m.r)(this,"config-changed",{config:o});var s=(null===(i=e.detail.elements)||void 0===i?void 0:i.length)||0;if(s===n+1){var a=s-1;this._subElementEditorConfig={index:a,type:"element",elementConfig:Object.assign({},e.detail.elements[a])}}}},{key:"_handleSubElementChanged",value:function(e){var t;if(e.stopPropagation(),this._config&&this.hass){var i=null===(t=this._subElementEditorConfig)||void 0===t?void 0:t.type,n=e.detail.config;if("element"===i){var o=this._config.elements.concat();n?o[this._subElementEditorConfig.index]=n:(o.splice(this._subElementEditorConfig.index,1),this._goBack()),this._config=Object.assign(Object.assign({},this._config),{},{elements:o})}this._subElementEditorConfig=Object.assign(Object.assign({},this._subElementEditorConfig),{},{elementConfig:n}),(0,m.r)(this,"config-changed",{config:this._config})}}},{key:"_editDetailElement",value:function(e){this._subElementEditorConfig=e.detail.subElementConfig}},{key:"_goBack",value:function(e){null==e||e.stopPropagation(),this._subElementEditorConfig=void 0}}])}(r.WF);(0,g.Cg)([(0,u.MZ)({attribute:!1})],k.prototype,"hass",void 0),(0,g.Cg)([(0,u.wk)()],k.prototype,"_config",void 0),(0,g.Cg)([(0,u.wk)()],k.prototype,"_subElementEditorConfig",void 0),k=(0,g.Cg)([(0,u.EM)("hui-conditional-element-editor")],k),n()}catch(y){n(y)}})}}]);
//# sourceMappingURL=74981.39d7d30eb348725d.js.map