diff --git a/card-mod.js b/card-mod.js
index b888f61..2d43bc7 100644
--- a/card-mod.js
+++ b/card-mod.js
@@ -1,6 +1,6 @@
-function t(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}function e(t,e,o,s){var i,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,s);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(n<3?i(r):n>3?i(e,o,r):i(e,o))||r);return n>3&&r&&Object.defineProperty(e,o,r),r}const o=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new Map;class n{constructor(t,e){if(this._$cssResult$=!0,e!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=i.get(this.cssText);return o&&void 0===t&&(i.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const r=o?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const o of t.cssRules)e+=o.cssText;return(t=>new n("string"==typeof t?t:t+"",s))(e)})(t):t;var a;const d=window.reactiveElementPolyfillSupport,l={toAttribute(t,e){switch(e){case Boolean:t=t?"":null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let o=t;switch(e){case Boolean:o=null!==t;break;case Number:o=null===t?null:Number(t);break;case Object:case Array:try{o=JSON.parse(t)}catch(t){o=null}}return o}},c=(t,e)=>e!==t&&(e==e||t==t),h={attribute:!0,type:String,converter:l,reflect:!1,hasChanged:c};class u extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,o)=>{const s=this._$Eh(o,e);void 0!==s&&(this._$Eu.set(s,o),t.push(s))})),t}static createProperty(t,e=h){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const o="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,o,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,o){return{get(){return this[e]},set(s){const i=this[t];this[e]=s,this.requestUpdate(t,i,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||h}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const o of e)this.createProperty(o,t[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const o=new Set(t.flat(1/0).reverse());for(const t of o)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eh(t,e){const o=e.attribute;return!1===o?void 0:"string"==typeof o?o:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ev=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Ep(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,o;(null!==(e=this._$Em)&&void 0!==e?e:this._$Em=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(o=t.hostConnected)||void 0===o||o.call(t))}removeController(t){var e;null===(e=this._$Em)||void 0===e||e.splice(this._$Em.indexOf(t)>>>0,1)}_$Ep(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{o?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const o=document.createElement("style"),s=window.litNonce;void 0!==s&&o.setAttribute("nonce",s),o.textContent=e.cssText,t.appendChild(o)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,o){this._$AK(t,o)}_$Eg(t,e,o=h){var s,i;const n=this.constructor._$Eh(t,o);if(void 0!==n&&!0===o.reflect){const r=(null!==(i=null===(s=o.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==i?i:l.toAttribute)(e,o.type);this._$Ei=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Ei=null}}_$AK(t,e){var o,s,i;const n=this.constructor,r=n._$Eu.get(t);if(void 0!==r&&this._$Ei!==r){const t=n.getPropertyOptions(r),a=t.converter,d=null!==(i=null!==(s=null===(o=a)||void 0===o?void 0:o.fromAttribute)&&void 0!==s?s:"function"==typeof a?a:null)&&void 0!==i?i:l.fromAttribute;this._$Ei=r,this[r]=d(e,t.type),this._$Ei=null}}requestUpdate(t,e,o){let s=!0;void 0!==t&&(((o=o||this.constructor.getPropertyOptions(t)).hasChanged||c)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===o.reflect&&this._$Ei!==t&&(void 0===this._$ES&&(this._$ES=new Map),this._$ES.set(t,o))):s=!1),!this.isUpdatePending&&s&&(this._$Ev=this._$EC())}async _$EC(){this.isUpdatePending=!0;try{await this._$Ev}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const o=this._$AL;try{e=this.shouldUpdate(o),e?(this.willUpdate(o),null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(o)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(o)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Em)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ev}shouldUpdate(t){return!0}update(t){void 0!==this._$ES&&(this._$ES.forEach(((t,e)=>this._$Eg(e,this[e],t))),this._$ES=void 0),this._$EU()}updated(t){}firstUpdated(t){}}var p;u.finalized=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:u}),(null!==(a=globalThis.reactiveElementVersions)&&void 0!==a?a:globalThis.reactiveElementVersions=[]).push("1.0.1");const m=globalThis.trustedTypes,f=m?m.createPolicy("lit-html",{createHTML:t=>t}):void 0,v=`lit$${(Math.random()+"").slice(9)}$`,y="?"+v,_=`<${y}>`,g=document,$=(t="")=>g.createComment(t),w=t=>null===t||"object"!=typeof t&&"function"!=typeof t,b=Array.isArray,E=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,A=/-->/g,S=/>/g,C=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,U=/'/g,N=/"/g,P=/^(?:script|style|textarea)$/i,M=(t=>(e,...o)=>({_$litType$:t,strings:e,values:o}))(1),R=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),x=new WeakMap,O=g.createTreeWalker(g,129,null,!1),T=(t,e)=>{const o=t.length-1,s=[];let i,n=2===e?"":"");return[void 0!==f?f.createHTML(a):a,s]};class k{constructor({strings:t,_$litType$:e},o){let s;this.parts=[];let i=0,n=0;const r=t.length-1,a=this.parts,[d,l]=T(t,e);if(this.el=k.createElement(d,o),O.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=O.nextNode())&&a.length0){s.textContent=m?m.emptyScript:"";for(let o=0;o{var e;return b(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(t)?this.M(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}S(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==D&&w(this._$AH)?this._$AA.nextSibling.data=t:this.S(g.createTextNode(t)),this._$AH=t}T(t){var e;const{values:o,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=k.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.m(o);else{const t=new L(i,this),e=t.p(this.options);t.m(o),this.S(e),this._$AH=t}}_$AC(t){let e=x.get(t.strings);return void 0===e&&x.set(t.strings,e=new k(t)),e}M(t){b(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let o,s=0;for(const i of t)s===e.length?e.push(o=new q(this.A($()),this.A($()),this,this.options)):o=e[s],o._$AI(i),s++;s2||""!==o[0]||""!==o[1]?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,o,s){const i=this.strings;let n=!1;if(void 0===i)t=H(this,t,e,0),n=!w(t)||t!==this._$AH&&t!==R,n&&(this._$AH=t);else{const s=t;let r,a;for(t=i[0],r=0;r{var s,i;const n=null!==(s=null==o?void 0:o.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(i=null==o?void 0:o.renderBefore)&&void 0!==i?i:null;n._$litPart$=r=new q(e.insertBefore($(),t),t,void 0,null!=o?o:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return R}}Y.finalized=!0,Y._$litElement$=!0,null===(W=globalThis.litElementHydrateSupport)||void 0===W||W.call(globalThis,{LitElement:Y});const Z=globalThis.litElementPolyfillSupport;null==Z||Z({LitElement:Y}),(null!==(K=globalThis.litElementVersions)&&void 0!==K?K:globalThis.litElementVersions=[]).push("3.0.1");const F=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(o){o.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(o){o.createProperty(e.key,t)}};function G(t){return(e,o)=>void 0!==o?((t,e,o)=>{e.constructor.createProperty(o,t)})(t,e,o):F(t,e)}const Q="lovelace-player-device-id";function X(){if(!localStorage[Q]){const t=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);window.fully&&"function"==typeof fully.getDeviceId?localStorage[Q]=fully.getDeviceId():localStorage[Q]=`${t()}${t()}-${t()}${t()}`}return localStorage[Q]}let tt=X();const et=new URLSearchParams(window.location.search);var ot;et.get("deviceID")&&null!==(ot=et.get("deviceID"))&&("clear"===ot?localStorage.removeItem(Q):localStorage[Q]=ot,tt=X()),window.cardMod_template_cache=window.cardMod_template_cache||{};const st=window.cardMod_template_cache;async function it(e,o,s){const i=t().connection,n=JSON.stringify([o,s]);let r=st[n];r?(r.callbacks.has(e)||nt(e),e(r.value),r.callbacks.add(e)):(nt(e),e(""),s=Object.assign({user:t().user.name,browser:tt,hash:location.hash.substr(1)||""},s),st[n]=r={template:o,variables:s,value:"",callbacks:new Set([e]),unsubscribe:i.subscribeMessage((t=>function(t,e){const o=st[t];o&&(o.value=e.result,o.callbacks.forEach((t=>t(e.result))))}(n,t)),{type:"render_template",template:o,variables:s})})}async function nt(t){let e;for(const[o,s]of Object.entries(st))if(s.callbacks.has(t)){s.callbacks.delete(t),0==s.callbacks.size&&(e=s.unsubscribe,delete st[o]);break}e&&await(await e)()}var rt="3.1.2";async function at(t,e,o=!1){let s=t;"string"==typeof e&&(e=e.split(/(\$| )/)),""===e[e.length-1]&&e.pop();for(const[t,i]of e.entries())if(i.trim().length){if(!s)return null;s.localName&&s.localName.includes("-")&&await customElements.whenDefined(s.localName),s.updateComplete&&await s.updateComplete,s="$"===i?o&&t==e.length-1?[s.shadowRoot]:s.shadowRoot:o&&t==e.length-1?s.querySelectorAll(i):s.querySelector(i)}return s}async function dt(t,e,o=!1,s=1e4){return Promise.race([at(t,e,o),new Promise(((t,e)=>setTimeout((()=>e(new Error("timeout"))),s)))]).catch((t=>{if(!t.message||"timeout"!==t.message)throw t;return null}))}const lt=async t=>{await(async()=>{if(customElements.get("developer-tools-event"))return;await customElements.whenDefined("partial-panel-resolver");const t=document.createElement("partial-panel-resolver");t.hass={panels:[{url_path:"tmp",component_name:"developer-tools"}]},t._updateRoutes(),await t.routerOptions.routes.tmp.load(),await customElements.whenDefined("developer-tools-router");const e=document.createElement("developer-tools-router");await e.routerOptions.routes.event.load()})();return document.createElement("developer-tools-event")._computeParsedEventData(t)};async function ct(t,e,o="",s={},i=null,n=!0){var r;if(!t)return;let a;(null===(r=t.localName)||void 0===r?void 0:r.includes("-"))&&await customElements.whenDefined(t.localName),t.updateComplete&&await t.updateComplete,void 0===t._cardMod&&(t._cardMod=[]);for(const o of t._cardMod)if(o.type===e){a=o;break}return a||(a=document.createElement("card-mod"),a.type=e,t._cardMod.push(a)),queueMicrotask((async()=>{(t.modElement?t.modElement:n&&t.shadowRoot||t).appendChild(a),a.variables=s,a.styles=o})),a}function ht(t,e){const o=t=>t&&"object"==typeof t&&!Array.isArray(t);if(o(t)&&o(e))for(const s in e)o(e[s])?(t[s]||Object.assign(t,{[s]:{}}),"string"==typeof t[s]&&(t[s]={".":t[s]}),ht(t[s],e[s])):t[s]?t[s]=e[s]+t[s]:t[s]=e[s];return t}function ut(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(!(t instanceof Object&&e instanceof Object))return!1;for(const o in t)if(t.hasOwnProperty(o)){if(!e.hasOwnProperty(o))return!1;if(t[o]!==e[o]){if("object"!=typeof t[o])return!1;if(!ut(t[o],e[o]))return!1}}for(const o in e)if(e.hasOwnProperty(o)&&!t.hasOwnProperty(o))return!1;return!0}function pt(t){return t.config?t.config:t._config?t._config:t.host?pt(t.host):t.parentElement?pt(t.parentElement):t.parentNode?pt(t.parentNode):null}function mt(t,e){for(const o of e)t.add(o)}async function ft(t,e=0){let o=new Set;if(10==e)return o;if(!t)return o;if(t._cardMod)for(const e of t._cardMod)e.styles&&o.add(e);return t.updateComplete&&await t.updateComplete,t.parentElement?mt(o,await ft(t.parentElement,e+1)):t.parentNode&&mt(o,await ft(t.parentNode,e+1)),t.host&&mt(o,await ft(t.host,e+1)),o}function vt(){var t,e,o;const s=document.querySelectorAll("script"),i=[];for(const n of s)if(null===(e=null===(t=null==n?void 0:n.innerText)||void 0===t?void 0:t.trim())||void 0===e?void 0:e.startsWith("import(")){const t=null===(o=n.innerText.split("\n"))||void 0===o?void 0:o.map((t=>t.trim()));for(const e of t)i.push(e.replace(/^import\(\"/,"").replace(/\"\);/,""))}return i}class yt extends Y{constructor(){super(),this._rendered_styles="",this._styleChildren=new Set,this._observer=new MutationObserver((t=>{for(const e of t){if("card-mod"===e.target.localName)return;let t=!0;if(e.addedNodes.length&&e.addedNodes.forEach((e=>{"card-mod"!==e.localName&&(t=!1)})),t)return;if(t=!0,e.removedNodes.length&&e.removedNodes.forEach((e=>{"card-mod"!==e.localName&&(t=!1)})),t)return}this.refresh()})),document.addEventListener("cm_update",(()=>{this.refresh()}))}static get applyToElement(){return ct}connectedCallback(){super.connectedCallback(),this._connect(),this.setAttribute("slot","none")}disconnectedCallback(){super.disconnectedCallback(),this._disconnect()}set styles(e){ut(e,this._input_styles)||(this._input_styles=e,(async()=>{let o=JSON.parse(JSON.stringify(e||{}));"string"==typeof o&&(o={".":o});ht(o,await async function(e){var o,s;if(!e.type)return null;const i=e.parentElement?e.parentElement:e,n=window.getComputedStyle(i).getPropertyValue("--card-mod-theme");if(!t())return{};const r=null!==(s=null===(o=t())||void 0===o?void 0:o.themes.themes)&&void 0!==s?s:{};return r[n]?r[n][`card-mod-${e.type}-yaml`]?lt(r[n][`card-mod-${e.type}-yaml`]):r[n][`card-mod-${e.type}`]?{".":r[n][`card-mod-${e.type}`]}:{}:{}}(this)),this._fixed_styles=o,this._connect()})())}get styles(){return this._styles}refresh(){this._connect()}async _styleChildEl(t,e){if(void 0===e){const o=this._fixed_styles;for(const[s,i]of Object.entries(o)){if("."===s)continue;if((await dt(this.parentElement||this.parentNode,s,!0)).forEach((o=>{o===t&&(e=i)})),void 0!==e)break}if(void 0===e)return}if(!t)return;const o=await ct(t,`${this.type}-child`,e,this.variables,null,!1);return o.refresh,o}async _connect(){var t;const e=null!==(t=this._fixed_styles)&&void 0!==t?t:{},o=new Set;let s="",i=!1;const n=this.parentElement||this.parentNode;for(const[t,r]of Object.entries(e))if("."===t)s=r;else{i=!0;const e=await dt(n,t,!0);if(!e)continue;for(const t of e){const e=await this._styleChildEl(t,r);e&&o.add(e)}}for(const t of this._styleChildren)o.has(t)||t&&(t.styles="");var r;(this._styleChildren=o,this._styles!==s)&&(this._styles=s,this._styles&&(r=this._styles,String(r).includes("{%")||String(r).includes("{{"))?(this._renderer=this._renderer||this._style_rendered.bind(this),it(this._renderer,this._styles,this.variables)):this._style_rendered(this._styles||""),i&&this._observer.observe(function(t){if(!t)return;const e=t.parentElement||t.parentNode;return e?e.host?e.host:e:void 0}(this),{childList:!0}))}async _disconnect(){this._observer.disconnect(),this._styles="",await nt(this._renderer)}_style_rendered(t){this._rendered_styles=t,this.dispatchEvent(new Event("card-mod-update"))}createRenderRoot(){return this}render(){return M`
+function t(){return document.querySelector("hc-main")?document.querySelector("hc-main").hass:document.querySelector("home-assistant")?document.querySelector("home-assistant").hass:void 0}function e(t,e,o,s){var i,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,o,s);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(r=(n<3?i(r):n>3?i(e,o,r):i(e,o))||r);return n>3&&r&&Object.defineProperty(e,o,r),r}const o=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),i=new Map;class n{constructor(t,e){if(this._$cssResult$=!0,e!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){let t=i.get(this.cssText);return o&&void 0===t&&(i.set(this.cssText,t=new CSSStyleSheet),t.replaceSync(this.cssText)),t}toString(){return this.cssText}}const r=o?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const o of t.cssRules)e+=o.cssText;return(t=>new n("string"==typeof t?t:t+"",s))(e)})(t):t;var a;const d=window.reactiveElementPolyfillSupport,l={toAttribute(t,e){switch(e){case Boolean:t=t?"":null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let o=t;switch(e){case Boolean:o=null!==t;break;case Number:o=null===t?null:Number(t);break;case Object:case Array:try{o=JSON.parse(t)}catch(t){o=null}}return o}},c=(t,e)=>e!==t&&(e==e||t==t),h={attribute:!0,type:String,converter:l,reflect:!1,hasChanged:c};class u extends HTMLElement{constructor(){super(),this._$Et=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Ei=null,this.o()}static addInitializer(t){var e;null!==(e=this.l)&&void 0!==e||(this.l=[]),this.l.push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,o)=>{const s=this._$Eh(o,e);void 0!==s&&(this._$Eu.set(s,o),t.push(s))})),t}static createProperty(t,e=h){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){const o="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,o,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}}static getPropertyDescriptor(t,e,o){return{get(){return this[e]},set(s){const i=this[t];this[e]=s,this.requestUpdate(t,i,o)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||h}static finalize(){if(this.hasOwnProperty("finalized"))return!1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Eu=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const o of e)this.createProperty(o,t[o])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const o=new Set(t.flat(1/0).reverse());for(const t of o)e.unshift(r(t))}else void 0!==t&&e.push(r(t));return e}static _$Eh(t,e){const o=e.attribute;return!1===o?void 0:"string"==typeof o?o:"string"==typeof t?t.toLowerCase():void 0}o(){var t;this._$Ev=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Ep(),this.requestUpdate(),null===(t=this.constructor.l)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,o;(null!==(e=this._$Em)&&void 0!==e?e:this._$Em=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(o=t.hostConnected)||void 0===o||o.call(t))}removeController(t){var e;null===(e=this._$Em)||void 0===e||e.splice(this._$Em.indexOf(t)>>>0,1)}_$Ep(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Et.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return((t,e)=>{o?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const o=document.createElement("style"),s=window.litNonce;void 0!==s&&o.setAttribute("nonce",s),o.textContent=e.cssText,t.appendChild(o)}))})(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,o){this._$AK(t,o)}_$Eg(t,e,o=h){var s,i;const n=this.constructor._$Eh(t,o);if(void 0!==n&&!0===o.reflect){const r=(null!==(i=null===(s=o.converter)||void 0===s?void 0:s.toAttribute)&&void 0!==i?i:l.toAttribute)(e,o.type);this._$Ei=t,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$Ei=null}}_$AK(t,e){var o,s,i;const n=this.constructor,r=n._$Eu.get(t);if(void 0!==r&&this._$Ei!==r){const t=n.getPropertyOptions(r),a=t.converter,d=null!==(i=null!==(s=null===(o=a)||void 0===o?void 0:o.fromAttribute)&&void 0!==s?s:"function"==typeof a?a:null)&&void 0!==i?i:l.fromAttribute;this._$Ei=r,this[r]=d(e,t.type),this._$Ei=null}}requestUpdate(t,e,o){let s=!0;void 0!==t&&(((o=o||this.constructor.getPropertyOptions(t)).hasChanged||c)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===o.reflect&&this._$Ei!==t&&(void 0===this._$ES&&(this._$ES=new Map),this._$ES.set(t,o))):s=!1),!this.isUpdatePending&&s&&(this._$Ev=this._$EC())}async _$EC(){this.isUpdatePending=!0;try{await this._$Ev}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Et&&(this._$Et.forEach(((t,e)=>this[e]=t)),this._$Et=void 0);let e=!1;const o=this._$AL;try{e=this.shouldUpdate(o),e?(this.willUpdate(o),null===(t=this._$Em)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(o)):this._$EU()}catch(t){throw e=!1,this._$EU(),t}e&&this._$AE(o)}willUpdate(t){}_$AE(t){var e;null===(e=this._$Em)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$Ev}shouldUpdate(t){return!0}update(t){void 0!==this._$ES&&(this._$ES.forEach(((t,e)=>this._$Eg(e,this[e],t))),this._$ES=void 0),this._$EU()}updated(t){}firstUpdated(t){}}var p;u.finalized=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==d||d({ReactiveElement:u}),(null!==(a=globalThis.reactiveElementVersions)&&void 0!==a?a:globalThis.reactiveElementVersions=[]).push("1.0.1");const m=globalThis.trustedTypes,f=m?m.createPolicy("lit-html",{createHTML:t=>t}):void 0,v=`lit$${(Math.random()+"").slice(9)}$`,y="?"+v,_=`<${y}>`,g=document,w=(t="")=>g.createComment(t),$=t=>null===t||"object"!=typeof t&&"function"!=typeof t,E=Array.isArray,b=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,A=/-->/g,S=/>/g,C=/>|[ \n\r](?:([^\s"'>=/]+)([ \n\r]*=[ \n\r]*(?:[^ \n\r"'`<>=]|("|')|))|$)/g,U=/'/g,N=/"/g,P=/^(?:script|style|textarea)$/i,M=(t=>(e,...o)=>({_$litType$:t,strings:e,values:o}))(1),R=Symbol.for("lit-noChange"),D=Symbol.for("lit-nothing"),x=new WeakMap,O=g.createTreeWalker(g,129,null,!1),T=(t,e)=>{const o=t.length-1,s=[];let i,n=2===e?"":"");return[void 0!==f?f.createHTML(a):a,s]};class k{constructor({strings:t,_$litType$:e},o){let s;this.parts=[];let i=0,n=0;const r=t.length-1,a=this.parts,[d,l]=T(t,e);if(this.el=k.createElement(d,o),O.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=O.nextNode())&&a.length0){s.textContent=m?m.emptyScript:"";for(let o=0;o{var e;return E(t)||"function"==typeof(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])})(t)?this.M(t):this.$(t)}A(t,e=this._$AB){return this._$AA.parentNode.insertBefore(t,e)}S(t){this._$AH!==t&&(this._$AR(),this._$AH=this.A(t))}$(t){this._$AH!==D&&$(this._$AH)?this._$AA.nextSibling.data=t:this.S(g.createTextNode(t)),this._$AH=t}T(t){var e;const{values:o,_$litType$:s}=t,i="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=k.createElement(s.h,this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===i)this._$AH.m(o);else{const t=new L(i,this),e=t.p(this.options);t.m(o),this.S(e),this._$AH=t}}_$AC(t){let e=x.get(t.strings);return void 0===e&&x.set(t.strings,e=new k(t)),e}M(t){E(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let o,s=0;for(const i of t)s===e.length?e.push(o=new q(this.A(w()),this.A(w()),this,this.options)):o=e[s],o._$AI(i),s++;s2||""!==o[0]||""!==o[1]?(this._$AH=Array(o.length-1).fill(new String),this.strings=o):this._$AH=D}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,o,s){const i=this.strings;let n=!1;if(void 0===i)t=H(this,t,e,0),n=!$(t)||t!==this._$AH&&t!==R,n&&(this._$AH=t);else{const s=t;let r,a;for(t=i[0],r=0;r{var s,i;const n=null!==(s=null==o?void 0:o.renderBefore)&&void 0!==s?s:e;let r=n._$litPart$;if(void 0===r){const t=null!==(i=null==o?void 0:o.renderBefore)&&void 0!==i?i:null;n._$litPart$=r=new q(e.insertBefore(w(),t),t,void 0,null!=o?o:{})}return r._$AI(t),r})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Dt)||void 0===t||t.setConnected(!1)}render(){return R}}Y.finalized=!0,Y._$litElement$=!0,null===(W=globalThis.litElementHydrateSupport)||void 0===W||W.call(globalThis,{LitElement:Y});const Z=globalThis.litElementPolyfillSupport;null==Z||Z({LitElement:Y}),(null!==(K=globalThis.litElementVersions)&&void 0!==K?K:globalThis.litElementVersions=[]).push("3.0.1");const F=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(o){o.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(o){o.createProperty(e.key,t)}};function G(t){return(e,o)=>void 0!==o?((t,e,o)=>{e.constructor.createProperty(o,t)})(t,e,o):F(t,e)}const Q="lovelace-player-device-id";function X(){if(!localStorage[Q]){const t=()=>Math.floor(1e5*(1+Math.random())).toString(16).substring(1);window.fully&&"function"==typeof fully.getDeviceId?localStorage[Q]=fully.getDeviceId():localStorage[Q]=`${t()}${t()}-${t()}${t()}`}return localStorage[Q]}let tt=X();const et=new URLSearchParams(window.location.search);var ot;et.get("deviceID")&&null!==(ot=et.get("deviceID"))&&("clear"===ot?localStorage.removeItem(Q):localStorage[Q]=ot,tt=X()),window.cardMod_template_cache=window.cardMod_template_cache||{};const st=window.cardMod_template_cache;async function it(e,o,s){const i=t().connection,n=JSON.stringify([o,s]);let r=st[n];r?(r.callbacks.has(e)||nt(e),e(r.value),r.callbacks.add(e)):(nt(e),e(""),s=Object.assign({user:t().user.name,browser:tt,hash:location.hash.substr(1)||""},s),st[n]=r={template:o,variables:s,value:"",callbacks:new Set([e]),unsubscribe:i.subscribeMessage((t=>function(t,e){const o=st[t];o&&(o.value=e.result,o.callbacks.forEach((t=>t(e.result))))}(n,t)),{type:"render_template",template:o,variables:s})})}async function nt(t){let e;for(const[o,s]of Object.entries(st))if(s.callbacks.has(t)){s.callbacks.delete(t),0==s.callbacks.size&&(e=s.unsubscribe,delete st[o]);break}e&&await(await e)()}var rt="3.1.3";async function at(t,e,o=!1){let s=t;"string"==typeof e&&(e=e.split(/(\$| )/)),""===e[e.length-1]&&e.pop();for(const[t,i]of e.entries())if(i.trim().length){if(!s)return null;s.localName&&s.localName.includes("-")&&await customElements.whenDefined(s.localName),s.updateComplete&&await s.updateComplete,s="$"===i?o&&t==e.length-1?[s.shadowRoot]:s.shadowRoot:o&&t==e.length-1?s.querySelectorAll(i):s.querySelector(i)}return s}async function dt(t,e,o=!1,s=1e4){return Promise.race([at(t,e,o),new Promise(((t,e)=>setTimeout((()=>e(new Error("timeout"))),s)))]).catch((t=>{if(!t.message||"timeout"!==t.message)throw t;return null}))}const lt=async t=>{await(async()=>{if(customElements.get("developer-tools-event"))return;await customElements.whenDefined("partial-panel-resolver");const t=document.createElement("partial-panel-resolver");t.hass={panels:[{url_path:"tmp",component_name:"developer-tools"}]},t._updateRoutes(),await t.routerOptions.routes.tmp.load(),await customElements.whenDefined("developer-tools-router");const e=document.createElement("developer-tools-router");await e.routerOptions.routes.event.load()})();return document.createElement("developer-tools-event")._computeParsedEventData(t)};async function ct(t,e,o="",s={},i=null,n=!0){var r;if(!t)return;let a;(null===(r=t.localName)||void 0===r?void 0:r.includes("-"))&&await customElements.whenDefined(t.localName),t.updateComplete&&await t.updateComplete,void 0===t._cardMod&&(t._cardMod=[]);for(const o of t._cardMod)if(o.type===e){a=o;break}return a||(a=document.createElement("card-mod"),a.type=e,t._cardMod.push(a)),queueMicrotask((async()=>{(t.modElement?t.modElement:n&&t.shadowRoot||t).appendChild(a),a.variables=s,a.styles=o})),a}function ht(t,e){const o=t=>t&&"object"==typeof t&&!Array.isArray(t);if(o(t)&&o(e))for(const s in e)o(e[s])?(t[s]||Object.assign(t,{[s]:{}}),"string"==typeof t[s]&&(t[s]={".":t[s]}),ht(t[s],e[s])):t[s]?t[s]=e[s]+t[s]:t[s]=e[s];return t}function ut(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(!(t instanceof Object&&e instanceof Object))return!1;for(const o in t)if(t.hasOwnProperty(o)){if(!e.hasOwnProperty(o))return!1;if(t[o]!==e[o]){if("object"!=typeof t[o])return!1;if(!ut(t[o],e[o]))return!1}}for(const o in e)if(e.hasOwnProperty(o)&&!t.hasOwnProperty(o))return!1;return!0}function pt(t){return t.config?t.config:t._config?t._config:t.host?pt(t.host):t.parentElement?pt(t.parentElement):t.parentNode?pt(t.parentNode):null}function mt(t,e){for(const o of e)t.add(o)}async function ft(t,e=0){let o=new Set;if(10==e)return o;if(!t)return o;if(t._cardMod)for(const e of t._cardMod)e.styles&&o.add(e);return t.updateComplete&&await t.updateComplete,t.parentElement?mt(o,await ft(t.parentElement,e+1)):t.parentNode&&mt(o,await ft(t.parentNode,e+1)),t.host&&mt(o,await ft(t.host,e+1)),o}function vt(){var t,e,o;const s=document.querySelectorAll("script"),i=[];for(const n of s)if(null===(e=null===(t=null==n?void 0:n.innerText)||void 0===t?void 0:t.trim())||void 0===e?void 0:e.startsWith("import(")){const t=null===(o=n.innerText.split("\n"))||void 0===o?void 0:o.map((t=>t.trim()));for(const e of t)i.push(e.replace(/^import\(\"/,"").replace(/\"\);/,""))}return i}class yt extends Y{constructor(){super(),this._rendered_styles="",this._styleChildren=new Set,this._observer=new MutationObserver((t=>{for(const e of t){if("card-mod"===e.target.localName)return;let t=!0;if(e.addedNodes.length&&e.addedNodes.forEach((e=>{"card-mod"!==e.localName&&(t=!1)})),t)return;if(t=!0,e.removedNodes.length&&e.removedNodes.forEach((e=>{"card-mod"!==e.localName&&(t=!1)})),t)return}this.refresh()})),document.addEventListener("cm_update",(()=>{this.refresh()}))}static get applyToElement(){return ct}connectedCallback(){super.connectedCallback(),this._connect(),this.setAttribute("slot","none")}disconnectedCallback(){super.disconnectedCallback(),this._disconnect()}set styles(e){ut(e,this._input_styles)||(this._input_styles=e,(async()=>{let o=JSON.parse(JSON.stringify(e||{}));"string"==typeof o&&(o={".":o});ht(o,await async function(e){var o,s;if(!e.type)return null;const i=e.parentElement?e.parentElement:e,n=window.getComputedStyle(i).getPropertyValue("--card-mod-theme");if(!t())return{};const r=null!==(s=null===(o=t())||void 0===o?void 0:o.themes.themes)&&void 0!==s?s:{};return r[n]?r[n][`card-mod-${e.type}-yaml`]?lt(r[n][`card-mod-${e.type}-yaml`]):r[n][`card-mod-${e.type}`]?{".":r[n][`card-mod-${e.type}`]}:{}:{}}(this)),this._fixed_styles=o,this._connect()})())}get styles(){return this._styles}refresh(){this._connect()}async _styleChildEl(t,e){if(void 0===e){const o=this._fixed_styles;for(const[s,i]of Object.entries(o)){if("."===s)continue;if((await dt(this.parentElement||this.parentNode,s,!0)).forEach((o=>{o===t&&(e=i)})),void 0!==e)break}if(void 0===e)return}if(!t)return;const o=await ct(t,`${this.type}-child`,e,this.variables,null,!1);return o.refresh,o}async _connect(){var t;const e=null!==(t=this._fixed_styles)&&void 0!==t?t:{},o=new Set;let s="",i=!1;const n=this.parentElement||this.parentNode;for(const[t,r]of Object.entries(e))if("."===t)s=r;else{i=!0;const e=await dt(n,t,!0);if(!e)continue;for(const t of e){const e=await this._styleChildEl(t,r);e&&o.add(e)}}for(const t of this._styleChildren)o.has(t)||t&&(t.styles="");var r;(this._styleChildren=o,this._styles!==s)&&(this._styles=s,this._styles&&(r=this._styles,String(r).includes("{%")||String(r).includes("{{"))?(this._renderer=this._renderer||this._style_rendered.bind(this),it(this._renderer,this._styles,this.variables)):this._style_rendered(this._styles||""),i&&this._observer.observe(function(t){if(!t)return;const e=t.parentElement||t.parentNode;return e?e.host?e.host:e:void 0}(this),{childList:!0}))}async _disconnect(){this._observer.disconnect(),this._styles="",await nt(this._renderer)}_style_rendered(t){this._rendered_styles=t,this.dispatchEvent(new Event("card-mod-update"))}createRenderRoot(){return this}render(){return M`
- `}}e([G()],yt.prototype,"_rendered_styles",void 0),customElements.get("card-mod")||(customElements.define("card-mod",yt),console.info(`%cCARD-MOD ${rt} IS INSTALLED`,"color: green; font-weight: bold")),customElements.whenDefined("ha-card").then((()=>{const t=customElements.get("ha-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(t){var o,s;null==e||e.bind(this)(t);const i=this.shadowRoot.querySelector(".card-header");i&&this.insertBefore(i,this.children[0]);const n=pt(this);(null===(o=null==n?void 0:n.card_mod)||void 0===o?void 0:o.class)&&this.classList.add(n.card_mod.class),(null==n?void 0:n.type)&&this.classList.add(`type-${n.type.replace(":","-")}`),ct(this,"card",(null===(s=null==n?void 0:n.card_mod)||void 0===s?void 0:s.style)||(null==n?void 0:n.style)||"",{config:n},null,!1).then((t=>{var e;const o=null===(e=this.parentNode)||void 0===e?void 0:e.host;if(o){if(o.setConfig&&!o.setConfig.cm_patched){const e=o.setConfig;o.setConfig=function(o){var s;e.bind(this)(o),t.variables={config:o},t.styles=(null===(s=o.card_mod)||void 0===s?void 0:s.style)||{}},o.setConfig.cm_patched=!0}if(o.update&&!o.update.cm_patched){const e=o.update;o.update=function(o){e.bind(this)(o),t.refresh(),this.updateComplete.then((()=>{t.refresh()}))},o.update.cm_patched=!0}}}))}})),customElements.whenDefined("hui-entities-card").then((()=>{const t=customElements.get("hui-entities-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.renderEntity;t.prototype.renderEntity=function(t){var o;const s=e.bind(this)(t);if(!s||!s.values)return s;const i=s.values[0];if(!i)return s;if("custom:mod-card"===(null==t?void 0:t.type))return s;(null===(o=null==t?void 0:t.card_mod)||void 0===o?void 0:o.class)&&i.classList.add(t.card_mod.class),(null==t?void 0:t.type)&&i.classList.add(`type-${t.type.replace(":","-")}`);const n=()=>{var e;return ct(i,"row",(null===(e=null==t?void 0:t.card_mod)||void 0===e?void 0:e.style)||(null==t?void 0:t.style)||"",{config:t})};return this.updateComplete.then((()=>n())),s.values[0]&&s.values[0].addEventListener("ll-rebuild",n),s}}));customElements.whenDefined("hui-glance-card").then((()=>{const t=customElements.get("hui-glance-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.updated;t.prototype.updated=function(t){var o,s;null==e||e.bind(this)(t);for(const t of this.shadowRoot.querySelectorAll("ha-card div.entity")){if(!t.cardmod_patched){t.cardmod_patched=!0;const e=t.attachShadow({mode:"open"});for(;t.firstChild;)e.append(t.firstChild);const o=document.createElement("style");e.appendChild(o),o.innerHTML="\ndiv {\n width: 100%;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.name {\n min-height: var(--paper-font-body1_-_line-height, 20px);\n}\nstate-badge {\n margin: 8px 0;\n}\n"}const e=t.config||t.entityConf;(null===(o=null==e?void 0:e.card_mod)||void 0===o?void 0:o.class)&&t.classList.add(e.card_mod.class),ct(t,"glance",(null===(s=null==e?void 0:e.card_mod)||void 0===s?void 0:s.style)||(null==e?void 0:e.style)||"",{config:e})}}})),customElements.whenDefined("hui-state-label-badge").then((()=>{const t=customElements.get("hui-state-label-badge");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(t){var o,s;null==e||e.bind(this)(t);const i=this._config;(null===(o=null==i?void 0:i.card_mod)||void 0===o?void 0:o.class)&&this.classList.add(i.card_mod.class),ct(this,"badge",(null===(s=null==i?void 0:i.card_mod)||void 0===s?void 0:s.style)||(null==i?void 0:i.style)||"",{config:i})}})),customElements.whenDefined("hui-view").then((()=>{const t=customElements.get("hui-view");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(t){null==e||e.bind(this)(t),ct(this,"view")}})),customElements.whenDefined("hui-root").then((()=>{const t=customElements.get("hui-root");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=async function(t){null==e||e.bind(this)(t),ct(this,"root")},dt(document,"home-assistant$home-assistant-main$app-drawer-layout partial-panel-resolver ha-panel-lovelace$hui-root",!1).then((t=>{null==t||t.firstUpdated()}))})),customElements.whenDefined("ha-more-info-dialog").then((()=>{const t=customElements.get("ha-more-info-dialog");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.showDialog;t.prototype.showDialog=function(t){null==e||e.bind(this)(t),this.requestUpdate(),this.updateComplete.then((async()=>{const e=this.shadowRoot.querySelector("ha-dialog");e&&ct(e,"more-info","",{config:t},null,!1)}))},dt(document,"home-assistant$ha-more-info-dialog",!1).then((e=>{e&&(e.showDialog=t.prototype.showDialog.bind(e),e.showDialog({entityId:e.entityId}))}))})),customElements.whenDefined("ha-sidebar").then((()=>{const t=customElements.get("ha-sidebar");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=async function(t){null==e||e.bind(this)(t),ct(this,"sidebar")},dt(document,"home-assistant$home-assistant-main$app-drawer-layout app-drawer ha-sidebar",!1).then((t=>null==t?void 0:t.firstUpdated()))})),customElements.whenDefined("hui-card-element-editor").then((()=>{const t=customElements.get("hui-card-element-editor");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.getConfigElement;t.prototype.getConfigElement=async function(){const t=await e.bind(this)();if(t){const e=t.setConfig;t.setConfig=function(t){var o,s;const i=JSON.parse(JSON.stringify(t));if(this._cardModData={card:i.card_mod,entities:[]},i.entities)for(const[t,e]of null===(o=i.entities)||void 0===o?void 0:o.entries())this._cardModData.entities[t]=e.card_mod,delete e.card_mod;if(delete i.card_mod,e.bind(this)(i),i.entities)for(const[t,e]of null===(s=i.entities)||void 0===s?void 0:s.entries())this._cardModData.entities[t]&&(e.card_mod=this._cardModData.entities[t])}}return t};const o=t.prototype._handleUIConfigChanged;t.prototype._handleUIConfigChanged=function(t){if(this._configElement&&this._configElement._cardModData){const e=this._configElement._cardModData;e.card&&(t.detail.config.card_mod=e.card)}o.bind(this)(t)}})),customElements.whenDefined("hui-dialog-edit-card").then((()=>{const t=customElements.get("hui-dialog-edit-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.updated;t.prototype.updated=function(t){null==e||e.bind(this)(t),this.updateComplete.then((async()=>{var t,e,o;this._cardModIcon||(this._cardModIcon=document.createElement("ha-icon"),this._cardModIcon.icon="mdi:brush");const s=this.shadowRoot.querySelector("mwc-button[slot=secondaryAction]");s&&(s.appendChild(this._cardModIcon),(null===(t=this._cardConfig)||void 0===t?void 0:t.card_mod)||(null===(o=null===(e=this._cardConfig)||void 0===e?void 0:e.entities)||void 0===o?void 0:o.some((t=>t.card_mod)))?this._cardModIcon.style.visibility="visible":this._cardModIcon.style.visibility="hidden")}))}})),customElements.whenDefined("hui-picture-elements-card").then((()=>{const t=customElements.get("hui-picture-elements-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.setConfig;t.prototype.setConfig=function(t){var o,s;null==e||e.bind(this)(t);for(const[t,e]of this._elements.entries()){const i=this._config.elements[t];(null===(o=null==i?void 0:i.card_mod)||void 0===o?void 0:o.class)&&e.classList.add(i.card_mod.class),(null==i?void 0:i.type)&&e.classList.add(`type-${i.type.replace(":","-")}`),ct(e,"element",null===(s=null==i?void 0:i.card_mod)||void 0===s?void 0:s.style,{config:i})}}})),customElements.whenDefined("ha-icon").then((()=>{const t=customElements.get("ha-icon");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(){null==e||e.bind(this)();const t=()=>{const t=window.getComputedStyle(this).getPropertyValue("--card-mod-icon");t&&(this.icon=t.trim());const e=window.getComputedStyle(this).getPropertyValue("--card-mod-icon-color");e&&(this.style.color=e)};(async()=>{const e=await ft(this);for(const o of e)o.addEventListener("card-mod-update",(async()=>{await o.updateComplete,t()}));t()})()}})),customElements.whenDefined("ha-svg-icon").then((()=>{const t=customElements.get("ha-svg-icon");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(){null==e||e.bind(this)();const t=async()=>{const t=window.getComputedStyle(this).getPropertyValue("--card-mod-icon");if(t){const e=document.createElement("ha-icon");e.icon=t.trim(),await e._loadIcon(),this.path=e._path}const e=window.getComputedStyle(this).getPropertyValue("--card-mod-icon-color");e&&(this.style.color=e)};(async()=>{const e=await ft(this);for(const o of e)o.addEventListener("card-mod-update",(async()=>{await o.updateComplete,t()}));t()})()}}));const _t="\nha-card {\n background: none;\n box-shadow: none;\n}";class gt extends Y{setConfig(t){var e;this._config=JSON.parse(JSON.stringify(t));let o=(null===(e=this._config.card_mod)||void 0===e?void 0:e.style)||this._config.style;void 0===o?o=_t:"string"==typeof o?o=_t+o:o["."]?o["."]=_t+o["."]:o["."]=_t,this._config.card_mod={style:o},this.build_card(t.card)}async build_card(t){void 0===this._hass&&await new Promise((t=>this._hassResolve=t)),this._hassResolve=void 0;const e=await window.loadCardHelpers();this.card=await e.createCardElement(t),this.card.hass=this._hass}firstUpdated(){window.setTimeout((()=>{var t,e;if(null===(e=null===(t=this.card)||void 0===t?void 0:t.shadowRoot)||void 0===e?void 0:e.querySelector("ha-card")){console.info("%cYou are doing it wrong!","color: red; font-weight: bold");let t=this.card.localName.replace(/hui-(.*)-card/,"$1");console.info(`mod-card should NEVER be used with a card that already has a ha-card element, such as ${t}`)}}),3e3)}set hass(t){this._hass=t,this.card&&(this.card.hass=t),this._hassResolve&&this._hassResolve()}render(){return M` ${this.card} `}getCardSize(){if(this._config.report_size)return this._config.report_size;let t=this.shadowRoot;return t&&(t=t.querySelector("ha-card card-maker")),t&&(t=t.getCardSize),t&&(t=t()),t||1}}function $t(){document.dispatchEvent(new Event("cm_update"))}e([G()],gt.prototype,"card",void 0),customElements.get("mod-card")||customElements.define("mod-card",gt);const wt=[customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")];Promise.race(wt).then((()=>{window.setTimeout((async()=>{for(var e,o;!t();)await new Promise((t=>window.setTimeout(t,500)));t().connection.subscribeEvents((()=>{window.setTimeout($t,500)}),"themes_updated"),null===(e=document.querySelector("home-assistant"))||void 0===e||e.addEventListener("settheme",$t),null===(o=document.querySelector("hc-main"))||void 0===o||o.addEventListener("settheme",$t)}),1e3)})),window.getResources=vt;vt().some((t=>t.endsWith("card-mod.js")))?console.info("Card-mod is loaded as a module"):(!function(t,e,o=null){if((t=new Event(t,{bubbles:!0,cancelable:!1,composed:!0})).detail=e||{},o)o.dispatchEvent(t);else{var s=function(){var t=document.querySelector("hc-main");return t?(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("hc-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-view")||t.querySelector("hui-panel-view"):(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root"))&&t.shadowRoot)&&t.querySelector("ha-app-layout"))&&t.querySelector("#view"))&&t.firstElementChild}();s&&s.dispatchEvent(t)}}("ll-rebuild",{}),console.info("You may not be getting optimal performance out of card-mod.\nSee https://github.com/thomasloven/lovelace-card-mod#performance-improvements"));
+ `}}e([G()],yt.prototype,"_rendered_styles",void 0),(async()=>{for(;void 0===customElements.get("home-assistant");)await new Promise((t=>window.setTimeout(t,100)));customElements.get("card-mod")||(customElements.define("card-mod",yt),console.info(`%cCARD-MOD ${rt} IS INSTALLED`,"color: green; font-weight: bold"))})(),customElements.whenDefined("ha-card").then((()=>{const t=customElements.get("ha-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(t){var o,s;null==e||e.bind(this)(t);const i=this.shadowRoot.querySelector(".card-header");i&&this.insertBefore(i,this.children[0]);const n=pt(this);(null===(o=null==n?void 0:n.card_mod)||void 0===o?void 0:o.class)&&this.classList.add(n.card_mod.class),(null==n?void 0:n.type)&&this.classList.add(`type-${n.type.replace(":","-")}`),ct(this,"card",(null===(s=null==n?void 0:n.card_mod)||void 0===s?void 0:s.style)||(null==n?void 0:n.style)||"",{config:n},null,!1).then((t=>{var e;const o=null===(e=this.parentNode)||void 0===e?void 0:e.host;if(o){if(o.setConfig&&!o.setConfig.cm_patched){const e=o.setConfig;o.setConfig=function(o){var s;e.bind(this)(o),t.variables={config:o},t.styles=(null===(s=o.card_mod)||void 0===s?void 0:s.style)||{}},o.setConfig.cm_patched=!0}if(o.update&&!o.update.cm_patched){const e=o.update;o.update=function(o){e.bind(this)(o),t.refresh(),this.updateComplete.then((()=>{t.refresh()}))},o.update.cm_patched=!0}}}))}})),customElements.whenDefined("hui-entities-card").then((()=>{const t=customElements.get("hui-entities-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.renderEntity;t.prototype.renderEntity=function(t){var o;const s=e.bind(this)(t);if(!s||!s.values)return s;const i=s.values[0];if(!i)return s;if("custom:mod-card"===(null==t?void 0:t.type))return s;(null===(o=null==t?void 0:t.card_mod)||void 0===o?void 0:o.class)&&i.classList.add(t.card_mod.class),(null==t?void 0:t.type)&&i.classList.add(`type-${t.type.replace(":","-")}`);const n=()=>{var e;return ct(i,"row",(null===(e=null==t?void 0:t.card_mod)||void 0===e?void 0:e.style)||(null==t?void 0:t.style)||"",{config:t})};return this.updateComplete.then((()=>n())),s.values[0]&&s.values[0].addEventListener("ll-rebuild",n),s}}));customElements.whenDefined("hui-glance-card").then((()=>{const t=customElements.get("hui-glance-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.updated;t.prototype.updated=function(t){var o,s;null==e||e.bind(this)(t);for(const t of this.shadowRoot.querySelectorAll("ha-card div.entity")){if(!t.cardmod_patched){t.cardmod_patched=!0;const e=t.attachShadow({mode:"open"});for(;t.firstChild;)e.append(t.firstChild);const o=document.createElement("style");e.appendChild(o),o.innerHTML="\ndiv {\n width: 100%;\n text-align: center;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.name {\n min-height: var(--paper-font-body1_-_line-height, 20px);\n}\nstate-badge {\n margin: 8px 0;\n}\n"}const e=t.config||t.entityConf;(null===(o=null==e?void 0:e.card_mod)||void 0===o?void 0:o.class)&&t.classList.add(e.card_mod.class),ct(t,"glance",(null===(s=null==e?void 0:e.card_mod)||void 0===s?void 0:s.style)||(null==e?void 0:e.style)||"",{config:e})}}})),customElements.whenDefined("hui-state-label-badge").then((()=>{const t=customElements.get("hui-state-label-badge");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(t){var o,s;null==e||e.bind(this)(t);const i=this._config;(null===(o=null==i?void 0:i.card_mod)||void 0===o?void 0:o.class)&&this.classList.add(i.card_mod.class),ct(this,"badge",(null===(s=null==i?void 0:i.card_mod)||void 0===s?void 0:s.style)||(null==i?void 0:i.style)||"",{config:i})}})),customElements.whenDefined("hui-view").then((()=>{const t=customElements.get("hui-view");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(t){null==e||e.bind(this)(t),ct(this,"view")}})),customElements.whenDefined("hui-root").then((()=>{const t=customElements.get("hui-root");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=async function(t){null==e||e.bind(this)(t),ct(this,"root")},dt(document,"home-assistant$home-assistant-main$app-drawer-layout partial-panel-resolver ha-panel-lovelace$hui-root",!1).then((t=>{null==t||t.firstUpdated()}))})),customElements.whenDefined("ha-more-info-dialog").then((()=>{const t=customElements.get("ha-more-info-dialog");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.showDialog;t.prototype.showDialog=function(t){null==e||e.bind(this)(t),this.requestUpdate(),this.updateComplete.then((async()=>{const e=this.shadowRoot.querySelector("ha-dialog");e&&ct(e,"more-info","",{config:t},null,!1)}))},dt(document,"home-assistant$ha-more-info-dialog",!1).then((e=>{e&&(e.showDialog=t.prototype.showDialog.bind(e),e.showDialog({entityId:e.entityId}))}))})),customElements.whenDefined("ha-sidebar").then((()=>{const t=customElements.get("ha-sidebar");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=async function(t){null==e||e.bind(this)(t),ct(this,"sidebar")},dt(document,"home-assistant$home-assistant-main$app-drawer-layout app-drawer ha-sidebar",!1).then((t=>null==t?void 0:t.firstUpdated()))})),customElements.whenDefined("hui-card-element-editor").then((()=>{const t=customElements.get("hui-card-element-editor");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.getConfigElement;t.prototype.getConfigElement=async function(){const t=await e.bind(this)();if(t){const e=t.setConfig;t.setConfig=function(t){var o,s;const i=JSON.parse(JSON.stringify(t));if(this._cardModData={card:i.card_mod,entities:[]},i.entities)for(const[t,e]of null===(o=i.entities)||void 0===o?void 0:o.entries())this._cardModData.entities[t]=e.card_mod,delete e.card_mod;if(delete i.card_mod,e.bind(this)(i),i.entities)for(const[t,e]of null===(s=i.entities)||void 0===s?void 0:s.entries())this._cardModData.entities[t]&&(e.card_mod=this._cardModData.entities[t])}}return t};const o=t.prototype._handleUIConfigChanged;t.prototype._handleUIConfigChanged=function(t){if(this._configElement&&this._configElement._cardModData){const e=this._configElement._cardModData;e.card&&(t.detail.config.card_mod=e.card)}o.bind(this)(t)}})),customElements.whenDefined("hui-dialog-edit-card").then((()=>{const t=customElements.get("hui-dialog-edit-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.updated;t.prototype.updated=function(t){null==e||e.bind(this)(t),this.updateComplete.then((async()=>{var t,e,o;this._cardModIcon||(this._cardModIcon=document.createElement("ha-icon"),this._cardModIcon.icon="mdi:brush");const s=this.shadowRoot.querySelector("mwc-button[slot=secondaryAction]");s&&(s.appendChild(this._cardModIcon),(null===(t=this._cardConfig)||void 0===t?void 0:t.card_mod)||(null===(o=null===(e=this._cardConfig)||void 0===e?void 0:e.entities)||void 0===o?void 0:o.some((t=>t.card_mod)))?this._cardModIcon.style.visibility="visible":this._cardModIcon.style.visibility="hidden")}))}})),customElements.whenDefined("hui-picture-elements-card").then((()=>{const t=customElements.get("hui-picture-elements-card");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.setConfig;t.prototype.setConfig=function(t){var o,s;null==e||e.bind(this)(t);for(const[t,e]of this._elements.entries()){const i=this._config.elements[t];(null===(o=null==i?void 0:i.card_mod)||void 0===o?void 0:o.class)&&e.classList.add(i.card_mod.class),(null==i?void 0:i.type)&&e.classList.add(`type-${i.type.replace(":","-")}`),ct(e,"element",null===(s=null==i?void 0:i.card_mod)||void 0===s?void 0:s.style,{config:i})}}})),customElements.whenDefined("ha-icon").then((()=>{const t=customElements.get("ha-icon");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(){null==e||e.bind(this)();const t=()=>{const t=window.getComputedStyle(this).getPropertyValue("--card-mod-icon");t&&(this.icon=t.trim());const e=window.getComputedStyle(this).getPropertyValue("--card-mod-icon-color");e&&(this.style.color=e)};(async()=>{const e=await ft(this);for(const o of e)o.addEventListener("card-mod-update",(async()=>{await o.updateComplete,t()}));t()})()}})),customElements.whenDefined("ha-svg-icon").then((()=>{const t=customElements.get("ha-svg-icon");if(t.prototype.cardmod_patched)return;t.prototype.cardmod_patched=!0;const e=t.prototype.firstUpdated;t.prototype.firstUpdated=function(){null==e||e.bind(this)();const t=async()=>{const t=window.getComputedStyle(this).getPropertyValue("--card-mod-icon");if(t){const e=document.createElement("ha-icon");e.icon=t.trim(),await e._loadIcon(),this.path=e._path}const e=window.getComputedStyle(this).getPropertyValue("--card-mod-icon-color");e&&(this.style.color=e)},o=async()=>{const e=await ft(this);for(const o of e)o.addEventListener("card-mod-update",(async()=>{await o.updateComplete,t()}));return t(),e};(async()=>{0==(await o()).size&&window.setTimeout((()=>o()),1e3)})()}}));const _t="\nha-card {\n background: none;\n box-shadow: none;\n}";class gt extends Y{setConfig(t){var e;this._config=JSON.parse(JSON.stringify(t));let o=(null===(e=this._config.card_mod)||void 0===e?void 0:e.style)||this._config.style;void 0===o?o=_t:"string"==typeof o?o=_t+o:o["."]?o["."]=_t+o["."]:o["."]=_t,this._config.card_mod={style:o},this.build_card(t.card)}async build_card(t){void 0===this._hass&&await new Promise((t=>this._hassResolve=t)),this._hassResolve=void 0;const e=await window.loadCardHelpers();this.card=await e.createCardElement(t),this.card.hass=this._hass}firstUpdated(){window.setTimeout((()=>{var t,e;if(null===(e=null===(t=this.card)||void 0===t?void 0:t.shadowRoot)||void 0===e?void 0:e.querySelector("ha-card")){console.info("%cYou are doing it wrong!","color: red; font-weight: bold");let t=this.card.localName.replace(/hui-(.*)-card/,"$1");console.info(`mod-card should NEVER be used with a card that already has a ha-card element, such as ${t}`)}}),3e3)}set hass(t){this._hass=t,this.card&&(this.card.hass=t),this._hassResolve&&this._hassResolve()}render(){return M` ${this.card} `}getCardSize(){if(this._config.report_size)return this._config.report_size;let t=this.shadowRoot;return t&&(t=t.querySelector("ha-card card-maker")),t&&(t=t.getCardSize),t&&(t=t()),t||1}}function wt(){document.dispatchEvent(new Event("cm_update"))}e([G()],gt.prototype,"card",void 0),(async()=>{for(;void 0===customElements.get("home-assistant");)await new Promise((t=>window.setTimeout(t,100)));customElements.get("mod-card")||customElements.define("mod-card",gt)})();const $t=[customElements.whenDefined("home-assistant"),customElements.whenDefined("hc-main")];Promise.race($t).then((()=>{window.setTimeout((async()=>{for(var e,o;!t();)await new Promise((t=>window.setTimeout(t,500)));t().connection.subscribeEvents((()=>{window.setTimeout(wt,500)}),"themes_updated"),null===(e=document.querySelector("home-assistant"))||void 0===e||e.addEventListener("settheme",wt),null===(o=document.querySelector("hc-main"))||void 0===o||o.addEventListener("settheme",wt)}),1e3)})),window.getResources=vt;vt().some((t=>t.endsWith("card-mod.js")))?console.info("Card-mod is loaded as a module"):(!function(t,e,o=null){if((t=new Event(t,{bubbles:!0,cancelable:!1,composed:!0})).detail=e||{},o)o.dispatchEvent(t);else{var s=function(){var t=document.querySelector("hc-main");return t?(t=(t=(t=t&&t.shadowRoot)&&t.querySelector("hc-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-view")||t.querySelector("hui-panel-view"):(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=(t=document.querySelector("home-assistant"))&&t.shadowRoot)&&t.querySelector("home-assistant-main"))&&t.shadowRoot)&&t.querySelector("app-drawer-layout partial-panel-resolver"))&&t.shadowRoot||t)&&t.querySelector("ha-panel-lovelace"))&&t.shadowRoot)&&t.querySelector("hui-root"))&&t.shadowRoot)&&t.querySelector("ha-app-layout"))&&t.querySelector("#view"))&&t.firstElementChild}();s&&s.dispatchEvent(t)}}("ll-rebuild",{}),console.info("You may not be getting optimal performance out of card-mod.\nSee https://github.com/thomasloven/lovelace-card-mod#performance-improvements"));
diff --git a/package-lock.json b/package-lock.json
index 40948a1..bafded8 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,6 +1,6 @@
{
"name": "card-mod",
- "version": "3.1.1",
+ "version": "3.1.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
diff --git a/package.json b/package.json
index 97a15c7..4514f48 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "card-mod",
"private": true,
- "version": "3.1.2",
+ "version": "3.1.3",
"description": "",
"scripts": {
"build": "rollup -c",
diff --git a/src/card-mod.ts b/src/card-mod.ts
index 75a4010..d2a7b26 100644
--- a/src/card-mod.ts
+++ b/src/card-mod.ts
@@ -196,10 +196,18 @@ export class CardMod extends LitElement {
}
}
-if (!customElements.get("card-mod")) {
- customElements.define("card-mod", CardMod);
- console.info(
- `%cCARD-MOD ${pjson.version} IS INSTALLED`,
- "color: green; font-weight: bold"
- );
-}
+(async () => {
+ // Wait for scoped customElements registry to be set up
+ // otherwise the customElements registry card-mod is defined in
+ // may get overwritten by the polyfill if card-mod is loaded as a module
+ while (customElements.get("home-assistant") === undefined)
+ await new Promise((resolve) => window.setTimeout(resolve, 100));
+
+ if (!customElements.get("card-mod")) {
+ customElements.define("card-mod", CardMod);
+ console.info(
+ `%cCARD-MOD ${pjson.version} IS INSTALLED`,
+ "color: green; font-weight: bold"
+ );
+ }
+})();
diff --git a/src/mod-card.ts b/src/mod-card.ts
index f99c1f3..413261a 100644
--- a/src/mod-card.ts
+++ b/src/mod-card.ts
@@ -79,6 +79,12 @@ class ModCard extends LitElement {
}
}
-if (!customElements.get("mod-card")) {
- customElements.define("mod-card", ModCard);
-}
+(async () => {
+ // See explanation in card-mod.ts
+ while (customElements.get("home-assistant") === undefined)
+ await new Promise((resolve) => window.setTimeout(resolve, 100));
+
+ if (!customElements.get("mod-card")) {
+ customElements.define("mod-card", ModCard);
+ }
+})();
diff --git a/src/patch/ha-icon.ts b/src/patch/ha-icon.ts
index 137067a..a2588b2 100644
--- a/src/patch/ha-icon.ts
+++ b/src/patch/ha-icon.ts
@@ -60,9 +60,8 @@ customElements.whenDefined("ha-svg-icon").then(() => {
if (iconColor) this.style.color = iconColor;
};
- (async () => {
+ const bindCM = async () => {
const cardMods = await findParentCardMod(this);
-
for (const cm of cardMods) {
cm.addEventListener("card-mod-update", async () => {
await cm.updateComplete;
@@ -71,6 +70,11 @@ customElements.whenDefined("ha-svg-icon").then(() => {
}
updateIcon();
+ return cardMods;
+ };
+
+ (async () => {
+ if ((await bindCM()).size == 0) window.setTimeout(() => bindCM(), 1000);
})();
};
});
diff --git a/test/themes/test.yaml b/test/themes/test.yaml
index da66296..5a142d3 100644
--- a/test/themes/test.yaml
+++ b/test/themes/test.yaml
@@ -9,3 +9,7 @@ test:
border: solid 1px var(--secondary-text-color);
background: url("https://placekitten.com/640/480");
}
+ card-mod-root: |
+ paper-tab:nth-of-type(2) {
+ --card-mod-icon: {{ iif(is_state('light.kitchen_lights', 'on'), "mdi:star", "mdi:star-outline")}};
+ }
diff --git a/test/views/1_cards.yaml b/test/views/1_cards.yaml
index a439d64..12f0659 100644
--- a/test/views/1_cards.yaml
+++ b/test/views/1_cards.yaml
@@ -21,6 +21,7 @@ x-anchors:
# Applying basic styles to cards
#
title: Cards
+icon: mdi:home
cards:
- type: vertical-stack
cards:
diff --git a/test/views/2_separate_items.yaml b/test/views/2_separate_items.yaml
index 4a33c47..4d23dab 100644
--- a/test/views/2_separate_items.yaml
+++ b/test/views/2_separate_items.yaml
@@ -13,6 +13,7 @@ x-anchors:
# Styling individual items
#
title: Individual items
+icon: mdi:home
cards:
- type: vertical-stack
cards: