UNPKG

iobroker.lovelace

Version:

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

1 lines 34.1 kB
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[93576],{90409:function(e,t,i){i.d(t,{A:function(){return s}});i(18111),i(61701);function s(e){const t=e.split(":").map(Number);return 3600*t[0]+60*t[1]+t[2]}},43908:function(e,t,i){i.a(e,async function(e,t){try{i(49255),i(16280),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(1087),d=(i(67094),i(91263)),r=i(42678),l=i(14487),h=i(21018),c=i(34128),g=e([d,h,l]);[d,h,l]=g.then?(await g)():g;class p extends((0,d.M)(a.mN)){load(){if(!this.config)throw new Error("Cannot build badge without config");this._loadElement(this.config)}createRenderRoot(){return this}disconnectedCallback(){super.disconnectedCallback()}connectedCallback(){super.connectedCallback(),this._updateVisibility()}_updateElement(e){this._element&&(this._element.setConfig(e),this._elementConfig=e,(0,n.r)(this,"badge-updated"))}_loadElement(e){for(this._element=(0,h.YH)(e),this._elementConfig=e,this.hass&&(this._element.hass=this.hass),this._element.addEventListener("badge-visibility-changed",e=>{e.stopPropagation(),this._updateVisibility()}),this._element.addEventListener("ll-upgrade",e=>{e.stopPropagation(),this.hass&&(this._element.hass=this.hass),(0,n.r)(this,"badge-updated")},{once:!0}),this._element.addEventListener("ll-rebuild",t=>{t.stopPropagation(),this._loadElement(e),(0,n.r)(this,"badge-updated")},{once:!0});this.lastChild;)this.removeChild(this.lastChild);this._updateVisibility()}willUpdate(e){super.willUpdate(e),e.has("config")&&(this._conditionContext=Object.assign(Object.assign({},this._conditionContext),{},{entity_id:this.config?(0,r.r)(this.config):void 0})),this._element||this.load()}update(e){if(super.update(e),this._element){if(e.has("config")){const e=this._elementConfig;if(this.config!==e&&this.config){var t;(null===(t=this.config)||void 0===t?void 0:t.type)!==(null==e?void 0:e.type)?this._loadElement(this.config):this._updateElement(this.config)}}if(e.has("hass"))try{this.hass&&(this._element.hass=this.hass)}catch(i){this._loadElement((0,c.G9)(i.message,null))}}(e.has("hass")||e.has("preview"))&&this._updateVisibility()}_updateVisibility(e){var t,i;if(!this._element||!this.hass)return;if(this._element.hidden)return void this._setElementVisibility(!1);if(this.preview)return void this._setElementVisibility(!0);if(null!==(t=this.config)&&void 0!==t&&t.disabled)return void this._setElementVisibility(!1);const s=null!=e?e:!(null!==(i=this.config)&&void 0!==i&&i.visibility)||(0,l.XH)(this.config.visibility,this.hass,this._conditionContext);this._setElementVisibility(s)}_setElementVisibility(e){this._element&&(this.hidden!==!e&&(this.style.setProperty("display",e?"":"none"),this.toggleAttribute("hidden",!e),(0,n.r)(this,"badge-visibility-changed",{value:e})),!0===this._element.connectedWhileHidden?this._element.parentElement||this.appendChild(this._element):!e&&this._element.parentElement?this.removeChild(this._element):e&&!this._element.parentElement&&this.appendChild(this._element))}constructor(...e){super(...e),this.preview=!1}}(0,s.Cg)([(0,o.MZ)({type:Boolean})],p.prototype,"preview",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"config",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],p.prototype,"hass",void 0),p=(0,s.Cg)([(0,o.EM)("hui-badge")],p),t()}catch(p){t(p)}})},52667:function(e,t,i){i.a(e,async function(e,t){try{i(49255),i(18111),i(81148),i(88454),i(29452),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(6412),d=i(75751),r=i(1087),l=(i(54276),i(85938),i(67094),i(80173)),h=i(82360),c=e([l]);l=(c.then?(await c)():c)[0];let g,p,u,v,m,b,_=e=>e;const y="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",f={delay:100,delayOnTouchOnly:!0,direction:"horizontal",invertedSwapThreshold:.7};class C extends a.WF{_checkAllHidden(){const e=!this.lovelace.editMode&&this.badges.every(e=>e.hidden);this.toggleAttribute("hidden",e)}connectedCallback(){super.connectedCallback(),this.addEventListener("badge-visibility-changed",this._badgeVisibilityChanged)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("badge-visibility-changed",this._badgeVisibilityChanged)}willUpdate(e){(e.has("badges")||e.has("lovelace"))&&this._checkAllHidden()}_getBadgeKey(e){return this._badgeConfigKeys.has(e)||this._badgeConfigKeys.set(e,Math.random().toString()),this._badgeConfigKeys.get(e)}_badgeMoved(e){e.stopPropagation();const{oldIndex:t,newIndex:i}=e.detail,s=(0,h.RB)(this.lovelace.config,[this.viewIndex,t],[this.viewIndex,i]);this.lovelace.saveConfig(s)}_badgeAdded(e){e.stopPropagation();const{index:t,data:i}=e.detail,s=i,a=[this.viewIndex,t],o=(0,h.RB)(this.lovelace.config,s,a);this.lovelace.saveConfig(o)}_badgeRemoved(e){e.stopPropagation()}_dragStart(){this._dragging=!0}_dragEnd(){this._dragging=!1}_addBadge(){(0,r.r)(this,"ll-create-badge")}render(){if(!this.lovelace)return a.s6;const e=this.lovelace.editMode,t=this.badges;return(0,a.qy)(g||(g=_` ${0} `),(null==t?void 0:t.length)>0||e?(0,a.qy)(p||(p=_` <ha-sortable .disabled="${0}" @item-moved="${0}" @item-added="${0}" @item-removed="${0}" @drag-start="${0}" @drag-end="${0}" group="badge" draggable-selector="[data-sortable]" .rollback="${0}" .options="${0}" invert-swap> <div class="badges ${0}"> ${0} ${0} </div> </ha-sortable> `),!e,this._badgeMoved,this._badgeAdded,this._badgeRemoved,this._dragStart,this._dragEnd,!1,f,(0,n.H)({"edit-mode":e}),(0,d.u)(t,e=>this._getBadgeKey(e),(t,i)=>{const s=[this.viewIndex,i];return(0,a.qy)(u||(u=_` ${0} `),e?(0,a.qy)(v||(v=_` <hui-badge-edit-mode data-sortable .hass="${0}" .lovelace="${0}" .path="${0}" .hiddenOverlay="${0}" .sortableData="${0}"> ${0} </hui-badge-edit-mode> `),this.hass,this.lovelace,s,this._dragging,s,t):t)}),e?(0,a.qy)(m||(m=_` <button class="add" @click="${0}" aria-label="${0}" .title="${0}"> <ha-ripple></ha-ripple> <ha-svg-icon .path="${0}"></ha-svg-icon> ${0} </button> `),this._addBadge,this.hass.localize("ui.panel.lovelace.editor.section.add_badge"),this.hass.localize("ui.panel.lovelace.editor.section.add_badge"),y,this.showAddLabel?this.hass.localize("ui.panel.lovelace.editor.section.add_badge"):a.s6):a.s6):a.s6)}constructor(...e){super(...e),this.badges=[],this._dragging=!1,this._badgeConfigKeys=new WeakMap,this._badgeVisibilityChanged=()=>{this._checkAllHidden()}}}C.styles=(0,a.AH)(b||(b=_`:host([hidden]){display:none!important}.badges{display:flex;align-items:flex-start;flex-wrap:var(--badges-wrap,wrap);justify-content:var(--badges-aligmnent,center);gap:var(--ha-space-2);margin:0}.badges::after,.badges::before{content:"";position:relative;display:block;min-width:var(--badge-padding,0px);height:16px;background-color:transparent}.badges::before{margin-left:-8px;margin-inline-start:-8px;margin-inline-end:0}.badges::after{margin-right:-8px;margin-inline-end:-8px;margin-inline-start:0}.badges>*{min-width:fit-content}hui-badge-edit-mode{display:block;position:relative;min-width:36px;min-height:36px}.add{position:relative;display:flex;flex-direction:row;align-items:center;outline:0;gap:var(--ha-space-2);height:36px;padding:6px 20px 6px 20px;box-sizing:border-box;width:auto;border-radius:var(--ha-border-radius-2xl);background-color:transparent;border-width:2px;border-style:dashed;border-color:var(--primary-color);--mdc-icon-size:18px;cursor:pointer;font-size:var(--ha-font-size-m);color:var(--primary-text-color);--ha-ripple-color:var(--primary-color);--ha-ripple-hover-opacity:0.04;--ha-ripple-pressed-opacity:0.12}.add:focus{border-style:solid}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"lovelace",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"badges",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],C.prototype,"viewIndex",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean,attribute:"show-add-label"})],C.prototype,"showAddLabel",void 0),(0,s.Cg)([(0,o.wk)()],C.prototype,"_dragging",void 0),C=(0,s.Cg)([(0,o.EM)("hui-view-badges")],C),t()}catch(g){t(g)}})},80173:function(e,t,i){i.a(e,async function(e,t){try{i(74423),i(62953);var s=i(40445),a=(i(68825),i(34271)),o=i(5124),n=i(67576),d=i(6412),r=i(93905),l=i(1087),h=i(29823),c=(i(70947),i(26300)),g=(i(67094),i(84970)),p=i(14503),u=i(63023),v=i(75196),m=e([h,c]);[h,c]=m.then?(await m)():m;let b,_,y=e=>e;const f="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z",C="M19,3L13,9L15,11L22,4V3M12,12.5A0.5,0.5 0 0,1 11.5,12A0.5,0.5 0 0,1 12,11.5A0.5,0.5 0 0,1 12.5,12A0.5,0.5 0 0,1 12,12.5M6,20A2,2 0 0,1 4,18C4,16.89 4.9,16 6,16A2,2 0 0,1 8,18C8,19.11 7.1,20 6,20M6,8A2,2 0 0,1 4,6C4,4.89 4.9,4 6,4A2,2 0 0,1 8,6C8,7.11 7.1,8 6,8M9.64,7.64C9.87,7.14 10,6.59 10,6A4,4 0 0,0 6,2A4,4 0 0,0 2,6A4,4 0 0,0 6,10C6.59,10 7.14,9.87 7.64,9.64L10,12L7.64,14.36C7.14,14.13 6.59,14 6,14A4,4 0 0,0 2,18A4,4 0 0,0 6,22A4,4 0 0,0 10,18C10,17.41 9.87,16.86 9.64,16.36L12,14L19,21H22V20L9.64,7.64Z",w="M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z",x="M12,16A2,2 0 0,1 14,18A2,2 0 0,1 12,20A2,2 0 0,1 10,18A2,2 0 0,1 12,16M12,10A2,2 0 0,1 14,12A2,2 0 0,1 12,14A2,2 0 0,1 10,12A2,2 0 0,1 12,10M12,4A2,2 0 0,1 14,6A2,2 0 0,1 12,8A2,2 0 0,1 10,6A2,2 0 0,1 12,4Z",E="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",k="M16,8H14V11H11V13H14V16H16V13H19V11H16M2,12C2,9.21 3.64,6.8 6,5.68V3.5C2.5,4.76 0,8.09 0,12C0,15.91 2.5,19.24 6,20.5V18.32C3.64,17.2 2,14.79 2,12M15,3C10.04,3 6,7.04 6,12C6,16.96 10.04,21 15,21C19.96,21 24,16.96 24,12C24,7.04 19.96,3 15,3M15,19C11.14,19 8,15.86 8,12C8,8.14 11.14,5 15,5C18.86,5 22,8.14 22,12C22,15.86 18.86,19 15,19Z";class M extends o.WF{get _badges(){const e=(0,v.S2)(this.path);return(0,v.jW)("badges",this.lovelace.config,e)}firstUpdated(){this.addEventListener("focus",()=>{this._focused=!0}),this.addEventListener("blur",()=>{this._focused=!1}),this.addEventListener("touchstart",()=>{this._touchStarted=!0}),this.addEventListener("touchend",()=>{setTimeout(()=>{this._touchStarted=!1},10)}),this.addEventListener("mouseenter",()=>{this._touchStarted||(this._hover=!0)}),this.addEventListener("mouseleave",()=>{this._hover=!1}),this.addEventListener("click",()=>{this._hover=!0,document.addEventListener("click",this._documentClicked)})}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this._documentClicked)}render(){const e=(this._hover||this._menuOpened||this._focused)&&!this.hiddenOverlay;return(0,o.qy)(b||(b=y` <div class="badge-wrapper" inert><slot></slot></div> <div class="badge-overlay ${0}"> <div class="edit" @click="${0}" @keydown="${0}" tabindex="0"> <div class="edit-overlay"></div> <ha-svg-icon class="edit" .path="${0}"> </ha-svg-icon> </div> <ha-dropdown class="more" placement="bottom-end" @wa-select="${0}" @opened="${0}" @closed="${0}"> <ha-icon-button slot="trigger" .path="${0}"> </ha-icon-button> <ha-dropdown-item value="edit"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="duplicate"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="copy"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item> <ha-dropdown-item value="cut"> <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> ${0} </ha-dropdown-item> <wa-divider></wa-divider> <ha-dropdown-item value="delete" variant="danger"> ${0} <ha-svg-icon slot="icon" .path="${0}"></ha-svg-icon> </ha-dropdown-item> </ha-dropdown> </div> `),(0,d.H)({visible:e}),this._handleOverlayClick,this._handleOverlayClick,E,this._handleAction,this._handleOpened,this._handleClosed,x,E,this.hass.localize("ui.panel.lovelace.editor.edit_card.edit"),k,this.hass.localize("ui.panel.lovelace.editor.edit_card.duplicate"),f,this.hass.localize("ui.panel.lovelace.editor.edit_card.copy"),C,this.hass.localize("ui.panel.lovelace.editor.edit_card.cut"),this.hass.localize("ui.panel.lovelace.editor.edit_card.delete"),w)}_handleOpened(){this._menuOpened=!0}_handleClosed(){this._menuOpened=!1}_handleOverlayClick(e){e.defaultPrevented||"keydown"===e.type&&"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.stopPropagation(),this._editBadge())}_handleAction(e){switch(e.detail.item.value){case"edit":this._editBadge();break;case"duplicate":this._duplicateBadge();break;case"copy":this._copyBadge();break;case"cut":this._cutBadge();break;case"delete":this._deleteBadge()}}_cutBadge(){this._copyBadge(),(0,l.r)(this,"ll-delete-badge",{path:this.path,silent:!0})}_copyBadge(){const{cardIndex:e}=(0,v.gO)(this.path),t=this._badges[e];this._clipboard=(0,a.A)(t)}_duplicateBadge(){const{cardIndex:e}=(0,v.gO)(this.path),t=(0,v.S2)(this.path),i=(0,g.q)(this._badges[e]);(0,u.N)(this,{lovelaceConfig:this.lovelace.config,saveConfig:this.lovelace.saveConfig,path:t,badgeConfig:i})}_editBadge(){(0,l.r)(this,"ll-edit-badge",{path:this.path})}_deleteBadge(){(0,l.r)(this,"ll-delete-badge",{path:this.path,silent:!1})}static get styles(){return[p.RF,(0,o.AH)(_||(_=y`.badge-overlay{position:absolute;opacity:0;pointer-events:none;inset:0;display:flex;align-items:center;justify-content:center;transition:opacity 180ms ease-in-out}.badge-overlay.visible{opacity:1;pointer-events:auto}.badge-wrapper{position:relative;height:100%;z-index:0}.edit{outline:0!important;cursor:pointer;position:absolute;inset:0;display:flex;align-items:center;justify-content:center;border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg));z-index:0}.edit-overlay{position:absolute;inset:0;opacity:.8;background-color:var(--primary-background-color);border-radius:var(--ha-card-border-radius,var(--ha-border-radius-lg));z-index:0}.edit ha-svg-icon{display:flex;position:relative;color:var(--primary-text-color);border-radius:var(--ha-border-radius-circle);padding:4px;background:var(--secondary-background-color);--mdc-icon-size:16px}.more ha-icon-button{position:absolute;right:-8px;top:-8px;inset-inline-end:-10px;inset-inline-start:initial}.more ha-icon-button{cursor:pointer;border-radius:var(--ha-border-radius-circle);background:var(--secondary-background-color);--ha-icon-button-size:24px;--mdc-icon-size:16px}`))]}constructor(...e){super(...e),this.hiddenOverlay=!1,this._menuOpened=!1,this._hover=!1,this._focused=!1,this._touchStarted=!1,this._documentClicked=e=>{this._hover=e.composedPath().includes(this),document.removeEventListener("click",this._documentClicked)}}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"hass",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],M.prototype,"lovelace",void 0),(0,s.Cg)([(0,n.MZ)({type:Array})],M.prototype,"path",void 0),(0,s.Cg)([(0,n.MZ)({attribute:"hidden-overlay",type:Boolean})],M.prototype,"hiddenOverlay",void 0),(0,s.Cg)([(0,n.wk)()],M.prototype,"_menuOpened",void 0),(0,s.Cg)([(0,n.wk)()],M.prototype,"_hover",void 0),(0,s.Cg)([(0,n.wk)()],M.prototype,"_focused",void 0),(0,s.Cg)([(0,r.I)({key:"dashboardBadgeClipboard",state:!1,subscribe:!1,storage:"sessionStorage"})],M.prototype,"_clipboard",void 0),M=(0,s.Cg)([(0,n.EM)("hui-badge-edit-mode")],M),t()}catch(b){t(b)}})},21018:function(e,t,i){i.a(e,async function(e,s){try{i.d(t,{YH:function(){return h},hZ:function(){return l},ww:function(){return c}});i(3362),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953);var a=i(67066),o=i(34128),n=e([a]);a=(n.then?(await n)():n)[0];const d=new Set(["error","entity"]),r={"entity-filter":()=>i.e(4994).then(i.bind(i,95417)),shortcut:()=>i.e(76612).then(i.bind(i,32175)),"state-label":()=>i.e(52396).then(i.bind(i,22087)),"power-total":()=>Promise.all([i.e(92610),i.e(77183),i.e(28696)]).then(i.bind(i,12150)),"gas-total":()=>Promise.all([i.e(92610),i.e(77183),i.e(72892)]).then(i.bind(i,70346)),"water-total":()=>Promise.all([i.e(92610),i.e(77183),i.e(33194)]).then(i.bind(i,61844))},l=e=>(0,o.Vd)("badge",e,d,r,void 0,"entity"),h=e=>(0,o.Ue)("badge",e,d,r,void 0,"entity"),c=e=>(0,o.gh)(e,"badge",d,r);s()}catch(d){s(d)}})},15414:function(e,t,i){i.a(e,async function(e,s){try{i.d(t,{_:function(){return l}});i(3362),i(17642),i(58004),i(33853),i(45876),i(32475),i(15024),i(31698),i(62953);var a=i(47606),o=i(34128),n=e([a]);a=(n.then?(await n)():n)[0];const d=new Set(["masonry"]),r={panel:()=>i.e(45750).then(i.bind(i,90005)),sidebar:()=>i.e(94332).then(i.bind(i,55287)),sections:()=>i.e(88020).then(i.bind(i,18911))},l=e=>(0,o.Ue)("view",e,d,r);s()}catch(d){s(d)}})},42124:function(e,t,i){i.d(t,{d:function(){return o}});i(3362),i(62953);var s=i(1087);const a=()=>Promise.all([i.e(66432),i.e(67785),i.e(29572)]).then(i.bind(i,59407)),o=(e,t)=>{(0,s.r)(e,"show-dialog",{dialogTag:"hui-dialog-create-badge",dialogImport:a,dialogParams:t})}},63023:function(e,t,i){i.d(t,{N:function(){return o}});i(3362),i(62953);var s=i(1087);const a=()=>Promise.all([i.e(66432),i.e(21780)]).then(i.bind(i,36511)),o=(e,t)=>{(0,s.r)(e,"show-dialog",{dialogTag:"hui-dialog-edit-badge",dialogImport:a,dialogParams:t})}},61511:function(e,t,i){i.d(t,{a:function(){return o}});i(3362);var s=i(82360),a=i(1087);async function o(e,t,i){try{const{path:o,silent:n}=i,d=t.config,r=(0,s.P3)(d,o);if(await t.saveConfig(r),n)return;t.showToast({message:e.localize("ui.common.successfully_deleted"),duration:8e3,action:{action:()=>(0,a.r)(window,"undo-change"),text:e.localize("ui.common.undo")}})}catch(o){console.error(o),t.showToast({message:e.localize("ui.common.deleting_failed")})}}},19959:function(e,t,i){i.d(t,{I:function(){return r}});i(62953);var s=i(40445),a=i(5124),o=i(67576);i(58388),i(67094);let n,d=e=>e;const r=e=>({type:"error",error:e});class l extends a.WF{setConfig(e){this._config=e}render(){return this._config?(0,a.qy)(n||(n=d` <h1>Error</h1> <p>${0}</p> `),this._config.error):a.s6}constructor(...e){super(...e),this.isStrategy=!1}}(0,s.Cg)([(0,o.MZ)({attribute:!1})],l.prototype,"isStrategy",void 0),(0,s.Cg)([(0,o.wk)()],l.prototype,"_config",void 0),l=(0,s.Cg)([(0,o.EM)("hui-error-section")],l)},49365:function(e,t,i){i.d(t,{NT:function(){return s},_H:function(){return o},oH:function(){return a}});const s="masonry",a="sidebar",o="sections"},36751:function(e,t,i){i.d(t,{E:function(){return a}});var s=i(49365);const a=e=>null!=e&&e.type?e.type:null!=e&&e.panel?"panel":null!=e&&e.sections?s._H:null!=e&&e.cards?s.NT:s._H},47606:function(e,t,i){i.a(e,async function(e,t){try{i(44114),i(72712),i(18111),i(7588),i(18237),i(3362),i(62953);var s=i(40445),a=i(5124),o=i(67576),n=i(1087),d=i(12587),r=i(58234),l=i(18350),h=(i(67094),i(52667)),c=i(33121),g=e([r,l,h]);[r,l,h]=g.then?(await g)():g;let p,u,v,m=e=>e;const b="M19,13H13V19H11V13H5V11H11V5H13V11H19V13Z",_=(e,t)=>{let i=0;for(let s=0;s<e.length;s++){if(e[s]<5){i=s;break}e[s]<e[i]&&(i=s)}return e[i]+=t,i};class y extends a.WF{connectedCallback(){super.connectedCallback(),this._initMqls()}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._mqls)||void 0===e||e.forEach(e=>{e.removeListener(this._mqlListenerRef)}),this._mqlListenerRef=void 0,this._mqls=void 0}setConfig(e){}render(){var e,t;return(0,a.qy)(p||(p=m` <hui-view-badges .hass="${0}" .badges="${0}" .lovelace="${0}" .viewIndex="${0}" show-add-label></hui-view-badges> <div id="columns" class="${0}"></div> ${0} `),this.hass,this.badges,this.lovelace,this.index,null!==(e=this.lovelace)&&void 0!==e&&e.editMode?"edit-mode":"",null!==(t=this.lovelace)&&void 0!==t&&t.editMode?(0,a.qy)(u||(u=m` <ha-button size="large" @click="${0}"> <ha-svg-icon slot="start" .path="${0}"></ha-svg-icon> ${0} </ha-button> `),this._addCard,b,this.hass.localize("ui.panel.lovelace.editor.edit_card.add")):"")}_initMqls(){this._mqls=[300,600,900,1200].map(e=>{const t=window.matchMedia(`(min-width: ${e}px)`);return this._mqlListenerRef||(this._mqlListenerRef=this._updateColumns.bind(this)),t.addListener(this._mqlListenerRef),t})}get mqls(){return this._mqls||this._initMqls(),this._mqls}willUpdate(e){var t;if(super.willUpdate(e),null!==(t=this.lovelace)&&void 0!==t&&t.editMode&&i.e(59127).then(i.bind(i,70410)),e.has("hass")){const t=e.get("hass");if(this.hass.dockedSidebar!==(null==t?void 0:t.dockedSidebar))return void this._updateColumns()}if(e.has("narrow"))return void this._updateColumns();const s=e.get("lovelace");(e.has("cards")||e.has("lovelace")&&s&&(s.config!==this.lovelace.config||s.editMode!==this.lovelace.editMode))&&this._createColumns()}_addCard(){(0,n.r)(this,"ll-create-card")}_createRootElement(e){const t=this.shadowRoot.getElementById("columns");for(;t.lastChild;)t.removeChild(t.lastChild);e.forEach(e=>t.appendChild(e))}async _createColumns(){if(!this._columns)return;this._createColumnsIteration++;const e=this._createColumnsIteration,t=[],i=[];for(let o=0;o<Math.min(this._columns,this.cards.length);o++){const e=document.createElement("div");e.classList.add("column"),t.push(0),i.push(e)}let s,a;this.hasUpdated?this._createRootElement(i):this.updateComplete.then(()=>{this._createRootElement(i)});for(const[o,n]of this.cards.entries()){let r;void 0===s&&(s=(0,d.E)().then(()=>{s=void 0,a=void 0})),void 0===a?a=new Date:(new Date).getTime()-a.getTime()>16&&(r=s);const l=(0,c.Z)(n),[h]=await Promise.all([l,r]);if(e!==this._createColumnsIteration)return;this._addCardToColumn(i[_(t,h)],o,this.lovelace.editMode)}i.forEach(e=>{e.lastChild||e.parentElement.removeChild(e)})}_addCardToColumn(e,t,i){const s=this.cards[t];if(!i||this.isStrategy)s.preview=!1,e.appendChild(s);else{const i=document.createElement("hui-card-options");i.hass=this.hass,i.lovelace=this.lovelace,i.path=[this.index,t],s.preview=!0,i.appendChild(s),e.appendChild(i)}}_updateColumns(){const e=this.mqls.reduce((e,t)=>e+Number(t.matches),0),t=Math.max(1,e-Number(!this.narrow&&"docked"===this.hass.dockedSidebar));t!==this._columns&&(this._columns=t,this._createColumns())}constructor(...e){super(...e),this.narrow=!1,this.isStrategy=!1,this.cards=[],this.badges=[],this._createColumnsIteration=0}}y.styles=(0,a.AH)(v||(v=m`:host{display:block;padding-top:4px}hui-view-badges{display:block;margin:4px 8px 4px 8px;font-size:var(--ha-font-size-s)}#columns{display:flex;flex-direction:row;justify-content:center;margin-left:4px;margin-right:4px}#columns.edit-mode{margin-bottom:72px}.column{flex:1 0 0;max-width:500px;min-width:0}.column:has(> *){flex-grow:1}.column:not(:has(> :not([hidden]))){flex-grow:0}.column>:not([hidden]){display:block;margin:var(--masonry-view-card-margin,4px 4px 8px)}ha-button{position:fixed;right:calc(16px + var(--safe-area-inset-right));bottom:calc(16px + var(--safe-area-inset-bottom));inset-inline-end:calc(16px + var(--safe-area-inset-right));inset-inline-start:initial;z-index:1;--ha-button-box-shadow:var(--ha-box-shadow-l)}@media (max-width:500px){.column>*{margin-left:0;margin-right:0}}@media (max-width:599px){.column{max-width:600px}}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],y.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],y.prototype,"lovelace",void 0),(0,s.Cg)([(0,o.MZ)({type:Boolean})],y.prototype,"narrow",void 0),(0,s.Cg)([(0,o.MZ)({type:Number})],y.prototype,"index",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],y.prototype,"isStrategy",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],y.prototype,"cards",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],y.prototype,"badges",void 0),(0,s.Cg)([(0,o.wk)()],y.prototype,"_columns",void 0),y=(0,s.Cg)([(0,o.EM)("hui-masonry-view")],y),t()}catch(p){t(p)}})},77985:function(e,t,i){i(74423),i(49255);var s=i(40445),a=i(5124),o=i(67576),n=i(17022);let d;class r extends a.WF{render(){return a.s6}_fetchMedia(){var e,t;const i="string"==typeof this.background?this.background:"object"==typeof(null===(e=this.background)||void 0===e?void 0:e.image)?this.background.image.media_content_id:null===(t=this.background)||void 0===t?void 0:t.image;i&&(0,n.St)(i)?(0,n.A1)(this.hass,i).then(e=>{this.resolvedImage=e.url}):this.resolvedImage=void 0}_applyTheme(){const e=getComputedStyle(this).getPropertyValue("--lovelace-background"),t=this._isFixedBackground(this.background||e),i=this._computeBackgroundProperty(this.background);this.toggleAttribute("fixed-background",t),this.style.setProperty("--view-background",i);const s=this._computeBackgroundOpacityProperty(this.background);this.style.setProperty("--view-background-opacity",s)}_isFixedBackground(e){return"string"==typeof e?e.split(" ").includes("fixed"):"object"==typeof e&&"fixed"===e.attachment}_computeBackgroundProperty(e){if("object"==typeof e&&e.image){var t,i,s;const a="object"==typeof e.image?e.image.media_content_id||"":e.image;if((0,n.St)(a)&&!this.resolvedImage)return null;return`${null!==(t=e.alignment)&&void 0!==t?t:"center"} / ${null!==(i=e.size)&&void 0!==i?i:"cover"} ${null!==(s=e.repeat)&&void 0!==s?s:"no-repeat"} url('${this.hass.hassUrl(this.resolvedImage||a)}')`}return"string"==typeof e?(0,n.St)(e)&&!this.resolvedImage?null:this.resolvedImage||e:null}_computeBackgroundOpacityProperty(e){return"object"==typeof e&&e.image&&e.opacity?`${e.opacity}%`:null}willUpdate(e){super.willUpdate(e);let t=!1;if(e.has("hass")&&this.hass){const i=e.get("hass");i&&this.hass.themes===i.themes&&this.hass.selectedTheme===i.selectedTheme||(t=!0)}e.has("background")&&(t=!0,this._fetchMedia()),e.has("resolvedImage")&&(t=!0),t&&this._applyTheme()}}r.styles=(0,a.AH)(d||(d=(e=>e)`:host([fixed-background]){display:block;z-index:-1;position:fixed;background-attachment:scroll!important}:host(:not([fixed-background])){z-index:-1;position:absolute}:host{top:0;left:0;right:0;bottom:0;height:100%;width:100%;background:var(--view-background,var(--lovelace-background,var(--primary-background-color)));opacity:var(--view-background-opacity)}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],r.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],r.prototype,"background",void 0),(0,s.Cg)([(0,o.wk)({attribute:!1})],r.prototype,"resolvedImage",void 0),r=(0,s.Cg)([(0,o.EM)("hui-view-background")],r)},87778:function(e,t,i){var s=i(40445),a=i(5124),o=i(67576),n=i(42372),d=i(71769);let r,l,h=e=>e;class c extends a.WF{connectedCallback(){super.connectedCallback(),this._setUpMediaQuery(),this._applyTheme()}disconnectedCallback(){super.disconnectedCallback(),this._clearmediaQuery()}_clearmediaQuery(){this._unsubMediaQuery&&(this._unsubMediaQuery(),this._unsubMediaQuery=void 0)}_setUpMediaQuery(){this._unsubMediaQuery=(0,d.m)("(prefers-color-scheme: dark)",this._applyTheme.bind(this))}willUpdate(e){if(super.willUpdate(e),e.has("hass")&&this.hass){const t=e.get("hass");if(!t||this.hass.themes!==t.themes||this.hass.selectedTheme!==t.selectedTheme)return void this._applyTheme()}e.has("theme")&&this._applyTheme()}render(){return(0,a.qy)(r||(r=h`<slot></slot>`))}_applyTheme(){var e;this.hass&&(0,n.Q)(this,null===(e=this.hass)||void 0===e?void 0:e.themes,this.theme)}}c.styles=(0,a.AH)(l||(l=h`:host{display:relative}`)),(0,s.Cg)([(0,o.MZ)({attribute:!1})],c.prototype,"hass",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],c.prototype,"background",void 0),(0,s.Cg)([(0,o.MZ)({attribute:!1})],c.prototype,"theme",void 0),(0,s.Cg)([(0,o.wk)()],c.prototype,"themeBackground",void 0),c=(0,s.Cg)([(0,o.EM)("hui-view-container")],c)},75400:function(e,t,i){i.a(e,async function(e,t){try{i(18111),i(7588),i(61701),i(3362),i(62953);var s=i(40445),a=i(34271),o=i(5124),n=i(67576),d=i(93905),r=i(9899),l=i(19459),h=i(58234),c=(i(67094),i(84970)),g=i(91984),p=i(43908),u=i(46856),v=i(15414),m=i(42124),b=i(63023),_=i(21146),y=i(15950),f=i(82360),C=i(61511),w=i(90565),x=i(75196),E=i(19959),k=i(26004),M=i(15656),A=i(36751),$=e([h,p,u,k,v]);[h,p,u,k,v]=$.then?(await $)():$;class L extends o.mN{_createCardElement(e){const t=document.createElement("hui-card");return t.hass=this.hass,t.preview=this.lovelace.editMode,t.config=e,t.addEventListener("card-updated",e=>{e.stopPropagation(),this._cards=[...this._cards]}),t.load(),t}createBadgeElement(e){const t=document.createElement("hui-badge");return t.hass=this.hass,t.preview=this.lovelace.editMode,t.config=e,t.addEventListener("badge-updated",e=>{e.stopPropagation(),this._badges=[...this._badges]}),t.load(),t}createSectionElement(e){const t=document.createElement("hui-section");return t.hass=this.hass,t.lovelace=this.lovelace,t.config=e,t.viewIndex=this.index,t.preview=this.lovelace.editMode,t.addEventListener("ll-rebuild",i=>{i.stopPropagation(),this._rebuildSection(t,e)},{once:!0}),t}createRenderRoot(){return this}willUpdate(e){super.willUpdate(e);const t=e.get("lovelace");if(e.has("index")||e.has("lovelace")&&(!t||this.lovelace.config.views[this.index]!==t.config.views[this.index]))return void this._initializeConfig();if(!e.has("hass"))return;const i=e.get("hass"),s=this.lovelace.config.views[this.index];i&&this.hass&&this.lovelace&&(0,g.R6)(s)&&("RUNNING"!==this.hass.config.state||i.entities===this.hass.entities&&i.devices===this.hass.devices&&i.areas===this.hass.areas&&i.floors===this.hass.floors||this._debounceRefreshConfig())}update(e){super.update(e),this._layoutElement&&(e.has("hass")&&(this._badges.forEach(e=>{e.hass=this.hass}),this._cards.forEach(e=>{e.hass=this.hass}),this._sections.forEach(e=>{try{e.hass=this.hass}catch(t){this._rebuildSection(e,(0,E.I)(t.message))}}),this._layoutElement.hass=this.hass),e.has("narrow")&&(this._layoutElement.narrow=this.narrow),e.has("lovelace")&&(this._layoutElement.lovelace=this.lovelace,this._sections.forEach(e=>{try{e.hass=this.hass,e.lovelace=this.lovelace,e.preview=this.lovelace.editMode}catch(t){this._rebuildSection(e,(0,E.I)(t.message))}}),this._cards.forEach(e=>{e.preview=this.lovelace.editMode}),this._badges.forEach(e=>{e.preview=this.lovelace.editMode})),e.has("_cards")&&(this._layoutElement.cards=this._cards),e.has("_badges")&&(this._layoutElement.badges=this._badges))}async _generateConfig(e){if((0,g.R6)(e)){const t=await(0,M.Xd)(e,this.hass);return Object.assign(Object.assign({},t),{},{type:(0,A.E)(t)})}return Object.assign(Object.assign({},e),{},{type:(0,A.E)(e)})}_setConfig(e,t){if(t&&(0,l.b)(e,this._config))return;this._config=e;let i=!1;if(this._layoutElement&&this._layoutElementType===e.type?this._layoutElement.setConfig(e):(i=!0,this._createLayoutElement(e)),this._createBadges(e),this._createCards(e),this._createSections(e),this._layoutElement.isStrategy=t,this._layoutElement.hass=this.hass,this._layoutElement.narrow=this.narrow,this._layoutElement.lovelace=this.lovelace,this._layoutElement.index=this.index,this._layoutElement.cards=this._cards,this._layoutElement.badges=this._badges,this._layoutElement.sections=this._sections,i){for(;this.lastChild;)this.removeChild(this.lastChild);this.appendChild(this._layoutElement)}}async _initializeConfig(){const e=this.lovelace.config.views[this.index],t=(0,g.R6)(e),i=await this._generateConfig(e);this._setConfig(i,t)}_createLayoutElement(e){this._layoutElement=(0,v._)(e),this._layoutElementType=e.type,this._layoutElement.addEventListener("ll-rebuild",e=>{e.stopPropagation(),this._layoutElementType=void 0,this._initializeConfig()},{once:!0}),this._layoutElement.addEventListener("ll-create-card",e=>{var t;(0,_.u)(this,{lovelaceConfig:this.lovelace.config,saveConfig:this.lovelace.saveConfig,path:[this.index],suggestedCards:null===(t=e.detail)||void 0===t?void 0:t.suggested})}),this._layoutElement.addEventListener("ll-edit-card",e=>{const{cardIndex:t}=(0,x.gO)(e.detail.path),i=this.lovelace.config.views[this.index];if((0,g.R6)(i))return;const s=i.cards[t];(0,y.O)(this,{lovelaceConfig:this.lovelace.config,saveCardConfig:async e=>{const i=(0,f.bn)(this.lovelace.config,[this.index,t],e);await this.lovelace.saveConfig(i)},cardConfig:s})}),this._layoutElement.addEventListener("ll-delete-card",e=>{this.lovelace&&(0,w.r)(this.hass,this.lovelace,e.detail)}),this._layoutElement.addEventListener("ll-create-badge",async()=>{(0,m.d)(this,{lovelaceConfig:this.lovelace.config,saveConfig:this.lovelace.saveConfig,path:[this.index]})}),this._layoutElement.addEventListener("ll-edit-badge",e=>{const{cardIndex:t}=(0,x.gO)(e.detail.path);(0,b.N)(this,{lovelaceConfig:this.lovelace.config,saveConfig:this.lovelace.saveConfig,path:[this.index],badgeIndex:t})}),this._layoutElement.addEventListener("ll-delete-badge",async e=>{this.lovelace&&(0,C.a)(this.hass,this.lovelace,e.detail)}),this._layoutElement.addEventListener("ll-duplicate-card",e=>{const{cardIndex:t}=(0,x.gO)(e.detail.path),i=this.lovelace.config.views[this.index];if((0,g.R6)(i))return;const s=i.cards[t];(0,y.O)(this,{lovelaceConfig:this.lovelace.config,saveCardConfig:async e=>{const t=(0,f.gm)(this.lovelace.config,[this.index],e);await this.lovelace.saveConfig(t)},cardConfig:s,isNew:!0})}),this._layoutElement.addEventListener("ll-copy-card",e=>{if(!this.lovelace)return;const{cardIndex:t}=(0,x.gO)(e.detail.path),i=this.lovelace.config.views[this.index];if((0,g.R6)(i))return;const s=i.cards[t];this._clipboard=(0,a.A)(s)})}_createBadges(e){e&&e.badges&&Array.isArray(e.badges)?this._badges=e.badges.map(e=>{const t=(0,c.q)(e);return this.createBadgeElement(t)}):this._badges=[]}_createCards(e){e&&e.cards&&Array.isArray(e.cards)?this._cards=e.cards.map(e=>this._createCardElement(e)):this._cards=[]}_createSections(e){e&&e.sections&&Array.isArray(e.sections)?this._sections=e.sections.map((e,t)=>{const i=this.createSectionElement(e);return i.index=t,i}):this._sections=[]}_rebuildSection(e,t){const i=this.createSectionElement(t);i.index=e.index,e.parentElement&&e.parentElement.replaceChild(i,e),this._sections=this._sections.map(t=>t===e?i:t)}constructor(...e){super(...e),this.narrow=!1,this._cards=[],this._badges=[],this._sections=[],this._debounceRefreshConfig=(0,r.s)(()=>this._initializeConfig(),200)}}(0,s.Cg)([(0,n.MZ)({attribute:!1})],L.prototype,"hass",void 0),(0,s.Cg)([(0,n.MZ)({attribute:!1})],L.prototype,"lovelace",void 0),(0,s.Cg)([(0,n.MZ)({type:Boolean})],L.prototype,"narrow",void 0),(0,s.Cg)([(0,n.MZ)({type:Number})],L.prototype,"index",void 0),(0,s.Cg)([(0,n.wk)()],L.prototype,"_cards",void 0),(0,s.Cg)([(0,n.wk)()],L.prototype,"_badges",void 0),(0,s.Cg)([(0,n.wk)()],L.prototype,"_sections",void 0),(0,s.Cg)([(0,d.I)({key:"dashboardCardClipboard",state:!1,subscribe:!1,storage:"sessionStorage"})],L.prototype,"_clipboard",void 0),L=(0,s.Cg)([(0,n.EM)("hui-view")],L),t()}catch(L){t(L)}})}}]);