iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
8 lines • 29.6 kB
JavaScript
/*! For license information please see 21780.3c82102244e4d5e7.js.LICENSE.txt */
export const __rspack_esm_id=21780;export const __rspack_esm_ids=[21780];export const __webpack_modules__={34370(e,t,i){i(18111),i(7588),e.exports=function e(t){return Object.freeze(t),Object.getOwnPropertyNames(t).forEach(function(i){!t.hasOwnProperty(i)||null===t[i]||"object"!=typeof t[i]&&"function"!=typeof t[i]||Object.isFrozen(t[i])||e(t[i])}),t}},62647(e,t,i){var o=i(62826),a=i(9866),s=i(5124),n=i(22441);class r extends a.A{static get styles(){return[a.A.styles,s.AH`:host{font-size:var(--ha-font-size-m);--wa-color-brand-on-quiet:var(
--ha-tab-active-text-color,
var(--primary-color)
);--wa-color-neutral-on-quiet:var(--wa-color-brand-on-quiet);opacity:.8;color:inherit;--wa-space-l:16px}:host([active]:not([disabled])){opacity:1} (hover:hover){:host(:hover:not([disabled]):not([active])) .tab{color:var(--wa-color-brand-on-quiet)}}`]}}r=(0,o.Cg)([(0,n.EM)("ha-tab-group-tab")],r)},66289(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),a=i(42814),s=i(5124),n=i(22441),r=i(36356),l=e([a]);a=(l.then?(await l)():l)[0];class d extends a.A{connectedCallback(){super.connectedCallback(),this.addEventListener("keydown",this._handleKeyDown,!0)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("keydown",this._handleKeyDown,!0)}handleClick(e){this._dragScrollController.scrolled||super.handleClick(e)}static get styles(){return[a.A.styles,s.AH`:host{--track-width:2px;--track-color:var(--ha-tab-track-color, var(--divider-color));--indicator-color:var(
--ha-tab-indicator-color,
var(--primary-color)
);--wa-color-neutral-on-quiet:var(--indicator-color)}.tab-group-top ::slotted(ha-tab-group-tab[active]){border-block-end:solid var(--track-width) var(--indicator-color);margin-block-end:calc(-1 * var(--track-width))}.tab-group-start ::slotted(ha-tab-group-tab[active]){border-inline-end:solid var(--track-width) var(--indicator-color);margin-inline-end:calc(-1 * var(--track-width))}.tab-group-end ::slotted(ha-tab-group-tab[active]){border-inline-start:solid var(--track-width) var(--indicator-color);margin-inline-start:calc(-1 * var(--track-width))}.scroll-button::part(base):hover{background-color:transparent}`]}constructor(...e){super(...e),this._dragScrollController=new r.q(this,{selector:".nav"}),this.tabTag="ha-tab-group-tab",this.tabOnly=!0,this._handleKeyDown=e=>{(e.altKey||e.metaKey)&&e.stopPropagation()}}}(0,o.Cg)([(0,n.MZ)({attribute:"tab-tag"})],d.prototype,"tabTag",void 0),(0,o.Cg)([(0,n.MZ)({attribute:"tab-only",type:Boolean})],d.prototype,"tabOnly",void 0),d=(0,o.Cg)([(0,n.EM)("ha-tab-group")],d),t()}catch(e){t(e)}})},83892(e,t,i){i.d(t,{x:()=>r});i(18111),i(13579);var o=i(62826),a=i(92070),s=i(5124),n=i(22441);class r extends s.WF{_onSlotChange(e){return t=>{const i=t.target.assignedNodes({flatten:!0}).some(e=>e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&""!==e.textContent?.trim());"start"===e?this._hasStart=i:this._hasEnd=i}}render(){return this._renderBase(this._renderInner())}_renderBase(e){return s.qy`<div part="base" class="base" id="item">${e}</div>`}_renderInner(){const e=this._slotController.test("content");return s.qy` <div part="start" class="start" ?hidden="${!this._hasStart}"> <slot name="start" ="${this._onSlotChange("start")}"></slot> </div> <div part="content" class="content"> ${e?s.qy`<slot name="content"></slot>`:this._renderDefaultContent()} </div> <div part="end" class="end" ?hidden="${!this._hasEnd}"> <slot name="end" ="${this._onSlotChange("end")}"></slot> </div> `}_renderDefaultContent(){const e=this._slotController.test("headline"),t=this._slotController.test("supporting-text"),i=e||void 0!==this.headline,o=t||void 0!==this.supportingText;return s.qy` ${i?s.qy`<div part="headline" class="headline"> <slot name="headline">${this.headline??s.s6}</slot> </div>`:s.s6} ${o?s.qy`<div part="supporting-text" class="supporting"> <slot name="supporting-text">${this.supportingText??s.s6}</slot> </div>`:s.s6} `}constructor(...e){super(...e),this.disabled=!1,this._slotController=new a.X(this,"headline","supporting-text","content"),this._hasStart=!1,this._hasEnd=!1}}r.styles=s.AH`:host{display:block;color:var(--primary-text-color);font-size:var(--ha-font-size-m);line-height:var(--ha-line-height-normal)}:host([disabled]){color:var(--disabled-text-color);pointer-events:none}.base{position:relative;display:flex;flex-direction:row;align-items:center;gap:var(--ha-row-item-gap,var(--ha-space-4));padding-block:var(--ha-row-item-padding-block,var(--ha-space-3));padding-inline:var(--ha-row-item-padding-inline,var(--ha-space-4));min-height:var(--ha-row-item-min-height,48px);box-sizing:border-box}.content{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;justify-content:center}.end,.start{display:flex;align-items:center;flex:0 0 auto}.end[hidden],.start[hidden]{display:none}.headline{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.supporting{color:var(--secondary-text-color);font-size:var(--ha-font-size-s);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}`,(0,o.Cg)([(0,n.MZ)({type:String})],r.prototype,"headline",void 0),(0,o.Cg)([(0,n.MZ)({type:String,attribute:"supporting-text"})],r.prototype,"supportingText",void 0),(0,o.Cg)([(0,n.MZ)({type:Boolean,reflect:!0})],r.prototype,"disabled",void 0),(0,o.Cg)([(0,n.wk)()],r.prototype,"_hasStart",void 0),(0,o.Cg)([(0,n.wk)()],r.prototype,"_hasEnd",void 0),r=(0,o.Cg)([(0,n.EM)("ha-row-item")],r)},17596(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),a=i(5124),s=i(22441),n=i(66289),r=(i(62647),i(42678)),l=i(21018),d=i(63277),h=i(76530),g=e([n,h,l,d]);[n,h,l,d]=g.then?(await g)():g;const c=["config","visibility"];class p extends d.U{async getConfigElement(){const e=await(0,l.ww)(this.configElementType);if(e&&e.getConfigElement)return e.getConfigElement()}async getConfigForm(){const e=await(0,l.ww)(this.configElementType);if(e&&e.getConfigForm)return e.getConfigForm()}_handleTabChanged(e){const t=e.detail.name;t!==this._currTab&&(this._currTab=t)}_configChanged(e){e.stopPropagation(),this.value=e.detail.value}renderConfigElement(){let e=a.s6;switch(this._currTab){case"config":e=a.qy`${super.renderConfigElement()}`;break;case"visibility":e=a.qy` <hui-badge-visibility-editor .hass="${this.hass}" .config="${this.value}" .entityId="${this.value?(0,r.r)(this.value):void 0}" -changed="${this._configChanged}"></hui-badge-visibility-editor> `}return a.qy` <ha-tab-group -tab-show="${this._handleTabChanged}"> ${c.map(e=>a.qy` <ha-tab-group-tab slot="nav" .panel="${e}" .active="${this._currTab===e}"> ${this.hass.localize(`ui.panel.lovelace.editor.edit_badge.tab_${e}`)} </ha-tab-group-tab> `)} </ha-tab-group> ${e} `}static get styles(){return[d.U.styles,a.AH`ha-tab-group{margin-bottom:16px}ha-tab-group-tab{flex:1}ha-tab-group-tab::part(base){width:100%;justify-content:center}`]}constructor(...e){super(...e),this._currTab=c[0]}}(0,o.Cg)([(0,s.wk)()],p.prototype,"_currTab",void 0),p=(0,o.Cg)([(0,s.EM)("hui-badge-element-editor")],p),t()}catch(e){t(e)}})},76530(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),a=i(35211),s=i(5124),n=i(22441),r=i(1087),l=i(82747),d=i(13898),h=i(30461),g=e([d,h]);[d,h]=g.then?(await g)():g;class c extends s.WF{willUpdate(e){e.has("entityId")&&this._contextProvider.setValue(this.entityId?{mode:"current",entityId:this.entityId}:void 0)}render(){const e=this.config.visibility??[];return s.qy` <ha-visibility-status .hass="${this.hass}" .conditions="${e}"></ha-visibility-status> <ha-card-conditions-editor .hass="${this.hass}" .conditions="${e}" -changed="${this._valueChanged}"> </ha-card-conditions-editor> `}_valueChanged(e){e.stopPropagation();const t=e.detail.value,i={...this.config,visibility:t};0===i.visibility?.length&&delete i.visibility,(0,r.r)(this,"value-changed",{value:i})}constructor(...e){super(...e),this._contextProvider=new a.DT(this,{context:l.$,initialValue:void 0})}}c.styles=s.AH`ha-visibility-status{margin-bottom:var(--ha-space-3)}`,(0,o.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"config",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],c.prototype,"entityId",void 0),c=(0,o.Cg)([(0,n.EM)("hui-badge-visibility-editor")],c),t()}catch(e){t(e)}})},36511(e,t,i){i.a(e,async function(e,o){try{i.r(t),i.d(t,{HuiDialogEditBadge:()=>z});var a=i(62826),s=i(34370),n=i.n(s),r=i(5124),l=i(22441),d=i(1087),h=i(15638),g=i(64481),c=i(18350),p=(i(93444),i(72554)),u=i(26300),_=i(65829),y=i(84970),v=i(45291),m=i(65063),b=i(14503),f=i(92255),C=i(43908),w=i(26004),E=i(82360),$=i(77859),x=i(75196),k=i(17596),M=e([c,p,u,_,C,w,k]);[c,p,u,_,C,w,k]=M.then?(await M)():M;const A="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",L="M11,18H13V16H11V18M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20M12,6A4,4 0 0,0 8,10H10A2,2 0 0,1 12,8A2,2 0 0,1 14,10C14,12 11,11.75 11,15H13C13,12.75 16,12.5 16,10A4,4 0 0,0 12,6Z";class z extends r.WF{async showDialog(e){this._params=e,this._GUImode=!0,this._guiModeAvailable=!0,this._open=!0;const t=(0,x.ys)(e.lovelaceConfig,e.path);if("strategy"in t)throw new Error("Can't edit strategy");if(this._containerConfig=t,"badgeConfig"in e)this._badgeConfig=e.badgeConfig,this._dirty=!0;else{const t=this._containerConfig.badges?.[e.badgeIndex];this._badgeConfig=null!=t?(0,y.q)(t):t}this.large=!1,this._badgeConfig&&!Object.isFrozen(this._badgeConfig)&&(this._badgeConfig=n()(this._badgeConfig))}closeDialog(){return this._dirty?(this._confirmCancel(),!1):(this._open=!1,!0)}_dialogClosed(){this._open=!1,this._params=void 0,this._badgeConfig=void 0,this._error=void 0,this._documentationURL=void 0,this._dirty=!1,(0,d.r)(this,"dialog-closed",{dialog:this.localName})}updated(e){if(!this._badgeConfig||void 0!==this._documentationURL||!e.has("_badgeConfig"))return;const t=e.get("_badgeConfig");t?.type!==this._badgeConfig.type&&(this._documentationURL=this._badgeConfig.type?(0,$.R)(this.hass,this._badgeConfig.type):void 0)}render(){if(!this._params)return r.s6;let e;if(this._badgeConfig&&this._badgeConfig.type){let t;(0,v.c8)(this._badgeConfig.type)?(t=(0,v.b$)((0,v.Iu)(this._badgeConfig.type))?.name,t?.toLowerCase().endsWith(" badge")&&(t=t.substring(0,t.length-6))):t=this.hass.localize(`ui.panel.lovelace.editor.badge.${this._badgeConfig.type}.name`),e=this.hass.localize("ui.panel.lovelace.editor.edit_badge.typed_header",{type:t})}else e=this._badgeConfig?this.hass.localize("ui.panel.lovelace.editor.edit_badge.header"):this._containerConfig.title?this.hass.localize("ui.panel.lovelace.editor.edit_badge.pick_badge_view_title",{name:this._containerConfig.title}):this.hass.localize("ui.panel.lovelace.editor.edit_badge.pick_badge");return r.qy` <ha-dialog .open="${this._open}" .width="${this.large?"full":"large"}" prevent-scrim-close ="${this._ignoreKeydown}" ="${this._dialogClosed}" ="${this._opened}"> <ha-icon-button slot="headerNavigationIcon" ="${this._cancel}" .label="${this.hass.localize("ui.common.close")}" .path="${A}"></ha-icon-button> <span slot="headerTitle" class="title-enlargeable" ="${this._enlarge}">${e}</span> ${void 0!==this._documentationURL?r.qy` <ha-icon-button .path="${L}" slot="headerActionItems" .href="${this._documentationURL}" title="${this.hass.localize("ui.panel.lovelace.menu.help")}" target="_blank" rel="noreferrer" dir="${(0,h.Vc)(this.hass)}"></ha-icon-button> `:r.s6} <div class="content"> <div class="element-editor"> <hui-badge-element-editor autofocus .hass="${this.hass}" .lovelace="${this._params.lovelaceConfig}" .value="${this._badgeConfig}" in-dialog -changed="${this._handleConfigChanged}" -changed="${this._handleGUIModeChanged}" -save="${this._save}"></hui-badge-element-editor> </div> <div class="element-preview"> <hui-badge .hass="${this.hass}" .config="${this._badgeConfig}" preview class="${this._error?"blur":""}"></hui-badge> ${this._error?r.qy` <ha-spinner size="small" aria-label="Can't update badge"></ha-spinner> `:""} </div> </div> <ha-dialog-footer slot="footer"> ${void 0!==this._badgeConfig?r.qy` <ha-button appearance="plain" slot="secondaryAction" ="${this._toggleMode}" .disabled="${!this._guiModeAvailable}" class="gui-mode-button"> ${this.hass.localize(!this._badgeEditorEl||this._GUImode?"ui.panel.lovelace.editor.edit_badge.show_code_editor":"ui.panel.lovelace.editor.edit_badge.show_visual_editor")} </ha-button> `:r.s6} <ha-button appearance="plain" slot="secondaryAction" ="${this._cancel}"> ${this.hass.localize("ui.common.cancel")} </ha-button> ${void 0!==this._badgeConfig&&this._dirty?r.qy` <ha-button slot="primaryAction" ?disabled="${!this._canSave||this._saving}" ="${this._save}" .loading="${this._saving}"> ${this.hass.localize("ui.common.save")} </ha-button> `:r.s6} </ha-dialog-footer> </ha-dialog> `}_enlarge(){(0,g.J)(()=>{this.large=!this.large})}_ignoreKeydown(e){e.stopPropagation()}_handleConfigChanged(e){this._badgeConfig=n()(e.detail.config),this._error=e.detail.error,this._guiModeAvailable=e.detail.guiModeAvailable,this._dirty=!0}_handleGUIModeChanged(e){e.stopPropagation(),this._GUImode=e.detail.guiMode,this._guiModeAvailable=e.detail.guiModeAvailable}_toggleMode(){(0,g.J)(()=>{this._badgeEditorEl?.toggleMode()})}_opened(){this._badgeEditorEl?.focusYamlEditor()}get _canSave(){return!this._saving&&(void 0!==this._badgeConfig&&(!this._badgeEditorEl||!this._badgeEditorEl.hasError))}async _confirmCancel(){await new Promise(e=>{setTimeout(e,0)});await(0,m.dk)(this,{title:this.hass.localize("ui.panel.lovelace.editor.edit_badge.unsaved_changes"),text:this.hass.localize("ui.panel.lovelace.editor.edit_badge.confirm_cancel"),dismissText:this.hass.localize("ui.common.stay"),confirmText:this.hass.localize("ui.common.leave")})&&this._cancel()}_cancel(e){e&&e.stopPropagation(),this._dirty=!1,this.closeDialog()}async _save(){if(!this._canSave)return;if(!this._dirty)return void this.closeDialog();this._saving=!0;const e=this._params.path;await this._params.saveConfig("badgeConfig"in this._params?(0,E.HQ)(this._params.lovelaceConfig,e,this._badgeConfig):(0,E.M)(this._params.lovelaceConfig,[...e,this._params.badgeIndex],this._badgeConfig)),this._saving=!1,this._dirty=!1,(0,f.f)(this,this.hass),this.closeDialog()}static get styles(){return[b.nA,b.kO,r.AH`:host{--code-mirror-max-height:calc(100vh - 176px)}ha-dialog{--dialog-z-index:6;--dialog-content-padding:var(--ha-space-2)}.content{width:100%;max-width:100%} all and (max-width:450px),all and (max-height:500px){.content{width:100%;max-width:100%;gap:var(--ha-space-3)}} all and (min-width:451px) and (min-height:501px){:host([large]) .content{max-width:none}}.center{margin-left:auto;margin-right:auto}.content{display:flex;flex-direction:column}.content .element-editor{margin:0 10px} (min-width:1000px){.content{flex-direction:row}.content>*{flex-basis:0;flex-grow:1;flex-shrink:1;min-width:0}}.hidden{display:none}.element-editor{margin-bottom:8px}.blur{filter:blur(2px) grayscale(100%)}.element-preview{position:relative;height:max-content;background:var(--primary-background-color);padding:10px;border-radius:var(--ha-border-radius-sm);position:sticky;top:0;display:flex;flex-direction:column;justify-content:center;align-items:center}.element-preview ha-spinner{top:calc(50% - 14px);left:calc(50% - 14px);position:absolute;z-index:10}.gui-mode-button{margin-right:auto;margin-inline-end:auto;margin-inline-start:initial}ha-dialog ha-icon-button[slot=headerActionItems]{color:var(--secondary-text-color)}.title-enlargeable{display:block}`]}constructor(...e){super(...e),this.large=!1,this._open=!1,this._saving=!1,this._guiModeAvailable=!0,this._GUImode=!0,this._dirty=!1}}(0,a.Cg)([(0,l.MZ)({attribute:!1})],z.prototype,"hass",void 0),(0,a.Cg)([(0,l.MZ)({type:Boolean,reflect:!0})],z.prototype,"large",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_params",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_open",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_badgeConfig",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_containerConfig",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_saving",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_error",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_guiModeAvailable",void 0),(0,a.Cg)([(0,l.P)("hui-badge-element-editor")],z.prototype,"_badgeEditorEl",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_GUImode",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_documentationURL",void 0),(0,a.Cg)([(0,l.wk)()],z.prototype,"_dirty",void 0),z=(0,a.Cg)([(0,l.EM)("hui-dialog-edit-badge")],z),o()}catch(e){o(e)}})},30461(e,t,i){i.a(e,async function(e,t){try{var o=i(62826),a=i(35211),s=i(5124),n=i(22441),r=i(87047),l=i(38962),d=(i(67094),i(83892)),h=i(14487),g=i(82747),c=e([l,h,r]);[l,h,r]=c.then?(await c)():c;const p={visible:"M12,9A3,3 0 0,0 9,12A3,3 0 0,0 12,15A3,3 0 0,0 15,12A3,3 0 0,0 12,9M12,17A5,5 0 0,1 7,12A5,5 0 0,1 12,7A5,5 0 0,1 17,12A5,5 0 0,1 12,17M12,4.5C7,4.5 2.73,7.61 1,12C2.73,16.39 7,19.5 12,19.5C17,19.5 21.27,16.39 23,12C21.27,7.61 17,4.5 12,4.5Z",hidden:"M11.83,9L15,12.16C15,12.11 15,12.05 15,12A3,3 0 0,0 12,9C11.94,9 11.89,9 11.83,9M7.53,9.8L9.08,11.35C9.03,11.56 9,11.77 9,12A3,3 0 0,0 12,15C12.22,15 12.44,14.97 12.65,14.92L14.2,16.47C13.53,16.8 12.79,17 12,17A5,5 0 0,1 7,12C7,11.21 7.2,10.47 7.53,9.8M2,4.27L4.28,6.55L4.73,7C3.08,8.3 1.78,10 1,12C2.73,16.39 7,19.5 12,19.5C13.55,19.5 15.03,19.2 16.38,18.66L16.81,19.08L19.73,22L21,20.73L3.27,3M12,7A5,5 0 0,1 17,12C17,12.64 16.87,13.26 16.64,13.82L19.57,16.75C21.07,15.5 22.27,13.86 23,12C21.27,7.61 17,4.5 12,4.5C10.6,4.5 9.26,4.75 8,5.2L10.17,7.35C10.74,7.13 11.35,7 12,7Z",invalid:"M13,13H11V7H13M13,17H11V15H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2Z"};class u extends s.WF{willUpdate(e){super.willUpdate(e),(e.has("conditions")||e.has("hass"))&&this._listeners.setup(this.conditions??[],this.hass,()=>this._evaluate()),(e.has("hass")||e.has("conditions")||e.has("_entityContext"))&&this._evaluate()}render(){return s.qy` <ha-alert .alertType="${"visible"===this.state?"success":"hidden"===this.state?"warning":"error"}"> <ha-svg-icon slot="icon" .path="${p[this.state]}"></ha-svg-icon> <div class="headline"> ${this.hass?.localize(`ui.panel.lovelace.editor.condition-editor.visibility_status.${this.state}.headline`)} </div> <div class="supporting"> ${this.hass?.localize(`ui.panel.lovelace.editor.condition-editor.visibility_status.${this.state}.supporting${0===(this.conditions?.length??0)?"_empty":""}`)} </div> </ha-alert> `}_evaluate(){const e=this.conditions??[];let t;if(0===e.length)t="visible";else if((0,h.db)(e)){const i="current"===this._entityContext?.mode?{entity_id:this._entityContext.entityId}:{};t=(0,h.XH)(e,this.hass,i)?"visible":"hidden"}else t="invalid";t!==this.state&&(this.state=t)}constructor(...e){super(...e),this.conditions=[],this.state="visible",this._listeners=new r.x(this)}}u.styles=[d.x.styles,s.AH`ha-alert{display:block;--mdc-icon-size:24px}.headline{font-weight:var(--ha-font-weight-medium);margin-bottom:var(--ha-space-1)}`],(0,o.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"hass",void 0),(0,o.Cg)([(0,n.MZ)({attribute:!1})],u.prototype,"conditions",void 0),(0,o.Cg)([(0,n.wk)(),(0,a.Fg)({context:g.$,subscribe:!0})],u.prototype,"_entityContext",void 0),(0,o.Cg)([(0,n.MZ)()],u.prototype,"state",void 0),u=(0,o.Cg)([(0,n.EM)("ha-visibility-status")],u),t()}catch(e){t(e)}})},77859(e,t,i){i.d(t,{R:()=>l,W:()=>r});var o=i(45291),a=i(36918);const s={"energy-date-selection":"energy/#energy-date-picker","energy-compare":"energy/#energy-compare-alert","energy-usage-graph":"energy/#energy-usage-graph","energy-solar-graph":"energy/#solar-production-graph","energy-gas-graph":"energy/#gas-consumption-graph","energy-water-graph":"energy/#water-consumption-graph","energy-distribution":"energy/#energy-distribution","energy-sources-table":"energy/#energy-sources-table","energy-grid-balance":"energy/#grid-energy-balance","energy-grid-neutrality-gauge":"energy/#grid-neutrality-gauge","energy-solar-consumed-gauge":"energy/#solar-consumed-gauge","energy-carbon-consumed-gauge":"energy/#carbon-consumed-gauge","energy-self-sufficiency-gauge":"energy/#self-sufficiency-gauge","energy-devices-graph":"energy/#devices-energy-graph","energy-devices-detail-graph":"energy/#detail-devices-energy-graph","energy-sankey":"energy/#sankey-energy-graph","power-sources-graph":"energy/#power-sources-graph"},n={"power-total":"energy/#power-consumption-badge","water-total":"energy/#water-flow-rate-badge","gas-total":"energy/#gas-flow-rate-badge"},r=(e,t)=>(0,o.c8)(t)?(0,o.wi)((0,o.Iu)(t))?.documentationURL:`${(0,a.o)(e,"/dashboards/")}${s[t]||t}`,l=(e,t)=>(0,o.c8)(t)?(0,o.b$)((0,o.Iu)(t))?.documentationURL:`${(0,a.o)(e,"/dashboards/")}${n[t]||"badges"}`},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}}},91322(e,t,i){i.a(e,async function(e,o){try{i.d(t,{m:()=>y});i(18111),i(7588),i(61701);var a=i(62826),s=i(5124),n=i(22441),r=i(74985),l=i(1087),d=i(78978),h=i(19459),g=i(38962),c=i(65829),p=i(10763),u=i(39039),_=e([g,c,p]);[g,c,p]=_.then?(await _)():_;class y extends s.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 s.qy`${this._configElement}`}_renderSubElement(){return s.qy` <hui-sub-element-editor .hass="${this.hass}" .config="${this._subElementEditorConfig}" -back="${this._goBack}" -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 s.qy` <div class="wrapper"> ${this.GUImode?s.qy` <div class="gui-editor" -sub-element="${this._editSubElement}"> ${this._loading?s.qy` <ha-spinner class="center margin-bot"></ha-spinner> `:(0,r.P)(this._subElementEditorConfig?this._renderSubElement():this.renderConfigElement())} </div> `:s.qy` <div class="yaml-editor"> <ha-yaml-editor .defaultValue="${this._config}" autofocus .inDialog="${this.inDialog}" -changed="${this._handleYAMLChanged}" ="${this._ignoreKeydown}" dir="ltr"></ha-yaml-editor> </div> `} ${!1===this._guiSupported&&!1===this._loading?s.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> `:s.s6} ${this._errors?.length?s.qy` <ha-alert alert-type="error" .title="${this.hass.localize("ui.errors.config.configuration_error")}"> <ul> ${this._errors.map(e=>s.qy`<li>${e}</li>`)} </ul> </ha-alert> `:s.s6} ${this.hasWarning?s.qy` <ha-alert alert-type="warning" .title="${this.hass.localize("ui.errors.config.visual_editor_not_supported")}"> <ul> ${this._warnings.map(e=>s.qy`<li>${e}</li>`)} </ul> ${this.hass.localize("ui.errors.config.edit_in_yaml_supported")} </ha-alert> `:s.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:a,computeLabel:s,computeHelper:n}=t;e.schema=o,s&&(e.computeLabel=s),n&&(e.computeHelper=n),a&&(e.assertConfig=a)}}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,d._)(this.hass,e);throw new u.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 u.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}}y.styles=s.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,a.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"hass",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"lovelace",void 0),(0,a.Cg)([(0,n.MZ)({attribute:!1})],y.prototype,"context",void 0),(0,a.Cg)([(0,n.MZ)({type:Boolean,attribute:"in-dialog"})],y.prototype,"inDialog",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_config",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_configElement",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_subElementEditorConfig",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_guiMode",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_errors",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_warnings",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_guiSupported",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_loading",void 0),(0,a.Cg)([(0,n.wk)()],y.prototype,"_yamlError",void 0),(0,a.Cg)([(0,n.P)("ha-yaml-editor")],y.prototype,"_yamlEditor",void 0),o()}catch(e){o(e)}})},63277(e,t,i){i.a(e,async function(e,o){try{i.d(t,{U:()=>l});var a=i(62826),s=i(22441),n=i(91322),r=e([n]);n=(r.then?(await r)():r)[0];class l extends n.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,a.Cg)([(0,s.wk)()],l.prototype,"_configElementType",void 0),o()}catch(e){o(e)}})},92255(e,t,i){i.d(t,{f:()=>a});var o=i(81619);const a=(e,t)=>(0,o.P)(e,{message:t.localize("ui.common.successfully_saved")})},74985(e,t,i){i.d(t,{P:()=>r});i(88454),i(29452);var o=i(5055),a=i(42017),s=i(63937);const n=e=>(0,s.ps)(e)?e._$litType$.h:e.strings,r=(0,a.u$)(class extends a.WL{render(e){return[e]}update(e,[t]){const i=(0,s.qb)(this.it)?n(this.it):null,a=(0,s.qb)(t)?n(t):null;if(null!==i&&(null===a||i!==a)){const t=(0,s.cN)(e).pop();let a=this.et.get(i);if(void 0===a){const e=document.createDocumentFragment();a=(0,o.XX)(o.s6,e),a.setConnected(!1),this.et.set(i,a)}(0,s.mY)(a,[t]),(0,s.Dx)(a,void 0,t)}if(null!==a){if(null===i||i!==a){const t=this.et.get(a);if(void 0!==t){const i=(0,s.cN)(t).pop();(0,s.Jz)(e),(0,s.Dx)(e,void 0,i),(0,s.mY)(e,[i])}}this.it=t}else this.it=void 0;return this.render(t)}constructor(e){super(e),this.et=new WeakMap}})}};