UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

2 lines 29 kB
/*! For license information please see 18377.bc13763625441467.js.LICENSE.txt */ export const __rspack_esm_id=18377;export const __rspack_esm_ids=[18377];export const __webpack_modules__={45100(e,t,i){i.a(e,async function(e,o){try{i.r(t),i.d(t,{HaIconButtonPrev:()=>g});var n=i(62826),a=i(5124),s=i(22441),r=i(63091),l=i(26300),c=e([l]);l=(c.then?(await c)():c)[0];const h="M15.41,16.58L10.83,12L15.41,7.41L14,6L8,12L14,18L15.41,16.58Z",d="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z";class g extends a.WF{render(){return a.qy` <ha-icon-button .disabled="${this.disabled}" .label="${this.label||this.hass?.localize("ui.common.back")||"Back"}" .path="${this._icon}" .href="${this.href}" .target="${this.target}" .rel="${this.rel}" .download="${this.download}"></ha-icon-button> `}constructor(...e){super(...e),this.disabled=!1,this._icon="rtl"===r.G.document.dir?d:h}}(0,n.Cg)([(0,s.MZ)({attribute:!1})],g.prototype,"hass",void 0),(0,n.Cg)([(0,s.MZ)({type:Boolean})],g.prototype,"disabled",void 0),(0,n.Cg)([(0,s.MZ)()],g.prototype,"label",void 0),(0,n.Cg)([(0,s.MZ)()],g.prototype,"href",void 0),(0,n.Cg)([(0,s.MZ)()],g.prototype,"target",void 0),(0,n.Cg)([(0,s.MZ)()],g.prototype,"rel",void 0),(0,n.Cg)([(0,s.MZ)()],g.prototype,"download",void 0),(0,n.Cg)([(0,s.wk)()],g.prototype,"_icon",void 0),g=(0,n.Cg)([(0,s.EM)("ha-icon-button-prev")],g),o()}catch(e){o(e)}})},85938(e,t,i){i(18111),i(22489),i(46058);var o=i(62826),n=i(5124),a=i(22441),s=i(1087);class r extends n.WF{updated(e){e.has("disabled")&&(this.disabled?this._destroySortable():this._createSortable())}disconnectedCallback(){super.disconnectedCallback(),this._shouldBeDestroy=!0,setTimeout(()=>{this._shouldBeDestroy&&(this._destroySortable(),this._shouldBeDestroy=!1)},1)}connectedCallback(){super.connectedCallback(),this._shouldBeDestroy=!1,this.hasUpdated&&!this.disabled&&this._createSortable()}createRenderRoot(){return this}render(){return this.noStyle?n.s6:n.qy` <style>.sortable-fallback{display:none!important}.sortable-ghost{box-shadow:0 0 0 2px var(--primary-color);background:rgba(var(--rgb-primary-color),.25);border-radius:var(--ha-border-radius-sm);opacity:.4}.sortable-drag{border-radius:var(--ha-border-radius-sm);opacity:1;background:var(--card-background-color);box-shadow:0px 4px 8px 3px #00000026;cursor:grabbing}</style> `}async _createSortable(){if(this._sortable)return;const e=this.children[0];if(!e)return;const t=(await Promise.all([i.e(85283),i.e(70322)]).then(i.bind(i,80745))).default,o={scroll:!0,forceAutoScrollFallback:!0,scrollSpeed:20,animation:150,...this.options,onChoose:this._handleChoose,onStart:this._handleStart,onEnd:this._handleEnd,onUpdate:this._handleUpdate,onAdd:this._handleAdd,onRemove:this._handleRemove};this.draggableSelector&&(o.draggable=this.draggableSelector),this.handleSelector&&(o.handle=this.handleSelector),void 0!==this.invertSwap&&(o.invertSwap=this.invertSwap),this.group&&(o.group=this.group),this.filter&&(o.filter=this.filter),this._sortable=new t(e,o)}_destroySortable(){this._sortable&&(this._sortable.destroy(),this._sortable=void 0)}constructor(...e){super(...e),this.disabled=!1,this.noStyle=!1,this.invertSwap=!1,this.rollback=!0,this._shouldBeDestroy=!1,this._handleUpdate=e=>{(0,s.r)(this,"item-moved",{newIndex:e.newIndex,oldIndex:e.oldIndex})},this._handleAdd=e=>{(0,s.r)(this,"item-added",{index:e.newIndex,data:e.item.sortableData,item:e.item})},this._handleRemove=e=>{(0,s.r)(this,"item-removed",{index:e.oldIndex})},this._handleEnd=async e=>{(0,s.r)(this,"drag-end"),this.rollback&&e.item.placeholder&&(e.item.placeholder.replaceWith(e.item),delete e.item.placeholder)},this._handleStart=()=>{(0,s.r)(this,"drag-start")},this._handleChoose=e=>{this.rollback&&(e.item.placeholder=document.createComment("sort-placeholder"),e.item.after(e.item.placeholder))}}}(0,o.Cg)([(0,a.MZ)({type:Boolean})],r.prototype,"disabled",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean,attribute:"no-style"})],r.prototype,"noStyle",void 0),(0,o.Cg)([(0,a.MZ)({type:String,attribute:"draggable-selector"})],r.prototype,"draggableSelector",void 0),(0,o.Cg)([(0,a.MZ)({type:String,attribute:"handle-selector"})],r.prototype,"handleSelector",void 0),(0,o.Cg)([(0,a.MZ)({type:String,attribute:"filter"})],r.prototype,"filter",void 0),(0,o.Cg)([(0,a.MZ)({type:String})],r.prototype,"group",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean,attribute:"invert-swap"})],r.prototype,"invertSwap",void 0),(0,o.Cg)([(0,a.MZ)({attribute:!1})],r.prototype,"options",void 0),(0,o.Cg)([(0,a.MZ)({type:Boolean})],r.prototype,"rollback",void 0),r=(0,o.Cg)([(0,a.EM)("ha-sortable")],r)},9169(e,t,i){i.d(t,{j:()=>o});const o=["relative","total","date","time","datetime"]},82743(e,t,i){i.a(e,async function(e,o){try{i.d(t,{j:()=>m});i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698);var n=i(98743),a=(i(16732),i(9578)),s=i(51007),r=i(37696),l=i(10792),c=i(14097),h=i(34128),d=e([n,a,s,r,l,c]);[n,a,s,r,l,c]=d.then?(await d)():d;const g=new Set(["conditional","icon","image","service-button","state-badge","state-icon","state-label"]),u={},m=e=>(0,h.gh)("action-button"===e?"service-button":e,"element",g,u);o()}catch(e){o(e)}})},98809(e,t,i){i.a(e,async function(e,t){try{i(74423),i(18111),i(22489),i(61701);var o=i(62826),n=i(5124),a=i(22441),s=i(22786),r=i(63533),l=i(1087),c=i(71727),h=i(52763),d=i(20507),g=e([h]);h=(g.then?(await g)():g)[0];const u={none:{},"entity-id":{},"last-changed":{},"last-updated":{},"last-triggered":{domains:["automation","script"]},area:{},position:{domains:["cover"]},state:{},"tilt-position":{domains:["cover"]},brightness:{domains:["light"]}};class m extends n.WF{setConfig(e){(0,r.vA)(e,d.l),this._config=e}render(){if(!this.hass||!this._config)return n.s6;const e=this.schema||this._schema(this._config.entity,this.hass.localize);return n.qy` <ha-form .hass="${this.hass}" .data="${this._config}" .schema="${e}" .computeLabel="${this._computeLabelCallback}" @value-changed="${this._valueChanged}"></ha-form> `}_valueChanged(e){(0,l.r)(this,"config-changed",{config:e.detail.value})}constructor(...e){super(...e),this._schema=(0,s.A)((e,t)=>{const i=(0,c.m)(e);return[{name:"entity",required:!0,selector:{entity:{}}},{name:"name",selector:{entity_name:{}},context:{entity:"entity"}},{name:"icon",selector:{icon:{}},context:{icon_entity:"entity"}},{name:"secondary_info",selector:{select:{options:Object.keys(u).filter(e=>!("domains"in u[e])||"domains"in u[e]&&u[e].domains.includes(i)).map(e=>({value:e,label:t(`ui.panel.lovelace.editor.card.entities.secondary_info_values.${e}`)}))}}}]}),this._computeLabelCallback=e=>"secondary_info"===e.name?this.hass.localize(`ui.panel.lovelace.editor.card.entity-row.${e.name}`):this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)}}(0,o.Cg)([(0,a.MZ)({attribute:!1})],m.prototype,"hass",void 0),(0,o.Cg)([(0,a.MZ)({attribute:!1})],m.prototype,"schema",void 0),(0,o.Cg)([(0,a.wk)()],m.prototype,"_config",void 0),m=(0,o.Cg)([(0,a.EM)("hui-generic-entity-row-editor")],m),t()}catch(e){t(e)}})},88528(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),n=i(22441),a=i(94225),s=i(63277),r=i(98809),l=e([r,s,a]);[r,s,a]=l.then?(await l)():l;const c="generic-row";class h extends s.U{get configElementType(){return!this.value?.type&&"entity"in this.value?c:"perform-action"===this.value?.type?"call-service":this.value?.type}async getConfigElement(){if(this.configElementType===c)return document.createElement("hui-generic-entity-row-editor");const e=await(0,a.t)(this.configElementType);return e&&e.getConfigElement?e.getConfigElement():void 0}}h=(0,o.Cg)([(0,n.EM)("hui-row-element-editor")],h),t()}catch(e){t(e)}})},10903(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),n=i(22441),a=i(13174),s=i(63277),r=e([s,a]);[s,a]=r.then?(await r)():r;class l extends s.U{async getConfigElement(){const e=await(0,a.h)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}async getConfigForm(){const e=await(0,a.h)(this.configElementType);if(e&&e.getConfigForm)return e.getConfigForm()}}l=(0,o.Cg)([(0,n.EM)("hui-card-feature-element-editor")],l),t()}catch(e){t(e)}})},48324(e,t,i){i.a(e,async function(e,o){try{i.d(t,{H:()=>s});var n=i(82743),a=e([n]);n=(a.then?(await a)():a)[0];const s=async(e,t,i,o)=>{let a={type:t};"conditional"===t?a={type:t,conditions:[],elements:[]}:a.style={left:"50%",top:"50%"};const s=await(0,n.j)(t);if(s&&s.getStubConfig){const t=await s.getStubConfig(e,i,o);a={...a,...t}}return a};o()}catch(e){o(e)}})},39039(e,t,i){i.d(t,{r:()=>o});class o extends Error{constructor(e,t,i){super(e),this.name="GUISupportError",this.warnings=t,this.errors=i}}},49288(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),n=i(22441),a=i(83938),s=i(63277),r=e([s]);s=(r.then?(await r)():r)[0];class l extends s.U{async getConfigElement(){const e=await(0,a.l)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}}l=(0,o.Cg)([(0,n.EM)("hui-headerfooter-element-editor")],l),t()}catch(e){t(e)}})},6870(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),n=i(22441),a=i(72669),s=i(63277),r=e([s,a]);[s,a]=r.then?(await r)():r;class l extends s.U{get configElementType(){return this.value?.type||"entity"}async getConfigElement(){const e=await(0,a.U)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}async getConfigForm(){const e=await(0,a.U)(this.configElementType);if(e&&e.getConfigForm)return e.getConfigForm()}}l=(0,o.Cg)([(0,n.EM)("hui-heading-badge-element-editor")],l),t()}catch(e){t(e)}})},91322(e,t,i){i.a(e,async function(e,o){try{i.d(t,{m:()=>f});i(18111),i(7588),i(61701);var n=i(62826),a=i(5124),s=i(22441),r=i(74985),l=i(1087),c=i(78978),h=i(19459),d=i(38962),g=i(65829),u=i(10763),m=i(39039),p=e([d,g,u]);[d,g,u]=p.then?(await p)():p;class f extends a.WF{get value(){return this._config}set value(e){this._config&&(0,h.b)(e,this._config,{compareSymbols:!0})||(this._config=e,this._errors=void 0,this._setConfig())}_setConfig(){if(!this._errors&&!this._yamlError)try{this._updateConfigElement()}catch(e){this._errors=[e.message]}this.updateComplete.then(()=>{(0,l.r)(this,"config-changed",{config:this.value,error:this._errors?.join(", "),guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})})}get hasWarning(){return void 0!==this._warnings&&this._warnings.length>0}get hasError(){return this._yamlError||void 0!==this._errors&&this._errors.length>0}get GUImode(){return this._guiMode}set GUImode(e){this._guiMode=e,this.updateComplete.then(()=>{(0,l.r)(this,"GUImode-changed",{guiMode:e,guiModeAvailable:!(this.hasWarning||this.hasError||!1===this._guiSupported)})})}toggleMode(){this.GUImode||this._yamlEditor?.disableCodeEditorFullscreen(),this.GUImode=!this.GUImode}focusYamlEditor(){this._configElement?.focusYamlEditor&&this._configElement.focusYamlEditor(),this._yamlEditor&&this._yamlEditor.focus()}async getConfigElement(){}async getConfigForm(){}renderConfigElement(){return a.qy`${this._configElement}`}_renderSubElement(){return a.qy` <hui-sub-element-editor .hass="${this.hass}" .config="${this._subElementEditorConfig}" @go-back="${this._goBack}" @config-changed="${this._subElementChanged}"> </hui-sub-element-editor> `}_subElementChanged(e){e.stopPropagation();const t=e.detail.config;this._subElementEditorConfig={...this._subElementEditorConfig,elementConfig:t},this._subElementEditorConfig.saveElementConfig?.(t)}_goBack(e){e.stopPropagation(),this._subElementEditorConfig=void 0}async _editSubElement(e){e.stopPropagation(),await Promise.all([i.e(92769),i.e(3283),i.e(80131),i.e(70183),i.e(67218),i.e(58416),i.e(99788),i.e(58303),i.e(21543),i.e(22398),i.e(46601),i.e(51455),i.e(26092),i.e(8851),i.e(59704),i.e(25322),i.e(90790),i.e(59532),i.e(55076),i.e(36332),i.e(77563),i.e(15862),i.e(99143),i.e(97500),i.e(12009),i.e(66990),i.e(20282),i.e(87857),i.e(92363),i.e(84240)]).then(i.bind(i,81287)),this._subElementEditorConfig={type:e.detail.type,elementConfig:e.detail.config,context:e.detail.context,saveElementConfig:e.detail.saveConfig}}render(){return a.qy` <div class="wrapper"> ${this.GUImode?a.qy` <div class="gui-editor" @edit-sub-element="${this._editSubElement}"> ${this._loading?a.qy` <ha-spinner class="center margin-bot"></ha-spinner> `:(0,r.P)(this._subElementEditorConfig?this._renderSubElement():this.renderConfigElement())} </div> `:a.qy` <div class="yaml-editor"> <ha-yaml-editor .defaultValue="${this._config}" autofocus .inDialog="${this.inDialog}" @value-changed="${this._handleYAMLChanged}" @keydown="${this._ignoreKeydown}" dir="ltr"></ha-yaml-editor> </div> `} ${!1===this._guiSupported&&!1===this._loading?a.qy` <ha-alert alert-type="info" .title="${this.hass.localize("ui.errors.config.visual_editor_not_supported")}"> ${this.hass.localize("ui.errors.config.visual_editor_not_supported_reason_type")} <br> ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} </ha-alert> `:a.s6} ${this._errors?.length?a.qy` <ha-alert alert-type="error" .title="${this.hass.localize("ui.errors.config.configuration_error")}"> <ul> ${this._errors.map(e=>a.qy`<li>${e}</li>`)} </ul> </ha-alert> `:a.s6} ${this.hasWarning?a.qy` <ha-alert alert-type="warning" .title="${this.hass.localize("ui.errors.config.visual_editor_not_supported")}"> <ul> ${this._warnings.map(e=>a.qy`<li>${e}</li>`)} </ul> ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} </ha-alert> `:a.s6} </div> `}updated(e){super.updated(e),this._configElement&&e.has("hass")&&(this._configElement.hass=this.hass),this._configElement&&"lovelace"in this._configElement&&e.has("lovelace")&&(this._configElement.lovelace=this.lovelace),this._configElement&&e.has("context")&&(this._configElement.context=this.context)}_handleUIConfigChanged(e){if(e.stopPropagation(),!this.GUImode)return;const t=e.detail.config;Object.keys(t).forEach(e=>{void 0===t[e]&&delete t[e]}),this.value=t}_handleYAMLChanged(e){e.stopPropagation(),e.detail.isValid?(this._config=e.detail.value,this._errors=void 0,this._yamlError=!1):this._yamlError=!0,this._setConfig()}async unloadConfigElement(){this._configElement=void 0,this._guiSupported=void 0}async loadConfigElement(){if(this._configElement)return;let e=await this.getConfigElement();if(!e){const t=await this.getConfigForm();if(t){await i.e(15106).then(i.bind(i,15737)),e=document.createElement("hui-form-editor");const{schema:o,assertConfig:n,computeLabel:a,computeHelper:s}=t;e.schema=o,a&&(e.computeLabel=a),s&&(e.computeHelper=s),n&&(e.assertConfig=n)}}e?(e.hass=this.hass,"lovelace"in e&&(e.lovelace=this.lovelace),e.context=this.context,e.addEventListener("config-changed",e=>this._handleUIConfigChanged(e)),this._guiSupported=!0):this._guiSupported=!1,this._configElement=e}async _updateConfigElement(){if(!this.value)return;const e=++this._loadCount;try{if(this._errors=void 0,this._warnings=void 0,await this.loadConfigElement(),this._configElement)try{this._configElement.setConfig(this.value)}catch(e){const t=(0,c._)(this.hass,e);throw new m.r("Config is not supported",t.warnings,t.errors)}else this._guiSupported=!1,this.GUImode=!1}catch(t){if(e!==this._loadCount)return;t instanceof m.r?(this._warnings=t.warnings??[t.message],this._errors=t.errors||void 0):this._errors=[t.message],this.GUImode=!1}finally{this._loading=!1}}_ignoreKeydown(e){e.stopPropagation()}constructor(...e){super(...e),this.inDialog=!1,this._guiMode=!0,this._loading=!1,this._yamlError=!1,this._loadCount=0}}f.styles=a.AH`:host{display:flex}.wrapper{width:100%}.gui-editor,.yaml-editor{padding:8px 0px}ha-code-editor{--code-mirror-max-height:calc(100vh - 245px)}ha-spinner{display:block;margin:auto}`,(0,n.Cg)([(0,s.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,n.Cg)([(0,s.MZ)({attribute:!1})],f.prototype,"lovelace",void 0),(0,n.Cg)([(0,s.MZ)({attribute:!1})],f.prototype,"context",void 0),(0,n.Cg)([(0,s.MZ)({type:Boolean,attribute:"in-dialog"})],f.prototype,"inDialog",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_config",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_configElement",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_subElementEditorConfig",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_guiMode",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_errors",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_warnings",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_guiSupported",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_loading",void 0),(0,n.Cg)([(0,s.wk)()],f.prototype,"_yamlError",void 0),(0,n.Cg)([(0,s.P)("ha-yaml-editor")],f.prototype,"_yamlEditor",void 0),o()}catch(e){o(e)}})},98161(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),n=i(22441),a=i(91322),s=e([a]);a=(s.then?(await s)():s)[0];class r extends a.m{async getConfigForm(){return this.form}updated(e){if(super.updated(e),e.has("form")&&this._configElement){const{schema:e,assertConfig:t,computeLabel:i,computeHelper:o}=this.form;this._configElement.schema=e,i&&(this._configElement.computeLabel=i),o&&(this._configElement.computeHelper=o),t&&(this._configElement.assertConfig=t)}}}(0,o.Cg)([(0,n.MZ)({attribute:!1})],r.prototype,"form",void 0),r=(0,o.Cg)([(0,n.EM)("hui-form-element-editor")],r),t()}catch(e){t(e)}})},37258(e,t,i){i.a(e,async function(e,t){try{i(18111),i(61701);var o=i(62826),n=i(34271),a=i(5124),s=i(22441),r=i(1087),l=i(18350),c=i(29823),h=(i(70947),i(26300)),d=(i(85938),i(67094),i(65063)),g=i(48324),u=e([l,c,h,g]);[l,c,h,g]=u.then?(await u)():u;const m="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",p="M11,17H4A2,2 0 0,1 2,15V3A2,2 0 0,1 4,1H16V3H4V15H11V13L15,16L11,19V17M19,21V7H8V13H6V7A2,2 0 0,1 8,5H19A2,2 0 0,1 21,7V21A2,2 0 0,1 19,23H8A2,2 0 0,1 6,21V19H8V21H19Z",f="M21 11H3V9H21V11M21 13H3V15H21V13Z",y="M20.71,7.04C21.1,6.65 21.1,6 20.71,5.63L18.37,3.29C18,2.9 17.35,2.9 16.96,3.29L15.12,5.12L18.87,8.87M3,17.25V21H6.75L17.81,9.93L14.06,6.18L3,17.25Z",_="M3 16H10V14H3M18 14V10H16V14H12V16H16V20H18V16H22V14M14 6H3V8H14M14 10H3V12H14V10Z",v=["state-badge","state-icon","state-label","action-button","icon","image","conditional"];class b extends a.WF{render(){return this.elements&&this.hass?a.qy` <h3> ${this.hass.localize("ui.panel.lovelace.editor.card.picture-elements.elements")} </h3> <div class="elements"> <ha-sortable handle-selector=".handle" @item-moved="${this._elementMoved}"> <div> ${this.elements.map((e,t)=>a.qy` <div class="element"> <div class="handle"> <ha-svg-icon .path="${f}"></ha-svg-icon> </div> ${e.type?a.qy` <div class="element-row"> <div> <span> ${this.hass?.localize(`ui.panel.lovelace.editor.card.picture-elements.element_types.${e.type}`)||e.type} </span> <span class="secondary">${this._getSecondaryDescription(e)}</span> </div> </div> `:a.s6} <ha-icon-button .label="${this.hass.localize("ui.common.delete")}" .path="${m}" class="remove-icon" .index="${t}" @click="${this._removeRow}"></ha-icon-button> <ha-icon-button .label="${this.hass.localize("ui.common.edit")}" .path="${y}" class="edit-icon" .index="${t}" @click="${this._editRow}"></ha-icon-button> <ha-icon-button .label="${this.hass.localize("ui.common.duplicate")}" .path="${p}" class="duplicate-icon" .index="${t}" @click="${this._duplicateRow}"></ha-icon-button> </div> `)} </div> </ha-sortable> <ha-dropdown @wa-select="${this._addElement}"> <ha-button size="small" slot="trigger" appearance="filled"> <ha-svg-icon slot="start" .path="${_}"></ha-svg-icon> ${this.hass.localize("ui.panel.lovelace.editor.card.picture-elements.new_element")} </ha-button> ${v.map(e=>a.qy` <ha-dropdown-item .value="${e}"> ${this.hass?.localize(`ui.panel.lovelace.editor.card.picture-elements.element_types.${e}`)||e} </ha-dropdown-item> `)} </ha-dropdown> </div> `:a.s6}_getSecondaryDescription(e){switch(e.type){case"icon":return e.title??e.icon??"";case"state-badge":case"state-icon":case"state-label":return e.title??e.entity??"";case"action-button":case"service-button":return e.title??e.action??e.service??"";case"image":{if(e.title)return e.title;const t=e;return t.image?"string"==typeof t.image?t.image:t.image.metadata?.title||t.image.media_content_id||"":t.camera_image||""}case"conditional":return e.title??`${(e.elements||[]).length.toString()} ${this.hass?.localize("ui.panel.lovelace.editor.card.picture-elements.elements")}`}return e.title??"Unknown type"}async _addElement(e){const t=e.detail.item.value;if(""===t)return;const i=this.elements.concat(await(0,g.H)(this.hass,t,Object.keys(this.hass.entities),[]));(0,r.r)(this,"elements-changed",{elements:i})}_elementMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,o=this.elements.concat();o.splice(i,0,o.splice(t,1)[0]),(0,r.r)(this,"elements-changed",{elements:o})}_removeRow(e){const t=e.currentTarget.index,i=this.elements?.[t];i&&(0,d.dk)(this,{text:this.hass.localize("ui.panel.lovelace.editor.card.picture-elements.confirm_delete_element",{type:this.hass.localize(`ui.panel.lovelace.editor.card.picture-elements.element_types.${i.type}`)||i.type}),confirmText:this.hass.localize("ui.common.delete"),destructive:!0,confirm:()=>{const e=this.elements.concat();e.splice(t,1),(0,r.r)(this,"elements-changed",{elements:e})}})}_editRow(e){const t=e.currentTarget.index;(0,r.r)(this,"edit-detail-element",{subElementConfig:{index:t,type:"element",elementConfig:this.elements[t]}})}_duplicateRow(e){const t=e.currentTarget.index,i=[...this.elements,(0,n.A)(this.elements[t])];(0,r.r)(this,"elements-changed",{elements:i})}}b.styles=a.AH`.element{display:flex;align-items:center}.handle{padding-right:var(--ha-space-2);cursor:move;cursor:grab;padding-inline-end:var(--ha-space-2);padding-inline-start:initial;direction:var(--direction)}.handle>*{pointer-events:none}.element-row{height:60px;font-size:var(--ha-font-size-l);display:flex;align-items:center;justify-content:space-between;flex-grow:1}.element-row div{display:flex;flex-direction:column}.duplicate-icon,.edit-icon,.remove-icon{--ha-icon-button-size:36px;color:var(--secondary-text-color)}.secondary{font-size:var(--ha-font-size-s);color:var(--secondary-text-color)}`,(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"hass",void 0),(0,o.Cg)([(0,s.MZ)({attribute:!1})],b.prototype,"elements",void 0),b=(0,o.Cg)([(0,s.EM)("hui-picture-elements-card-row-editor")],b),t()}catch(e){t(e)}})},81287(e,t,i){i.a(e,async function(e,o){try{i.r(t),i.d(t,{HuiSubElementEditor:()=>v});var n=i(62826),a=i(5124),s=i(22441),r=i(1087),l=i(26300),c=i(45100),h=i(88528),d=i(10903),g=i(49288),u=i(6870),m=i(98161),p=i(3548),f=e([l,c,h,d,g,u,m,p]);[l,c,h,d,g,u,m,p]=f.then?(await f)():f;const y="M8,3A2,2 0 0,0 6,5V9A2,2 0 0,1 4,11H3V13H4A2,2 0 0,1 6,15V19A2,2 0 0,0 8,21H10V19H8V14A2,2 0 0,0 6,12A2,2 0 0,0 8,10V5H10V3M16,3A2,2 0 0,1 18,5V9A2,2 0 0,0 20,11H21V13H20A2,2 0 0,0 18,15V19A2,2 0 0,1 16,21H14V19H16V14A2,2 0 0,1 18,12A2,2 0 0,1 16,10V5H14V3H16Z",_="M11 15H17V17H11V15M9 7H7V9H9V7M11 13H17V11H11V13M11 9H17V7H11V9M9 11H7V13H9V11M21 5V19C21 20.1 20.1 21 19 21H5C3.9 21 3 20.1 3 19V5C3 3.9 3.9 3 5 3H19C20.1 3 21 3.9 21 5M19 5H5V19H19V5M9 15H7V17H9V15Z";class v extends a.WF{render(){const e=this.config.elementConfig&&"type"in this.config.elementConfig?this.config.elementConfig.type:"";return a.qy` <div class="header"> <div class="back-title"> <ha-icon-button-prev .label="${this.hass.localize("ui.common.back")}" @click="${this._goBack}"></ha-icon-button-prev> <span slot="title"> ${"element"===this.config?.type?this.hass.localize("ui.panel.lovelace.editor.sub-element-editor.types.element_type",{type:this.hass.localize(`ui.panel.lovelace.editor.card.picture-elements.element_types.${e}`)||e}):this.hass.localize(`ui.panel.lovelace.editor.sub-element-editor.types.${this.config?.type}`)} </span> </div> <ha-icon-button class="gui-mode-button" @click="${this._toggleMode}" .disabled="${!this._guiModeAvailable}" .label="${this.hass.localize(this._guiMode?"ui.panel.lovelace.editor.edit_card.show_code_editor":"ui.panel.lovelace.editor.edit_card.show_visual_editor")}" .path="${this._guiMode?y:_}"></ha-icon-button> </div> ${this._renderEditor()} `}_renderEditor(){const e=this.config.type;if(this.form)return a.qy` <hui-form-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .form="${this.form}" .context="${this.config.context}" @config-changed="${this._handleConfigChanged}"></hui-form-element-editor> `;switch(e){case"row":return a.qy` <hui-row-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" @config-changed="${this._handleConfigChanged}" @GUImode-changed="${this._handleGUIModeChanged}"></hui-row-element-editor> `;case"header":case"footer":return a.qy` <hui-headerfooter-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" @config-changed="${this._handleConfigChanged}" @GUImode-changed="${this._handleGUIModeChanged}"></hui-headerfooter-element-editor> `;case"element":return a.qy` <hui-picture-element-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" @config-changed="${this._handleConfigChanged}" @GUImode-changed="${this._handleGUIModeChanged}"></hui-picture-element-element-editor> `;case"feature":return a.qy` <hui-card-feature-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" @config-changed="${this._handleConfigChanged}" @GUImode-changed="${this._handleGUIModeChanged}"></hui-card-feature-element-editor> `;case"heading-badge":return a.qy` <hui-heading-badge-element-editor class="editor" .hass="${this.hass}" .value="${this.config.elementConfig}" .context="${this.config.context}" @config-changed="${this._handleConfigChanged}" @GUImode-changed="${this._handleGUIModeChanged}"></hui-heading-badge-element-editor> `;default:return a.s6}}_goBack(){(0,r.r)(this,"go-back")}_toggleMode(){this._editorElement?.toggleMode()}_handleGUIModeChanged(e){e.stopPropagation(),this._guiMode=e.detail.guiMode,this._guiModeAvailable=e.detail.guiModeAvailable}_handleConfigChanged(e){this._guiModeAvailable=e.detail.guiModeAvailable}constructor(...e){super(...e),this._guiModeAvailable=!0,this._guiMode=!0}}v.styles=a.AH`.header{display:flex;justify-content:space-between;align-items:center}.back-title{display:flex;align-items:center;font-size:var(--ha-font-size-l)}`,(0,n.Cg)([(0,s.MZ)({attribute:!1})],v.prototype,"config",void 0),(0,n.Cg)([(0,s.MZ)({attribute:!1})],v.prototype,"form",void 0),(0,n.Cg)([(0,s.wk)()],v.prototype,"_guiModeAvailable",void 0),(0,n.Cg)([(0,s.wk)()],v.prototype,"_guiMode",void 0),(0,n.Cg)([(0,s.P)(".editor")],v.prototype,"_editorElement",void 0),v=(0,n.Cg)([(0,s.EM)("hui-sub-element-editor")],v),o()}catch(e){o(e)}})},63277(e,t,i){i.a(e,async function(e,o){try{i.d(t,{U:()=>l});var n=i(62826),a=i(22441),s=i(91322),r=e([s]);s=(r.then?(await r)():r)[0];class l extends s.m{get configElementType(){return this.value?this.value.type:void 0}async loadConfigElement(){if(this._configElementType!==this.configElementType){if(this.unloadConfigElement(),!this.configElementType)throw new Error(this.hass.localize("ui.errors.config.no_type_provided"));this._configElementType=this.configElementType}return super.loadConfigElement()}}(0,n.Cg)([(0,a.wk)()],l.prototype,"_configElementType",void 0),o()}catch(e){o(e)}})},3548(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),n=i(22441),a=i(63277),s=i(82743),r=e([a,s]);[a,s]=r.then?(await r)():r;class l extends a.U{get configElementType(){return"action-button"===this.value?.type?"service-button":this.value?.type}async getConfigElement(){const e=await(0,s.j)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}}l=(0,o.Cg)([(0,n.EM)("hui-picture-element-element-editor")],l),t()}catch(e){t(e)}})},20507(e,t,i){i.d(t,{l:()=>r,z:()=>l});var o=i(63533),n=i(9169),a=i(91408),s=i(44155);const r=(0,o.KC)([(0,o.Ik)({entity:(0,o.Yj)(),name:(0,o.lq)(s.q),icon:(0,o.lq)((0,o.Yj)()),image:(0,o.lq)((0,o.Yj)()),secondary_info:(0,o.lq)((0,o.Yj)()),format:(0,o.lq)((0,o.vP)(n.j)),state_color:(0,o.lq)((0,o.zM)()),tap_action:(0,o.lq)(a.kn),hold_action:(0,o.lq)(a.kn),double_tap_action:(0,o.lq)(a.kn),confirmation:(0,o.lq)(a.dk),show_last_changed:(0,o.lq)((0,o.zM)()),show_state:(0,o.lq)((0,o.zM)())}),(0,o.Yj)()]),l=(0,o.KC)([(0,o.Ik)({entity:(0,o.Yj)(),name:(0,o.lq)(s.q),color:(0,o.lq)((0,o.Yj)())}),(0,o.Yj)()])},74985(e,t,i){i.d(t,{P:()=>r});i(88454),i(29452);var o=i(5055),n=i(42017),a=i(63937);const s=e=>(0,a.ps)(e)?e._$litType$.h:e.strings,r=(0,n.u$)(class extends n.WL{render(e){return[e]}update(e,[t]){const i=(0,a.qb)(this.it)?s(this.it):null,n=(0,a.qb)(t)?s(t):null;if(null!==i&&(null===n||i!==n)){const t=(0,a.cN)(e).pop();let n=this.et.get(i);if(void 0===n){const e=document.createDocumentFragment();n=(0,o.XX)(o.s6,e),n.setConnected(!1),this.et.set(i,n)}(0,a.mY)(n,[t]),(0,a.Dx)(n,void 0,t)}if(null!==n){if(null===i||i!==n){const t=this.et.get(n);if(void 0!==t){const i=(0,a.cN)(t).pop();(0,a.Jz)(e),(0,a.Dx)(e,void 0,i),(0,a.mY)(e,[i])}}this.it=t}else this.it=void 0;return this.render(t)}constructor(e){super(e),this.et=new WeakMap}})}};