From 535b2818a0e1b657bafb1b616bcb42398c9ff9d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anthon=20M=C3=B8lgaard=20Steiness?= Date: Sun, 27 Oct 2024 23:09:56 +0100 Subject: [PATCH] Bug Fix: my-slider-v2 cover entity - value shown incorrect when using sliderMin config key. --- dist/dev/my-cards.js | 6 +- dist/my-button.js | 195 +++++++++++++--------- dist/my-cards.js | 339 +++++++++++++++++++++----------------- dist/my-slider-v2.js | 34 ++-- dist/my-slider.js | 2 +- src/cards/extras/const.ts | 2 +- src/cards/my-slider.ts | 25 ++- 7 files changed, 350 insertions(+), 253 deletions(-) diff --git a/dist/dev/my-cards.js b/dist/dev/my-cards.js index 14a2a12..5214e5a 100644 --- a/dist/dev/my-cards.js +++ b/dist/dev/my-cards.js @@ -183,7 +183,7 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ut={};class gt extends it{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!lt){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new dt(String(e),ct)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?lt?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ut&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return ut}}gt.finalized=!0,gt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,s=U.has(e),o=X&&11===e.nodeType&&!!e.host,r=o&&!G.has(n),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let n=U.get(e);void 0===n&&(d(e,e.firstChild),U.set(e,n=new H(Object.assign({templateFactory:z},i))),n.appendInto(e)),n.setValue(t),n.commit()})(t,a,Object.assign({templateFactory:J(n)},i)),r){const t=U.get(a);U.delete(a);const i=t.value instanceof M?t.value.template:void 0;K(n,a,i),d(e,e.firstChild),e.appendChild(a),U.set(e,t)}!s&&o&&window.ShadyCSS.styleElement(e.host)},gt.shadowRootOptions={mode:"open"};var pt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,mt="[^\\s]+",ft=/\[([^]*?)\]/gm;function _t(t,e){for(var i=[],n=0,s=t.length;n-1?n:null}};function yt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},kt=yt({},St),$t=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+$t(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+$t(Math.floor(Math.abs(e)/60),2)+":"+$t(Math.abs(e)%60,2)}},Mt=function(t){return+t-1},Ct=[null,"[1-9]\\d?"],Et=[null,mt],Pt=["isPm",mt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],Nt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Ot=(vt("monthNamesShort"),vt("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Vt,At,Ht=function(t,e,i){if(void 0===e&&(e=Ot.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=Ot[e]||e).replace(ft,(function(t,e){return n.push(e),"@@@"}));var s=yt(yt({},kt),i);return(e=e.replace(pt,(function(e){return Tt[e](t,s)}))).replace(/@@@/g,(function(){return n.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function Lt(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(At=Vt||(Vt={})).language="language",At.system="system",At.comma_decimal="comma_decimal",At.decimal_comma="decimal_comma",At.space_comma="space_comma",At.none="none";var Dt=!1;if("undefined"!=typeof window){var jt={get passive(){Dt=!0}};window.addEventListener("testPassive",null,jt),window.removeEventListener("testPassive",null,jt)}var Rt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Yt=[],It=!1,zt=-1,Ft=void 0,Ut=void 0,Bt=void 0,qt=function(t){return Yt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Wt=function(t){var e=t||window.event;return!!qt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Xt=function(t,e){if(t){if(!Yt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};Yt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e=n&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Bt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var n=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Bt=document.body.style.paddingRight,document.body.style.paddingRight=n+i+"px"}}void 0===Ft&&(Ft=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Rt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(zt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-zt;!qt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Wt(t):t.stopPropagation())}(e,t)},It||(document.addEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Jt=function(t){t?(Yt=Yt.filter((function(e){return e.targetElement!==t})),Rt&&(t.ontouchstart=null,t.ontouchmove=null,It&&0===Yt.length&&(document.removeEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!1)),Rt?function(){if(void 0!==Ut){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ut.position,document.body.style.top=Ut.top,document.body.style.left=Ut.left,window.scrollTo(e,t),Ut=void 0}}():(void 0!==Bt&&(document.body.style.paddingRight=Bt,Bt=void 0),void 0!==Ft&&(document.body.style.overflow=Ft,Ft=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};console.info(`%c ---- MY-SLIDER ---- \n%c ${a("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Zt=class extends gt{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const i=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",n=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+i]);var s=e.step?e.step:"1",o=e.minBar?e.minBar:0,r=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(i.includes("input_number.")||i.includes("number."))&&(s=e.step?e.step:n.attributes.step,a=e.minSet?e.minSet:n.attributes.min,l=e.maxSet?e.maxSet:n.attributes.max);var c=e.width?e.width:"100%",d=e.height?e.height:"50px",h=e.radius?e.radius:"4px",u=e.top?e.top:"0px",g=e.bottom?e.bottom:"0px",p=e.right?e.right:"0px",m=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",_=e.containerHeight?e.containerHeight:d;"0"!=f&&(f+="deg");var v=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",y=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",w=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",x=e.border?e.border:"0",S=e.thumbWidth?e.thumbWidth:"25px",k=e.thumbHeight?e.thumbHeight:"80px",$=e.thumbColor?e.thumbColor:"#FFFFFF",T=e.thumbColorOff?e.thumbColorOff:"#969696",M=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",C=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",E=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",P=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",N=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",O=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",A=!!e.lockTrack&&e.lockTrack,H=`\n\t\t\t--slider-width: ${c};\n\t\t\t--slider-width-inverse: -${c};\n\t\t\t--slider-height: ${d};\n\t\t\t--slider-main-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${v};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${y};\n\t\t\t--slider-secondary-color-off: ${w};\n\t\t\t--slider-radius: ${h};\n\t\t\t--border: ${x};\n\n\t\t\t--thumb-width: ${S};\n\t\t\t--thumb-height: ${k};\n\t\t\t--thumb-color: ${"off"===n.state||null==n.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${$};\n\t\t\t--thumb-color-off: ${T};\n\t\t\t--thumb-horizontal-padding: ${M};\n\t\t\t--thumb-vertical-padding: ${C};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${u};\n\t\t\t--bottom: ${g};\n\t\t\t--right: ${p};\n\t\t\t--left: ${m};\n\t\t\t--container-height: ${_};\n\t\t\t--thumb-top: ${E};\n\t\t\t--thumb-border-right: ${P};\n\t\t\t--thumb-border-left: ${N};\n\t\t\t--thumb-border-top: ${O};\n\t\t\t--thumb-border-bottom: ${V};\n\t\t\t\n\t\t\t--lock-track-container: ${A?"none":"auto"};\n\t\t`;const L=t=>{i.includes("light.")?"Warmth"==e.function?this._setWarmth(n,t.target,a,l):this._setBrightness(n,t.target,a,l):i.includes("input_number.")||i.includes("number.")?this._setInputNumber(n,t.target,a,l):i.includes("media_player.")?this._setMediaVolume(n,t.target,a,l):i.includes("cover.")?this._setCover(n,t.target,a,l):i.includes("fan.")?this._setFan(n,t.target,a,l):i.includes("switch.")?this._setSwitch(n,t.target,a,l,o,r):i.includes("lock.")&&this._setLock(n,t.target,a,l,o,r)},D=t=>{e.intermediate&&L(t)},j=t=>{e.intermediate||L(t)},R=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Xt(window):Jt(window)};if(i.includes("light."))return"Warmth"==e.function?q` +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ut={};class gt extends it{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!lt){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new dt(String(e),ct)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?lt?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ut&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return ut}}gt.finalized=!0,gt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,s=U.has(e),o=X&&11===e.nodeType&&!!e.host,r=o&&!G.has(n),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let n=U.get(e);void 0===n&&(d(e,e.firstChild),U.set(e,n=new H(Object.assign({templateFactory:z},i))),n.appendInto(e)),n.setValue(t),n.commit()})(t,a,Object.assign({templateFactory:J(n)},i)),r){const t=U.get(a);U.delete(a);const i=t.value instanceof M?t.value.template:void 0;K(n,a,i),d(e,e.firstChild),e.appendChild(a),U.set(e,t)}!s&&o&&window.ShadyCSS.styleElement(e.host)},gt.shadowRootOptions={mode:"open"};var pt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,mt="[^\\s]+",ft=/\[([^]*?)\]/gm;function _t(t,e){for(var i=[],n=0,s=t.length;n-1?n:null}};function yt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},kt=yt({},St),$t=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+$t(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+$t(Math.floor(Math.abs(e)/60),2)+":"+$t(Math.abs(e)%60,2)}},Mt=function(t){return+t-1},Ct=[null,"[1-9]\\d?"],Et=[null,mt],Pt=["isPm",mt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],Nt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Ot=(vt("monthNamesShort"),vt("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Vt,At,Ht=function(t,e,i){if(void 0===e&&(e=Ot.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=Ot[e]||e).replace(ft,(function(t,e){return n.push(e),"@@@"}));var s=yt(yt({},kt),i);return(e=e.replace(pt,(function(e){return Tt[e](t,s)}))).replace(/@@@/g,(function(){return n.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function Lt(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(At=Vt||(Vt={})).language="language",At.system="system",At.comma_decimal="comma_decimal",At.decimal_comma="decimal_comma",At.space_comma="space_comma",At.none="none";var Dt=!1;if("undefined"!=typeof window){var jt={get passive(){Dt=!0}};window.addEventListener("testPassive",null,jt),window.removeEventListener("testPassive",null,jt)}var Rt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Yt=[],It=!1,zt=-1,Ft=void 0,Ut=void 0,Bt=void 0,qt=function(t){return Yt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Wt=function(t){var e=t||window.event;return!!qt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Xt=function(t,e){if(t){if(!Yt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};Yt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e=n&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Bt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var n=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Bt=document.body.style.paddingRight,document.body.style.paddingRight=n+i+"px"}}void 0===Ft&&(Ft=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Rt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(zt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-zt;!qt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Wt(t):t.stopPropagation())}(e,t)},It||(document.addEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Jt=function(t){t?(Yt=Yt.filter((function(e){return e.targetElement!==t})),Rt&&(t.ontouchstart=null,t.ontouchmove=null,It&&0===Yt.length&&(document.removeEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!1)),Rt?function(){if(void 0!==Ut){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ut.position,document.body.style.top=Ut.top,document.body.style.left=Ut.left,window.scrollTo(e,t),Ut=void 0}}():(void 0!==Bt&&(document.body.style.paddingRight=Bt,Bt=void 0),void 0!==Ft&&(document.body.style.overflow=Ft,Ft=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};console.info(`%c ---- MY-SLIDER ---- \n%c ${a("common.version")} 3.0.7 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Zt=class extends gt{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const i=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",n=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+i]);var s=e.step?e.step:"1",o=e.minBar?e.minBar:0,r=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(i.includes("input_number.")||i.includes("number."))&&(s=e.step?e.step:n.attributes.step,a=e.minSet?e.minSet:n.attributes.min,l=e.maxSet?e.maxSet:n.attributes.max);var c=e.width?e.width:"100%",d=e.height?e.height:"50px",h=e.radius?e.radius:"4px",u=e.top?e.top:"0px",g=e.bottom?e.bottom:"0px",p=e.right?e.right:"0px",m=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",_=e.containerHeight?e.containerHeight:d;"0"!=f&&(f+="deg");var v=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",y=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",w=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",x=e.border?e.border:"0",S=e.thumbWidth?e.thumbWidth:"25px",k=e.thumbHeight?e.thumbHeight:"80px",$=e.thumbColor?e.thumbColor:"#FFFFFF",T=e.thumbColorOff?e.thumbColorOff:"#969696",M=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",C=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",E=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",P=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",N=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",O=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",A=!!e.lockTrack&&e.lockTrack,H=`\n\t\t\t--slider-width: ${c};\n\t\t\t--slider-width-inverse: -${c};\n\t\t\t--slider-height: ${d};\n\t\t\t--slider-main-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${v};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${y};\n\t\t\t--slider-secondary-color-off: ${w};\n\t\t\t--slider-radius: ${h};\n\t\t\t--border: ${x};\n\n\t\t\t--thumb-width: ${S};\n\t\t\t--thumb-height: ${k};\n\t\t\t--thumb-color: ${"off"===n.state||null==n.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${$};\n\t\t\t--thumb-color-off: ${T};\n\t\t\t--thumb-horizontal-padding: ${M};\n\t\t\t--thumb-vertical-padding: ${C};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${u};\n\t\t\t--bottom: ${g};\n\t\t\t--right: ${p};\n\t\t\t--left: ${m};\n\t\t\t--container-height: ${_};\n\t\t\t--thumb-top: ${E};\n\t\t\t--thumb-border-right: ${P};\n\t\t\t--thumb-border-left: ${N};\n\t\t\t--thumb-border-top: ${O};\n\t\t\t--thumb-border-bottom: ${V};\n\t\t\t\n\t\t\t--lock-track-container: ${A?"none":"auto"};\n\t\t`;const L=t=>{i.includes("light.")?"Warmth"==e.function?this._setWarmth(n,t.target,a,l):this._setBrightness(n,t.target,a,l):i.includes("input_number.")||i.includes("number.")?this._setInputNumber(n,t.target,a,l):i.includes("media_player.")?this._setMediaVolume(n,t.target,a,l):i.includes("cover.")?this._setCover(n,t.target,a,l):i.includes("fan.")?this._setFan(n,t.target,a,l):i.includes("switch.")?this._setSwitch(n,t.target,a,l,o,r):i.includes("lock.")&&this._setLock(n,t.target,a,l,o,r)},D=t=>{e.intermediate&&L(t)},j=t=>{e.intermediate||L(t)},R=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Xt(window):Jt(window)};if(i.includes("light."))return"Warmth"==e.function?q`
e=>{if(!(e instanceof A)||e instanceof j||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let s=Gt.get(e);void 0===s&&(n.cssText=i.strings.join(" "),Gt.set(e,s=new Set)),s.forEach(e=>{e in t||(s.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))});for(const e in t)s.add(e),-1===e.indexOf("-")?n[e]=t[e]:n.setProperty(e,t[e])}),Qt=(t,e={})=>{const i=te[t];return i?Object.assign(Object.assign({},i),e):void console.log(t+": Not found in styles")},te={card:{height:"30px"},container:{width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},track:{width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},progress:{height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},thumb:{height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"}},ee=function(t,e,i){var n,s;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(n=o,s=t[o],e.push(n),"object"==typeof s&&null!==s?i=ee(s,e,i):i[e[e.length-1]]=s,e.pop());return i},ie=(t,e=100,i=0)=>t/(e-i)*100,ne=t=>Math.round(100*(t+Number.EPSILON))/100;function se(t,e){if(!oe(t))return oe(e)?e:{};if(!oe(e))return oe(t)?t:{};if(oe(t)&&oe(e)){const i=Object.assign({},t);return Object.keys(e).forEach(n=>{Array.isArray(e[n])?i[n]=e[n].map((e,i)=>t[n]&&oe(t[n][i])&&oe(e)?se(t[n][i],e):e):oe(e[n])?n in t?i[n]=se(t[n],e[n]):Object.assign(i,{[n]:e[n]}):Object.assign(i,{[n]:e[n]})}),i}return{}}function oe(t){return t&&"object"==typeof t&&!Array.isArray(t)}function re(e,i){if(void 0===e)return!1;const n=(s=e.entity_id).substring(0,s.indexOf("."));var s;const o=void 0!==i?i:null==e?void 0:e.state;if(["button","event","input_button","scene"].includes(n))return"unavailable"!==o;if(t(o))return!1;if("off"===o&&"alert"!==n)return!1;switch(n){case"alarm_control_panel":return"disarmed"!==o;case"alert":return"idle"!==o;case"cover":return"closed"!==o;case"device_tracker":case"person":return"not_home"!==o;case"lock":return"locked"!==o;case"media_player":return"standby"!==o;case"vacuum":return!["idle","docked","paused"].includes(o);case"plant":return"problem"===o;case"group":return["on","home","open","locked","problem"].includes(o);case"timer":return"active"===o;case"camera":return"streaming"===o}return!0}const ae=(t,e)=>{if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;let i,n;if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(!ae(t[i],e[i]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;for(i of t.entries())if(!ae(i[1],e.get(i[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(t[i]!==e[i])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,s[i]))return!1;for(i=n;0!=i--;){const n=s[i];if(!ae(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},le=(t,e,i)=>{const n=JSON.parse(JSON.stringify(i));return ce(t,e,n)},ce=(t,e,i)=>{if(["number","boolean"].includes(typeof i))return i;if(!i)return i;if("object"==typeof i)return Object.keys(i).forEach(n=>{i[n]=ce(t,e,i[n])}),i;const n=i.trim();if("[[["===n.substring(0,3)&&"]]]"===n.slice(-3)){return de(t,e,n.slice(3,-3))}return i},de=(t,e,i)=>{try{return new Function("states","entity","user","hass","html","'use strict'; "+i).call(t,t.hass.states,e,t.hass.user,t.hass,q)}catch(t){if(t instanceof Error){const e=i.length<=100?i.trim():i.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${e}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}};console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${a("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let he=class extends gt{constructor(){super(...arguments),this.touchInput=!1,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.zero=0,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0,this.initialTransition=""}setSliderValues(t,e){this._config.inverse?(this.sliderVal=this._config.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","input_boolean","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&(void 0!==this._config&&"seekbar"===this._config.mode&&this.entity.state,Lt(this,t,!1))}updated(t){super.updated(t),requestAnimationFrame(()=>{if(void 0===this.sliderEl&&null!==this.shadowRoot){this.sliderEl=this.shadowRoot.querySelector(".my-slider-custom-container");const t=this.sliderEl.querySelector(".my-slider-custom-progress");this.initialTransition=t.style.transition}})}render(){var t,e,i,n,s,o,r,a,l;const c=this.initializeConfig();if(null!==c)return c;const d=[{transition:this._config.vertical?"height 0.2s ease 0s":"width 0.2s ease 0s"}],h=(null===(t=this._config.styles)||void 0===t?void 0:t.progress)?Object.assign(Object.assign({},d),this._config.styles.progress):d,u=ee(null===(e=this._config.styles)||void 0===e?void 0:e.card)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},g=ee(null===(n=this._config.styles)||void 0===n?void 0:n.container)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=ee(null===(o=this._config.styles)||void 0===o?void 0:o.track)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.track):{},m=ee(h),f=ee(null===(a=this._config.styles)||void 0===a?void 0:a.thumb)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.thumb):{},_=Qt("card",u),v=Qt("container",g),y=Qt("track",p),b=Qt("progress",m),w=Qt("thumb",f);this._config.vertical?(b.height=this.sliderValPercent.toString()+"%",_.height=u.height?u.height:"100%",_.width=u.width?u.width:"30px",b.width=m.width?m.width:"100%",b.right=m.right?m.right:"auto",w.right=f.right?f:"auto",w.width=f.width?f.width:"100%",w.height=f.height?f.height:"10px",this._config.flipped?(b.top=m.top?m.top:"0",w.bottom=f.bottom?f.bottom:"-5px"):(b.bottom=m.bottom?m.bottom:"0",w.top=f.top?f.top:"-5px")):(b.width=this.sliderValPercent.toString()+"%",this._config.flipped&&(b.right=m.right?m.right:"0",w.right=f.right?f.right:"auto",w.left=f.left?f.left:"-5px"));const x=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;S(t);break;case"touchstart":this.touchInput=!0,S(t);break;case"mousemove":if(this.touchInput)return;$(t);break;case"touchmove":this._config.disableScroll&&t.preventDefault(),$(t);break;case"mouseup":case"touchend":case"touchcancel":k(t)}},S=t=>{var e;if(this.actionTaken)return;const i=t.clientX||t.touches[0].clientX,n=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=n),this._config.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const s=t.composedPath()[0],o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(s.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(o){const e=o.getBoundingClientRect();if(i>=e.left-this._config.marginOfError&&i<=e.right+this._config.marginOfError&&n>=e.top-this._config.marginOfError&&n<=e.bottom+this._config.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this._config.allowSliding&&(this.actionTaken=!0),this.clientYLast=n,this.clientXLast=i},k=t=>{if(!this.actionTaken)return;this.sliderEl.querySelector(".my-slider-custom-progress").style.transition=this.initialTransition,(this._config.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.touchInput=!1,this.isSliding=!1,setTimeout(()=>{this.actionTaken=!1},50)},$=t=>{if(this.actionTaken){this.sliderEl.querySelector(".my-slider-custom-progress").style.transition="";const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this._config.allowTapping||this.isSliding||!this._config.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this._config.allowSliding&&(this._config.vertical?Math.abs(i-this.clientYLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(x),q` +const Gt=new WeakMap,Kt=S(t=>e=>{if(!(e instanceof A)||e instanceof j||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let s=Gt.get(e);void 0===s&&(n.cssText=i.strings.join(" "),Gt.set(e,s=new Set)),s.forEach(e=>{e in t||(s.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))});for(const e in t)s.add(e),-1===e.indexOf("-")?n[e]=t[e]:n.setProperty(e,t[e])}),Qt=(t,e={})=>{const i=te[t];return i?Object.assign(Object.assign({},i),e):void console.log(t+": Not found in styles")},te={card:{height:"30px"},container:{width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},track:{width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},progress:{height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},thumb:{height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"}},ee=function(t,e,i){var n,s;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(n=o,s=t[o],e.push(n),"object"==typeof s&&null!==s?i=ee(s,e,i):i[e[e.length-1]]=s,e.pop());return i},ie=(t,e=100,i=0)=>t/(e-i)*100,ne=t=>Math.round(100*(t+Number.EPSILON))/100;function se(t,e){if(!oe(t))return oe(e)?e:{};if(!oe(e))return oe(t)?t:{};if(oe(t)&&oe(e)){const i=Object.assign({},t);return Object.keys(e).forEach(n=>{Array.isArray(e[n])?i[n]=e[n].map((e,i)=>t[n]&&oe(t[n][i])&&oe(e)?se(t[n][i],e):e):oe(e[n])?n in t?i[n]=se(t[n],e[n]):Object.assign(i,{[n]:e[n]}):Object.assign(i,{[n]:e[n]})}),i}return{}}function oe(t){return t&&"object"==typeof t&&!Array.isArray(t)}function re(e,i){if(void 0===e)return!1;const n=(s=e.entity_id).substring(0,s.indexOf("."));var s;const o=void 0!==i?i:null==e?void 0:e.state;if(["button","event","input_button","scene"].includes(n))return"unavailable"!==o;if(t(o))return!1;if("off"===o&&"alert"!==n)return!1;switch(n){case"alarm_control_panel":return"disarmed"!==o;case"alert":return"idle"!==o;case"cover":return"closed"!==o;case"device_tracker":case"person":return"not_home"!==o;case"lock":return"locked"!==o;case"media_player":return"standby"!==o;case"vacuum":return!["idle","docked","paused"].includes(o);case"plant":return"problem"===o;case"group":return["on","home","open","locked","problem"].includes(o);case"timer":return"active"===o;case"camera":return"streaming"===o}return!0}const ae=(t,e)=>{if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;let i,n;if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(!ae(t[i],e[i]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;for(i of t.entries())if(!ae(i[1],e.get(i[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(t[i]!==e[i])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,s[i]))return!1;for(i=n;0!=i--;){const n=s[i];if(!ae(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},le=(t,e,i)=>{const n=JSON.parse(JSON.stringify(i));return ce(t,e,n)},ce=(t,e,i)=>{if(["number","boolean"].includes(typeof i))return i;if(!i)return i;if("object"==typeof i)return Object.keys(i).forEach(n=>{i[n]=ce(t,e,i[n])}),i;const n=i.trim();if("[[["===n.substring(0,3)&&"]]]"===n.slice(-3)){return de(t,e,n.slice(3,-3))}return i},de=(t,e,i)=>{try{return new Function("states","entity","user","hass","html","'use strict'; "+i).call(t,t.hass.states,e,t.hass.user,t.hass,q)}catch(t){if(t instanceof Error){const e=i.length<=100?i.trim():i.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${e}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}};console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${a("common.version")} 3.0.7 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let he=class extends gt{constructor(){super(...arguments),this.touchInput=!1,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.zero=0,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0,this.initialTransition=""}setSliderValues(t,e,i=!1){this._config.inverse&&!i?(this.sliderVal=this._config.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","input_boolean","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&(void 0!==this._config&&"seekbar"===this._config.mode&&this.entity.state,Lt(this,t,!1))}updated(t){super.updated(t),requestAnimationFrame(()=>{if(void 0===this.sliderEl&&null!==this.shadowRoot){this.sliderEl=this.shadowRoot.querySelector(".my-slider-custom-container");const t=this.sliderEl.querySelector(".my-slider-custom-progress");this.initialTransition=t.style.transition}})}render(){var t,e,i,n,s,o,r,a,l;const c=this.initializeConfig();if(null!==c)return c;const d=[{transition:this._config.vertical?"height 0.2s ease 0s":"width 0.2s ease 0s"}],h=(null===(t=this._config.styles)||void 0===t?void 0:t.progress)?Object.assign(Object.assign({},d),this._config.styles.progress):d,u=ee(null===(e=this._config.styles)||void 0===e?void 0:e.card)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},g=ee(null===(n=this._config.styles)||void 0===n?void 0:n.container)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=ee(null===(o=this._config.styles)||void 0===o?void 0:o.track)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.track):{},m=ee(h),f=ee(null===(a=this._config.styles)||void 0===a?void 0:a.thumb)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.thumb):{},_=Qt("card",u),v=Qt("container",g),y=Qt("track",p),b=Qt("progress",m),w=Qt("thumb",f);this._config.vertical?(b.height=this.sliderValPercent.toString()+"%",_.height=u.height?u.height:"100%",_.width=u.width?u.width:"30px",b.width=m.width?m.width:"100%",b.right=m.right?m.right:"auto",w.right=f.right?f:"auto",w.width=f.width?f.width:"100%",w.height=f.height?f.height:"10px",this._config.flipped?(b.top=m.top?m.top:"0",w.bottom=f.bottom?f.bottom:"-5px"):(b.bottom=m.bottom?m.bottom:"0",w.top=f.top?f.top:"-5px")):(b.width=this.sliderValPercent.toString()+"%",this._config.flipped&&(b.right=m.right?m.right:"0",w.right=f.right?f.right:"auto",w.left=f.left?f.left:"-5px"));const x=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;S(t);break;case"touchstart":this.touchInput=!0,S(t);break;case"mousemove":if(this.touchInput)return;$(t);break;case"touchmove":this._config.disableScroll&&t.preventDefault(),$(t);break;case"mouseup":case"touchend":case"touchcancel":k(t)}},S=t=>{var e;if(this.actionTaken)return;const i=t.clientX||t.touches[0].clientX,n=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=n),this._config.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const s=t.composedPath()[0],o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(s.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(o){const e=o.getBoundingClientRect();if(i>=e.left-this._config.marginOfError&&i<=e.right+this._config.marginOfError&&n>=e.top-this._config.marginOfError&&n<=e.bottom+this._config.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this._config.allowSliding&&(this.actionTaken=!0),this.clientYLast=n,this.clientXLast=i},k=t=>{if(!this.actionTaken)return;this.sliderEl.querySelector(".my-slider-custom-progress").style.transition=this.initialTransition,(this._config.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.touchInput=!1,this.isSliding=!1,setTimeout(()=>{this.actionTaken=!1},50)},$=t=>{if(this.actionTaken){this.sliderEl.querySelector(".my-slider-custom-progress").style.transition="";const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this._config.allowTapping||this.isSliding||!this._config.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this._config.allowSliding&&(this._config.vertical?Math.abs(i-this.clientYLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(x),q`
e=>{if(!(e instanceof A)||e instanceof j||"style"!=
- `}initializeConfig(){var t;if(this.actionTaken)return null;this.entity=this.hass.states[""+this.config.entity];try{this._config=le(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return q`Error with evaluated _config`;const e=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:this._config.entity?this._config.entity.split(".")[0]:"none",i={sliderId:`slider-${this._config.entity.replace(".","-")}-${this._config.mode}`,type:this._config.type,disableScroll:void 0===this._config.disableScroll||this._config.disableScroll,allowTapping:void 0===this._config.allowTapping||this._config.allowTapping,allowSliding:void 0!==this._config.allowSliding&&this._config.allowSliding,marginOfError:void 0!==this._config.marginOfError?this._config.marginOfError:10,slideDistance:void 0!==this._config.slideDistance?this._config.slideDistance:10,showMin:void 0!==this._config.showMin&&this._config.showMin,minThreshold:0,maxThreshold:100,sliderMin:this._config.sliderMin?this._config.sliderMin:0,vertical:void 0!==this._config.vertical&&this._config.vertical,flipped:void 0!==this._config.flipped&&this._config.flipped,inverse:void 0!==this._config.inverse&&this._config.inverse,intermediate:void 0!==this._config.intermediate&&this._config.intermediate,min:this._config.min?this._config.min:0,max:this._config.max?this._config.max:100,step:this._config.step?this._config.step:1,mode:void 0!==this._config.mode?this._config.mode:void 0!==this._config.colorMode?this._config.colorMode:void 0!==this._config.coverMode?this._config.coverMode:"light"===e?"brightness":"cover"===e?"position":"media_player"===e?"volume":"brightness"};let n=0,s=0,o=0;switch(e){case"light":if("brightness"===i.mode)this.oldVal=Math.ceil(ie(this.entity.attributes.brightness,256)),"on"===this.entity.state&&(n=Math.ceil(ie(this.entity.attributes.brightness,256)),!i.showMin&&i.min&&(n-=i.min)),n=n*(100-i.sliderMin)/100+i.sliderMin,n=nthis.updateSeekbar(),500);if("playing"!==this.entity.state)return;let t=0;this._config.max=this.entity.attributes.media_duration;const e=new Date,i=new Date(this.entity.attributes.media_position_updated_at);let n=this.entity.attributes.media_position+(e.getTime()-i.getTime())/1e3;n=Math.min(n,this._config.max),t=n,this.setSliderValues(t,ne(ie(t,this._config.max))),this.setProgress(this.sliderEl,Math.round(t),"updateSeekbar"),setTimeout(()=>this.updateSeekbar(),1e3)}calcProgress(t){if(void 0===this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,n=e.touches[0]||e.changedTouches[0];i.x=n.clientX,i.y=n.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let n=e.getBoundingClientRect(),s=i.x-n.left,o=i.y-n.top;return o=e.offsetHeight-o,{x:s,y:o}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,n=this.sliderEl.offsetHeight,s=(this._config.vertical?ne(e.y/n*100):ne(e.x/i*100))/100*(this._config.max-0),o=this._config.max-s;let r=this._config.flipped?o:s;r=rthis._config.max?this._config.max:r{o.style.transition=this.initialTransition},200)}_setLock(t,e){var i=Math.min(this._config.max,this._config.maxThreshold);if(Number(i)<=e){var n="locked"===t.state?"unlock":"lock";this.hass.callService("lock",n,{entity_id:t.entity_id})}const s=Number(Math.max(this.zero,this._config.minThreshold)),o=ne(ie(s,this._config.max)),r=this.sliderEl.querySelector(".my-slider-custom-progress");this._config.vertical?r.style.transition="height 0.2s ease 0s":r.style.transition="width 0.2s ease 0s",this.setSliderValues(s,o),this.setProgress(this.sliderEl,s,"setLock"),setTimeout(()=>{r.style.transition=this.initialTransition},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}static get styles(){return ht` + `}initializeConfig(){var t;if(this.actionTaken)return null;this.entity=this.hass.states[""+this.config.entity];try{this._config=le(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return q`Error with evaluated _config`;const e=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:this._config.entity?this._config.entity.split(".")[0]:"none",i={sliderId:`slider-${this._config.entity.replace(".","-")}-${this._config.mode}`,type:this._config.type,disableScroll:void 0===this._config.disableScroll||this._config.disableScroll,allowTapping:void 0===this._config.allowTapping||this._config.allowTapping,allowSliding:void 0!==this._config.allowSliding&&this._config.allowSliding,marginOfError:void 0!==this._config.marginOfError?this._config.marginOfError:10,slideDistance:void 0!==this._config.slideDistance?this._config.slideDistance:10,showMin:void 0!==this._config.showMin&&this._config.showMin,minThreshold:0,maxThreshold:100,sliderMin:this._config.sliderMin?this._config.sliderMin:0,vertical:void 0!==this._config.vertical&&this._config.vertical,flipped:void 0!==this._config.flipped&&this._config.flipped,inverse:void 0!==this._config.inverse&&this._config.inverse,intermediate:void 0!==this._config.intermediate&&this._config.intermediate,min:this._config.min?this._config.min:0,max:this._config.max?this._config.max:100,step:this._config.step?this._config.step:1,mode:void 0!==this._config.mode?this._config.mode:void 0!==this._config.colorMode?this._config.colorMode:void 0!==this._config.coverMode?this._config.coverMode:"light"===e?"brightness":"cover"===e?"position":"media_player"===e?"volume":"brightness"};let n=0,s=0,o=0,r=!1;switch(e){case"light":if("brightness"===i.mode)this.oldVal=Math.ceil(ie(this.entity.attributes.brightness,256)),"on"===this.entity.state&&(n=Math.ceil(ie(this.entity.attributes.brightness,256)),!i.showMin&&i.min&&(n-=i.min)),n=n*(100-i.sliderMin)/100+i.sliderMin,n=nthis.updateSeekbar(),500);if("playing"!==this.entity.state)return;let t=0;this._config.max=this.entity.attributes.media_duration;const e=new Date,i=new Date(this.entity.attributes.media_position_updated_at);let n=this.entity.attributes.media_position+(e.getTime()-i.getTime())/1e3;n=Math.min(n,this._config.max),t=n,this.setSliderValues(t,ne(ie(t,this._config.max))),this.setProgress(this.sliderEl,Math.round(t),"updateSeekbar"),setTimeout(()=>this.updateSeekbar(),1e3)}calcProgress(t){if(void 0===this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,n=e.touches[0]||e.changedTouches[0];i.x=n.clientX,i.y=n.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let n=e.getBoundingClientRect(),s=i.x-n.left,o=i.y-n.top;return o=e.offsetHeight-o,{x:s,y:o}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,n=this.sliderEl.offsetHeight,s=(this._config.vertical?ne(e.y/n*100):ne(e.x/i*100))/100*(this._config.max-0),o=this._config.max-s;let r=this._config.flipped?o:s;r=rthis._config.max?this._config.max:r{o.style.transition=this.initialTransition},200)}_setLock(t,e){var i=Math.min(this._config.max,this._config.maxThreshold);if(Number(i)<=e){var n="locked"===t.state?"unlock":"lock";this.hass.callService("lock",n,{entity_id:t.entity_id})}const s=Number(Math.max(this.zero,this._config.minThreshold)),o=ne(ie(s,this._config.max)),r=this.sliderEl.querySelector(".my-slider-custom-progress");this._config.vertical?r.style.transition="height 0.2s ease 0s":r.style.transition="width 0.2s ease 0s",this.setSliderValues(s,o),this.setProgress(this.sliderEl,s,"setLock"),setTimeout(()=>{r.style.transition=this.initialTransition},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}static get styles(){return ht` `}};l([ot()],he.prototype,"_config",void 0),l([ot({attribute:!1})],he.prototype,"hass",void 0),l([at()],he.prototype,"config",void 0),he=l([nt("my-slider-v2")],he);const ue=(t,e,i,n)=>{n=n||{},i=null==i?{}:i;const s=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return s.detail=i,t.dispatchEvent(s),s},ge=1,pe=2,me=3,fe=4,_e=5; /** * @license diff --git a/dist/my-button.js b/dist/my-button.js index d2c393d..74ac637 100644 --- a/dist/my-button.js +++ b/dist/my-button.js @@ -25,7 +25,7 @@ function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPro * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */}const e="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,i=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},n=`{{lit-${String(Math.random()).slice(2)}}}`,s=`\x3c!--${n}--\x3e`,o=new RegExp(`${n}|${s}`);class r{constructor(t,e){this.parts=[],this.element=e;const i=[],s=[],r=document.createTreeWalker(e.content,133,null,!1);let l=0,d=-1,u=0;const{strings:p,values:{length:f}}=t;for(;u0;){const e=p[u],i=h.exec(e)[2],n=i.toLowerCase()+"$lit$",s=t.getAttribute(n);t.removeAttribute(n);const r=s.split(o);this.parts.push({type:"attribute",index:d,name:i,strings:r}),u+=r.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,s=e.split(o),r=s.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},l=t=>-1!==t.index,c=()=>document.createComment(""),h=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function d(t,e){const{element:{content:i},parts:n}=t,s=document.createTreeWalker(i,133,null,!1);let o=p(n),r=n[o],a=-1,l=0;const c=[];let h=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(c.push(t),null===h&&(h=t)),null!==h&&l++;void 0!==r&&r.index===a;)r.index=null!==h?-1:r.index-l,o=p(n,o),r=n[o]}c.forEach(t=>t.parentNode.removeChild(t))}const u=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},p=(t,e=-1)=>{for(let i=e+1;i{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},n=`{{lit-${String(Math.random()).slice(2)}}}`,s=`\x3c!--${n}--\x3e`,o=new RegExp(`${n}|${s}`);class r{constructor(t,e){this.parts=[],this.element=e;const i=[],s=[],r=document.createTreeWalker(e.content,133,null,!1);let l=0,h=-1,u=0;const{strings:p,values:{length:g}}=t;for(;u0;){const e=p[u],i=d.exec(e)[2],n=i.toLowerCase()+"$lit$",s=t.getAttribute(n);t.removeAttribute(n);const r=s.split(o);this.parts.push({type:"attribute",index:h,name:i,strings:r}),u+=r.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(n)>=0){const n=t.parentNode,s=e.split(o),r=s.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},l=t=>-1!==t.index,c=()=>document.createComment(""),d=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function h(t,e){const{element:{content:i},parts:n}=t,s=document.createTreeWalker(i,133,null,!1);let o=p(n),r=n[o],a=-1,l=0;const c=[];let d=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(c.push(t),null===d&&(d=t)),null!==d&&l++;void 0!==r&&r.index===a;)r.index=null!==d?-1:r.index-l,o=p(n,o),r=n[o]}c.forEach(t=>t.parentNode.removeChild(t))}const u=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},p=(t,e=-1)=>{for(let i=e+1;i(...e)=>{const i=t(...e);return f.set(i,!0),i},m=t=>"function"==typeof t&&f.has(t),y={},v={}; +const g=new WeakMap,f=t=>(...e)=>{const i=t(...e);return g.set(i,!0),i},m=t=>"function"==typeof t&&g.has(t),_={},y={}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -53,7 +53,7 @@ const f=new WeakMap,g=t=>(...e)=>{const i=t(...e);return f.set(i,!0),i},m=t=>"fu * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class _{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=e?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),i=[],n=this.template.parts,s=document.createTreeWalker(t,133,null,!1);let o,r=0,a=0,c=s.nextNode();for(;rt}),S=` ${n} `;class w{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let o=0;o-1||i)&&-1===t.indexOf("--\x3e",r+1);const a=h.exec(t);e+=null===a?t+(i?S:s):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==b&&(e=b.createHTML(e)),t.innerHTML=e,t}} + */const b=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),w=` ${n} `;class x{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let o=0;o-1||i)&&-1===t.indexOf("--\x3e",r+1);const a=d.exec(t);e+=null===a?t+(i?w:s):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+n}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==b&&(e=b.createHTML(e)),t.innerHTML=e,t}} /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -79,7 +79,7 @@ class _{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */const C=t=>null===t||!("object"==typeof t||"function"==typeof t),x=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class P{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return M=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class A{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;m(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=y,t(this)}if(this.__pendingValue===y)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=$(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=y}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const $=t=>t&&(M?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */const S=t=>null===t||!("object"==typeof t||"function"==typeof t),k=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class C{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return M=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class O{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;m(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=_,t(this)}if(this.__pendingValue===_)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=A(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=_}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const A=t=>t&&(M?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -92,7 +92,7 @@ class _{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */;function j(t){let e=D.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},D.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const s=t.strings.join(n);return i=e.keyString.get(s),void 0===i&&(i=new r(t,t.getTemplateElement()),e.keyString.set(s,i)),e.stringsArray.set(t.strings,i),i}const D=new Map,H=new WeakMap; + */;function H(t){let e=j.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},j.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const s=t.strings.join(n);return i=e.keyString.get(s),void 0===i&&(i=new r(t,t.getTemplateElement()),e.keyString.set(s,i)),e.stringsArray.set(t.strings,i),i}const j=new Map,D=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -119,7 +119,7 @@ class _{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new N(t,e.slice(1),i).parts}if("@"===s)return[new A(t,e.slice(1),n.eventContext)];if("?"===s)return[new k(t,e.slice(1),i)];return new P(t,e,i).parts}handleTextExpression(t){return new E(t)}}; +class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new N(t,e.slice(1),i).parts}if("@"===s)return[new O(t,e.slice(1),n.eventContext)];if("?"===s)return[new E(t,e.slice(1),i)];return new C(t,e,i).parts}handleTextExpression(t){return new P(t)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -132,7 +132,7 @@ class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new N( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new w(t,e,"html",V) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const R=(t,...e)=>new x(t,e,"html",V) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -145,7 +145,7 @@ class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new N( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */,Y=(t,e)=>`${t}--${e}`;let L=!0;void 0===window.ShadyCSS?L=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),L=!1);const R=t=>e=>{const i=Y(e.type,t);let s=D.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},D.set(i,s));let o=s.stringsArray.get(e.strings);if(void 0!==o)return o;const a=e.strings.join(n);if(o=s.keyString.get(a),void 0===o){const i=e.getTemplateElement();L&&window.ShadyCSS.prepareTemplateDom(i,t),o=new r(e,i),s.keyString.set(a,o)}return s.stringsArray.set(e.strings,o),o},z=["html","svg"],I=new Set,F=(t,e,i)=>{I.add(t);const n=i?i.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,t);const r=document.createElement("style");for(let t=0;t{z.forEach(e=>{const i=D.get(Y(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),d(t,i)})})})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:s}=t;if(null==i)return void n.appendChild(e);const o=document.createTreeWalker(n,133,null,!1);let r=p(s),a=0,l=-1;for(;o.nextNode();){l++;for(o.currentNode===i&&(a=u(e),i.parentNode.insertBefore(e,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=p(s,r);return}r=p(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),d(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const q={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},W=(t,e)=>e!==t&&(e==e||t==t),B={attribute:!0,type:String,converter:q,reflect:!1,hasChanged:W};class J extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=B){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const s=this[t];this[e]=n,this.requestUpdateInternal(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||B}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=W){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||q,s="function"==typeof n?n:n.fromAttribute;return s?s(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||q.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=B){const n=this.constructor,s=n._attributeNameForProperty(t,i);if(void 0!==s){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(s):this.setAttribute(s,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let n=!0;if(void 0!==t){const s=this.constructor;i=i||s.getPropertyOptions(t),s._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}J.finalized=!0; + */,L=(t,e)=>`${t}--${e}`;let U=!0;void 0===window.ShadyCSS?U=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),U=!1);const Y=t=>e=>{const i=L(e.type,t);let s=j.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},j.set(i,s));let o=s.stringsArray.get(e.strings);if(void 0!==o)return o;const a=e.strings.join(n);if(o=s.keyString.get(a),void 0===o){const i=e.getTemplateElement();U&&window.ShadyCSS.prepareTemplateDom(i,t),o=new r(e,i),s.keyString.set(a,o)}return s.stringsArray.set(e.strings,o),o},z=["html","svg"],I=new Set,F=(t,e,i)=>{I.add(t);const n=i?i.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,t);const r=document.createElement("style");for(let t=0;t{z.forEach(e=>{const i=j.get(L(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),h(t,i)})})})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:s}=t;if(null==i)return void n.appendChild(e);const o=document.createTreeWalker(n,133,null,!1);let r=p(s),a=0,l=-1;for(;o.nextNode();){l++;for(o.currentNode===i&&(a=u(e),i.parentNode.insertBefore(e,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=p(s,r);return}r=p(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),h(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const q={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},B=(t,e)=>e!==t&&(e==e||t==t),W={attribute:!0,type:String,converter:q,reflect:!1,hasChanged:B};class J extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=W){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const s=this[t];this[e]=n,this.requestUpdateInternal(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||W}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=B){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||q,s="function"==typeof n?n:n.fromAttribute;return s?s(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||q.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=W){const n=this.constructor,s=n._attributeNameForProperty(t,i);if(void 0!==s){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(s):this.setAttribute(s,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let n=!0;if(void 0!==t){const s=this.constructor;i=i||s.getPropertyOptions(t),s._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}J.finalized=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -183,7 +183,7 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const et={};class it extends J{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!G){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new Q(String(e),K)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?G?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==et&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return et}}it.finalized=!0,it.render=(t,e,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const s=n.scopeName,o=H.has(e),r=L&&11===e.nodeType&&!!e.host,a=r&&!I.has(s),l=a?document.createDocumentFragment():e;if(((t,e,n)=>{let s=H.get(e);void 0===s&&(i(e,e.firstChild),H.set(e,s=new E(Object.assign({templateFactory:j},n))),s.appendInto(e)),s.setValue(t),s.commit()})(t,l,Object.assign({templateFactory:R(s)},n)),a){const t=H.get(l);H.delete(l);const n=t.value instanceof _?t.value.template:void 0;F(s,l,n),i(e,e.firstChild),e.appendChild(l),H.set(e,t)}!o&&r&&window.ShadyCSS.styleElement(e.host)},it.shadowRootOptions={mode:"open"}; +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const et={};class it extends J{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!G){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new Q(String(e),K)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?G?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==et&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return et}}it.finalized=!0,it.render=(t,e,n)=>{if(!n||"object"!=typeof n||!n.scopeName)throw new Error("The `scopeName` option is required.");const s=n.scopeName,o=D.has(e),r=U&&11===e.nodeType&&!!e.host,a=r&&!I.has(s),l=a?document.createDocumentFragment():e;if(((t,e,n)=>{let s=D.get(e);void 0===s&&(i(e,e.firstChild),D.set(e,s=new P(Object.assign({templateFactory:H},n))),s.appendInto(e)),s.setValue(t),s.commit()})(t,l,Object.assign({templateFactory:Y(s)},n)),a){const t=D.get(l);D.delete(l);const n=t.value instanceof v?t.value.template:void 0;F(s,l,n),i(e,e.firstChild),e.appendChild(l),D.set(e,t)}!o&&r&&window.ShadyCSS.styleElement(e.host)},it.shadowRootOptions={mode:"open"}; /** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. @@ -197,79 +197,124 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const nt=new WeakMap,st=g(t=>e=>{if(!(e instanceof T)||e instanceof O||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let s=nt.get(e);void 0===s&&(n.cssText=i.strings.join(" "),nt.set(e,s=new Set)),s.forEach(e=>{e in t||(s.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))});for(const e in t)s.add(e),-1===e.indexOf("-")?n[e]=t[e]:n.setProperty(e,t[e])});var ot=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,rt="[^\\s]+",at=/\[([^]*?)\]/gm;function lt(t,e){for(var i=[],n=0,s=t.length;n-1?n:null}};function ht(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},gt=ht({},ft),mt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+mt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+mt(Math.floor(Math.abs(e)/60),2)+":"+mt(Math.abs(e)%60,2)}},vt=function(t){return+t-1},_t=[null,"[1-9]\\d?"],bt=[null,rt],St=["isPm",rt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],wt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Ct=(ct("monthNamesShort"),ct("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var xt,Pt,Tt=function(t,e,i){if(void 0===e&&(e=Ct.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=Ct[e]||e).replace(at,(function(t,e){return n.push(e),"@@@"}));var s=ht(ht({},gt),i);return(e=e.replace(ot,(function(e){return yt[e](t,s)}))).replace(/@@@/g,(function(){return n.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function Et(){return(Et=Object.assign||function(t){for(var e=1;e0||navigator.msMaxTouchPoints>0;class $t extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:At?"100px":"50px",height:At?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0},{passive:!0})})}bind(t,e){if(t.actionHandler)return;t.actionHandler=!0,t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1});const i=t=>{let e,i;this.held=!1,t.touches?(e=t.touches[0].pageX,i=t.touches[0].pageY):(e=t.pageX,i=t.pageY),this.timer=window.setTimeout(()=>{this.startAnimation(e,i),this.held=!0},this.holdTime)},n=i=>{i.preventDefault(),["touchend","touchcancel"].includes(i.type)&&void 0===this.timer||(clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0,this.held?Nt(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Nt(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Nt(t,"action",{action:"double_tap"})):Nt(t,"action",{action:"tap"}))};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",n),t.addEventListener("touchcancel",n),t.addEventListener("mousedown",i,{passive:!0}),t.addEventListener("click",n),t.addEventListener("keyup",t=>{13===t.keyCode&&n(t)})}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null}),this.ripple.disabled=!1,this.ripple.active=!0,this.ripple.unbounded=!0}stopAnimation(){this.ripple.active=!1,this.ripple.disabled=!0,this.style.display="none"}}customElements.define("action-handler-my-footer",$t);const jt=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("action-handler-my-footer"))return t.querySelector("action-handler-my-footer");const e=document.createElement("action-handler-my-footer");return t.appendChild(e),e})();i&&i.bind(t,e)},Dt=g((t={})=>e=>{jt(e.committer.element,t)});var Ht={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Vt={common:Ht},Ut={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Yt={common:Ut};const Lt={en:Object.freeze({__proto__:null,common:Ht,default:Vt}),nb:Object.freeze({__proto__:null,common:Ut,default:Yt})};const Rt=(t,e={})=>{const i=zt[t];return i?i(e):void console.log(t+": Not found in styles")},zt={card:t=>Object.assign({height:"125px",width:"100%","min-width":"fit-content",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer"},t),icon:t=>Object.assign({"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",padding:"10px 0 0 10px",color:"var(--paper-item-icon-color)"},t),stats:t=>Object.assign({"margin-left":"auto","margin-right":"5px","margin-top":"5px","margin-bottom":"5px",color:"var(--primary-text-color)",display:"grid","place-items":"center","aspect-ratio":"1 / 1","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, 0.5)"},t),"label-wrapper":t=>Object.assign({width:"100%",height:"100%",display:"flex"},t),label:t=>Object.assign({padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},t),container:t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"column",height:"100%"},t),row1:t=>Object.assign({flex:"0 1 auto",display:"flex","justify-content":"space-between"},t),row2:t=>Object.assign({flex:"1 1 auto"},t),row3:t=>Object.assign({flex:"0 1 auto"},t),"container-column":t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"row",height:"100%"},t),column1:t=>Object.assign({flex:"1"},t),column2:t=>Object.assign({flex:"0"},t)},It=function(t,e,i){var n,s;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(n=o,s=t[o],e.push(n),"object"==typeof s&&null!==s?i=It(s,e,i):i[e[e.length-1]]=s,e.pop());return i},Ft=(t,e=100,i=0)=>t/(e-i)*100;function qt(t,e){const i=Object.assign({},t);return Wt(t)&&Wt(e)&&Object.keys(e).forEach(n=>{Array.isArray(e[n])?i[n]=e[n].map((e,i)=>t[n]&&Wt(t[n][i])&&Wt(e)?qt(t[n][i],e):e):Wt(e[n])?n in t?i[n]=qt(t[n],e[n]):Object.assign(i,{[n]:e[n]}):Object.assign(i,{[n]:e[n]})}),i}function Wt(t){return t&&"object"==typeof t&&!Array.isArray(t)}console.info(`%c ---- MY-BUTTON ---- \n%c ${function(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce((t,e)=>t[e],Lt[n])}catch(e){s=t.split(".").reduce((t,e)=>t[e],Lt.en)}return void 0===s&&(s=t.split(".").reduce((t,e)=>t[e],Lt.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s}("common.version")} 1.0.1 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-button",name:"My Button Card",description:"Custom Button Card for Lovelace."});let Bt=class extends it{constructor(){super(...arguments),this.lastAction=0,this.layout="vertical",this.iconConfig={},this.labelConfig={},this.sliderConfig={},this.statsConfig={},this.cardStl={},this.containerStl={},this.containerColumnStl={},this.iconStl={},this.statsStl={},this.labelWrapperStl={},this.labelStl={},this.row1Stl={},this.row2Stl={},this.row3Stl={},this.column1Stl={},this.column2Stl={}}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","cover","switch"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MyButton"},t)}shouldUpdate(t){return!!this.config&&function(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}render(){const t=this.initializeConfig();return null!==t?t:this.entity&&this._config?"vertical"===this.layout?this.verticalLayoutCard():this.horizontalLayoutCard():U``}verticalLayoutCard(){var t,e,i,n,s,o,r,a;return U` - -
-
this._handleAction(t,this.config)} - .actionHandler=${Dt({hasDoubleClick:"none"!==(null===(e=null===(t=this.config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(n=null===(i=this.config)||void 0===i?void 0:i.hold_action)||void 0===n?void 0:n.action)})}> - ${this.iconElement()} +const nt=new WeakMap,st=f(t=>e=>{if(!(e instanceof T)||e instanceof $||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let s=nt.get(e);void 0===s&&(n.cssText=i.strings.join(" "),nt.set(e,s=new Set)),s.forEach(e=>{e in t||(s.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))});for(const e in t)s.add(e),-1===e.indexOf("-")?n[e]=t[e]:n.setProperty(e,t[e])});var ot=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,rt="[^\\s]+",at=/\[([^]*?)\]/gm;function lt(t,e){for(var i=[],n=0,s=t.length;n-1?n:null}};function dt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},ft=dt({},gt),mt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+mt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+mt(Math.floor(Math.abs(e)/60),2)+":"+mt(Math.abs(e)%60,2)}},yt=function(t){return+t-1},vt=[null,"[1-9]\\d?"],bt=[null,rt],wt=["isPm",rt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],xt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],St=(ct("monthNamesShort"),ct("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var kt,Ct,Tt=function(t,e,i){if(void 0===e&&(e=St.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=St[e]||e).replace(at,(function(t,e){return n.push(e),"@@@"}));var s=dt(dt({},ft),i);return(e=e.replace(ot,(function(e){return _t[e](t,s)}))).replace(/@@@/g,(function(){return n.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();(Ct=kt||(kt={})).language="language",Ct.system="system",Ct.comma_decimal="comma_decimal",Ct.decimal_comma="decimal_comma",Ct.space_comma="space_comma",Ct.none="none";const Pt=(Et=["unavailable","unknown"],(t,e)=>Et.includes(t,e));var Et;const Nt=(t,e,i,n)=>{n=n||{},i=null==i?{}:i;const s=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return s.detail=i,t.dispatchEvent(s),s},$t=(t,e=100,i=0)=>t/(e-i)*100;function Mt(t,e){if(!Ot(t))return Ot(e)?e:{};if(!Ot(e))return Ot(t)?t:{};if(Ot(t)&&Ot(e)){const i=Object.assign({},t);return Object.keys(e).forEach(n=>{Array.isArray(e[n])?i[n]=e[n].map((e,i)=>t[n]&&Ot(t[n][i])&&Ot(e)?Mt(t[n][i],e):e):Ot(e[n])?n in t?i[n]=Mt(t[n],e[n]):Object.assign(i,{[n]:e[n]}):Object.assign(i,{[n]:e[n]})}),i}return{}}function Ot(t){return t&&"object"==typeof t&&!Array.isArray(t)}function At(t,e){if(void 0===t)return!1;const i=(n=t.entity_id).substring(0,n.indexOf("."));var n;const s=void 0!==e?e:null==t?void 0:t.state;if(["button","event","input_button","scene"].includes(i))return"unavailable"!==s;if(Pt(s))return!1;if("off"===s&&"alert"!==i)return!1;switch(i){case"alarm_control_panel":return"disarmed"!==s;case"alert":return"idle"!==s;case"cover":return"closed"!==s;case"device_tracker":case"person":return"not_home"!==s;case"lock":return"locked"!==s;case"media_player":return"standby"!==s;case"vacuum":return!["idle","docked","paused"].includes(s);case"plant":return"problem"===s;case"group":return["on","home","open","locked","problem"].includes(s);case"timer":return"active"===s;case"camera":return"streaming"===s}return!0}const Ht=(t,e)=>{if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;let i,n;if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(!Ht(t[i],e[i]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;for(i of t.entries())if(!Ht(i[1],e.get(i[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(t[i]!==e[i])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,s[i]))return!1;for(i=n;0!=i--;){const n=s[i];if(!Ht(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},jt=1,Dt=2,Vt=3,Rt=4,Lt=5; +/** + * @license + * Copyright (c) 2021 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */class Ut{constructor(t){this.type=Dt,this.options=t.options,this.legacyPart=t}get parentNode(){return this.legacyPart.startNode.parentNode}get startNode(){return this.legacyPart.startNode}get endNode(){return this.legacyPart.endNode}}class Yt{constructor(t){this.legacyPart=t,this.type=t instanceof $?Vt:jt}get options(){}get name(){return this.legacyPart.committer.name}get element(){return this.legacyPart.committer.element}get strings(){return this.legacyPart.committer.strings}get tagName(){return this.element.tagName}}class zt{constructor(t){this.type=Rt,this.legacyPart=t}get options(){}get name(){return this.legacyPart.name}get element(){return this.legacyPart.element}get strings(){return this.legacyPart.strings}get tagName(){return this.element.tagName}}class It{constructor(t){this.type=Lt,this.legacyPart=t}get options(){}get name(){return this.legacyPart.eventName}get element(){return this.legacyPart.element}get strings(){}get tagName(){return this.element.tagName}handleEvent(t){this.legacyPart.handleEvent(t)}}const Ft="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class qt extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.cancelled=!1,this.isRepeating=!1,this.repeatCount=0}connectedCallback(){Object.assign(this.style,{position:"fixed",width:Ft?"100px":"50px",height:Ft?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{this.cancelled=!0,this.timer&&(this.stopAnimation(),clearTimeout(this.timer),this.timer=void 0,this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1))},{passive:!0})})}bind(t,e){t.actionHandler&&Ht(e,t.actionHandler.options)||(t.actionHandler?(t.removeEventListener("touchstart",t.actionHandler.start),t.removeEventListener("touchend",t.actionHandler.end),t.removeEventListener("touchcancel",t.actionHandler.end),t.removeEventListener("mousedown",t.actionHandler.start),t.removeEventListener("click",t.actionHandler.end),t.removeEventListener("keyup",t.actionHandler.handleEnter)):t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1}),t.actionHandler={options:e},e.disabled||(t.actionHandler.start=i=>{let n,s;this.cancelled=!1,i.touches?(n=i.touches[0].clientX,s=i.touches[0].clientY):(n=i.clientX,s=i.clientY),e.hasHold&&(this.held=!1,this.timer=window.setTimeout(()=>{this.startAnimation(n,s),this.held=!0,e.repeat&&!this.isRepeating&&(this.repeatCount=0,this.isRepeating=!0,this.repeatTimeout=setInterval(()=>{Nt(t,"action",{action:"hold"}),this.repeatCount++,this.repeatTimeout&&e.repeatLimit&&this.repeatCount>=e.repeatLimit&&(clearInterval(this.repeatTimeout),this.isRepeating=!1)},e.repeat))},this.holdTime))},t.actionHandler.end=t=>{if(["touchend","touchcancel"].includes(t.type)&&this.cancelled)return void(this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1));const i=t.target;t.cancelable&&t.preventDefault(),e.hasHold&&(clearTimeout(this.timer),this.isRepeating&&this.repeatTimeout&&clearInterval(this.repeatTimeout),this.isRepeating=!1,this.stopAnimation(),this.timer=void 0),e.hasHold&&this.held?e.repeat||Nt(i,"action",{action:"hold"}):e.hasDoubleClick?"click"===t.type&&t.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Nt(i,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Nt(i,"action",{action:"double_tap"})):Nt(i,"action",{action:"tap"})},t.actionHandler.handleEnter=t=>{13===t.keyCode&&t.currentTarget.actionHandler.end(t)},t.addEventListener("touchstart",t.actionHandler.start,{passive:!0}),t.addEventListener("touchend",t.actionHandler.end),t.addEventListener("touchcancel",t.actionHandler.end),t.addEventListener("mousedown",t.actionHandler.start,{passive:!0}),t.addEventListener("click",t.actionHandler.end),t.addEventListener("keyup",t.actionHandler.handleEnter)))}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null})}stopAnimation(){}}customElements.define("my-card-action-handler",qt);const Bt=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("my-card-action-handler"))return t.querySelector("my-card-action-handler");const e=document.createElement("my-card-action-handler");return t.appendChild(e),e})();i&&i.bind(t,e)},Wt=function(t){const e=new WeakMap;return f((...i)=>n=>{const s=e.get(n);let o,r;void 0===s?(o=function(t){if(t instanceof P)return new Ut(t);if(t instanceof O)return new It(t);if(t instanceof E)return new zt(t);if(t instanceof $||t instanceof T)return new Yt(t);throw new Error("Unknown part type")}(n),r=new t(o),e.set(n,[o,r])):(o=s[0],r=s[1]),n.setValue(r.update(o,i)),n.commit()})}(class extends class{constructor(t){}update(t,e){return this.render(...e)}}{update(t,[e]){return Bt(t.element,e),_}render(t){}});var Jt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Zt={common:Jt},Xt={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Gt={common:Xt};const Kt={en:Object.freeze({__proto__:null,common:Jt,default:Zt}),nb:Object.freeze({__proto__:null,common:Xt,default:Gt})};const Qt=(t,e={})=>{const i=te[t];return i?Mt(i,e):(console.log(t+": Not found in styles"),e)},te={card:{height:"125px",width:"100%",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer",display:"flex","flex-direction":"column"},icon:{"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",color:"var(--paper-item-icon-color)","border-radius":"50%",margin:"7px 0px 0px 7px"},stats:{margin:"5px 2px 0px auto",color:"var(--primary-text-color)",display:"inline-block","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, .9)",width:"50px",height:"50px",padding:"0px 3px"},camera:{"border-radius":"3px",overflow:"hidden"},labelContainer:{width:"100%",height:"100%",display:"flex","flex-direction":"column","align-items":"flex-start",overflow:"hidden"},label:{padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},extraText:{margin:"0 10px",color:"var(--primary-text-color)","font-weight":"normal","font-size":"12px","white-space":"nowrap",overflow:"hidden"},row1:{display:"flex","justify-content":"space-between","min-height":"55px"},row2:{},buttonsContainer:{display:"flex","align-items":"flex-start","flex-direction":"row",padding:"0px 5px"},button:{padding:"3px 5px 3px 5px","aspect-ratio":"1 / 1",display:"flex","align-items":"center","justify-content":"center"},buttonText:{padding:"0px",margin:"0px"},buttonIcon:{padding:"0px",margin:"0px",position:"relative","--mdc-icon-size":"100%",display:"flex",height:"20px",width:"20px"},sliderCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"},sliderContainer:{"border-radius":"0px"},sliderTrack:{background:"transparent"},sliderThumbHor:{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"},sliderThumbVer:{width:"20px",height:"3px",top:"2px",left:"7px","border-radius":"50px"},sliderProgressHor:{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"},sliderProgressVer:{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"},seekbarCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default","margin-left":"30px"},seekbarContainer:{"border-radius":"0px"},seekbarTrack:{background:"transparent"},seekbarThumb:{height:"100%",width:"3px",right:"0px","border-radius":"50px",background:"linear-gradient(to top, var(--paper-item-icon-active-color) -20%, transparent 70%)"},seekbarProgress:{background:"transparent"}},ee=function(t,e,i){var n,s;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(n=o,s=t[o],e.push(n),"object"==typeof s&&null!==s?i=ee(s,e,i):i[e[e.length-1]]=s,e.pop());return i},ie=(t,e,i)=>{if(["number","boolean"].includes(typeof i))return i;if(!i)return i;if("object"==typeof i)return Object.keys(i).forEach(n=>{i[n]=ie(t,e,i[n])}),i;const n=i.trim();if("[[["===n.substring(0,3)&&"]]]"===n.slice(-3)){return ne(t,e,n.slice(3,-3))}return i},ne=(t,e,i)=>{try{return new Function("states","entity","user","hass","html","'use strict'; "+i).call(t,t.hass.states,e,t.hass.user,t.hass,R)}catch(t){if(t instanceof Error){const e=i.length<=100?i.trim():i.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${e}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}};console.info(`%c ---- MY-BUTTON ---- \n%c ${function(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce((t,e)=>t[e],Kt[n])}catch(e){s=t.split(".").reduce((t,e)=>t[e],Kt.en)}return void 0===s&&(s=t.split(".").reduce((t,e)=>t[e],Kt.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s}("common.version")} 1.0.2 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-button",name:"My Button Card",description:"Custom Button Card for Lovelace."});let se=class extends it{constructor(){super(...arguments),this.lastAction=0}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["","light","cover","switch","input_boolean","button","lock","media_player"];if(t.entity&&!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MyButton"},t)}shouldUpdate(t){return!!this.config&&function(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}updated(t){super.updated(t),requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('[data-container="label-row"]'),i=null==e?void 0:e.querySelector("p");if(e&&i){const t=window.getComputedStyle(i),n=window.getComputedStyle(e),s=e.offsetWidth,o=i.offsetWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),r=s-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight);i.style.animation=o +
+
this._handleAction(t,this._config)} + .actionHandler=${Wt({hasDoubleClick:"none"!==(null===(e=null===(t=this._config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(n=null===(i=this._config)||void 0===i?void 0:i.hold_action)||void 0===n?void 0:n.action),repeat:null===(o=null===(s=this._config)||void 0===s?void 0:s.hold_action)||void 0===o?void 0:o.repeat,repeatLimit:null===(a=null===(r=this._config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.repeat_limit})}> +
+ ${this.iconElement()} + ${this.statsElement()} +
+
+ ${this.labelElement()} +
- ${this.statsElement()}
-
this._handleAction(t,this.config)} - .actionHandler=${Dt({hasDoubleClick:"none"!==(null===(o=null===(s=this.config)||void 0===s?void 0:s.double_tap_action)||void 0===o?void 0:o.action),hasHold:"none"!==(null===(a=null===(r=this.config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.action)})}> - ${this.labelElement()} +
+ ${!1===this._config.buttons.vertical?this.buttonsElement():""}
-
- ${this.sliderElement()} +
+ ${!1===this._config.slider.vertical?this.sliderElement():""} + ${this._config.seekbar.show?this.seekbarElement():""} +
+
+ ${!0===this._config.buttons.vertical?this.buttonsElement():""} +
+
+ ${!0===this._config.slider.vertical?this.sliderElement():""}
- `}horizontalLayoutCard(){var t,e,i,n,s,o,r,a;return U` - -
-
-
-
this._handleAction(t,this.config)} - .actionHandler=${Dt({hasDoubleClick:"none"!==(null===(e=null===(t=this.config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(n=null===(i=this.config)||void 0===i?void 0:i.hold_action)||void 0===n?void 0:n.action)})}> - ${this.iconElement()} -
-
this._handleAction(t,this.config)} - .actionHandler=${Dt({hasDoubleClick:"none"!==(null===(o=null===(s=this.config)||void 0===s?void 0:s.double_tap_action)||void 0===o?void 0:o.action),hasHold:"none"!==(null===(a=null===(r=this.config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.action)})}> - ${this.labelElement()} -
-
-
+ `}iconElement(){var t,e,i,n;return this._config.icon.show?this._config.icon.tap_action||this._config.icon.double_tap_action||this._config.icon.hold_action?R` + this._handleAction(t,this._config.icon)} + .actionHandler=${Wt({hasDoubleClick:"none"!==(null===(t=this._config.icon.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this._config.icon.hold_action)||void 0===e?void 0:e.action),repeat:null===(i=this._config.icon.hold_action)||void 0===i?void 0:i.repeat,repeatLimit:null===(n=this._config.icon.hold_action)||void 0===n?void 0:n.repeat_limit})} /> + `:R` + + `:R``}statsElement(){var t,e,i,n,s,o,r,a;return this._config.stats.show?this._config.stats.tap_action||this._config.stats.double_tap_action||this._config.stats.hold_action?this._config.camera?R` +
this._handleAction(t,this._config.stats)} + .actionHandler=${Wt({hasDoubleClick:"none"!==(null===(t=this._config.stats.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this._config.stats.hold_action)||void 0===e?void 0:e.action),repeat:null===(i=this._config.stats.hold_action)||void 0===i?void 0:i.repeat,repeatLimit:null===(n=this._config.stats.hold_action)||void 0===n?void 0:n.repeat_limit})}> +
+ + ${this._config.stats.text}
-
- ${this.sliderElement()} + `:R` +
this._handleAction(t,this._config.stats)} + .actionHandler=${Wt({hasDoubleClick:"none"!==(null===(s=this._config.stats.double_tap_action)||void 0===s?void 0:s.action),hasHold:"none"!==(null===(o=this._config.stats.hold_action)||void 0===o?void 0:o.action),repeat:null===(r=this._config.stats.hold_action)||void 0===r?void 0:r.repeat,repeatLimit:null===(a=this._config.stats.hold_action)||void 0===a?void 0:a.repeat_limit})}> + +
+ ${this._config.stats.text} +
+
+ `:this._config.camera?R` +
+
+ +
+
+ `:R` +
+
+ ${this._config.stats.text} +
+
+ `:R``}labelElement(){var t,e,i,n;return this._config.label.show?this._config.label.tap_action||this._config.label.double_tap_action||this._config.label.hold_action?R` +
+ + ${this._config.label.extra?R`

${this._config.label.extra}

`:""} +
- - `}iconElement(){var t,e;return this.iconConfig.show?this.iconConfig.tap_action||this.iconConfig.double_tap_action||this.iconConfig.hold_action?U` - this._handleAction(t,this.iconConfig)} - .actionHandler=${Dt({hasDoubleClick:"none"!==(null===(t=this.iconConfig.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this.iconConfig.hold_action)||void 0===e?void 0:e.action)})} /> - `:U` - - `:U``}statsElement(){var t,e;return this.statsConfig.show?this.statsConfig.tap_action||this.statsConfig.double_tap_action||this.statsConfig.hold_action?U` -
this._handleAction(t,this.statsConfig)} - .actionHandler=${Dt({hasDoubleClick:"none"!==(null===(t=this.statsConfig.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this.statsConfig.hold_action)||void 0===e?void 0:e.action)})}> - - ${this.statsConfig.text} - -
- `:U` -
- ${this.statsConfig.text} -
- `:U``}labelElement(){var t,e;return this.labelConfig.show?this.labelConfig.tap_action||this.labelConfig.double_tap_action||this.labelConfig.hold_action?U` -
- -
- `:U` -
- + `:R` +
+ + ${this._config.label.extra?R`

${this._config.label.extra}

`:""}
- `:U``}sliderElement(){return this.sliderConfig.show?("horizontal"===this.layout&&(this.sliderConfig.vertical=void 0===this.sliderConfig.vertical||this.sliderConfig.vertical,this.sliderConfig.styles=this.sliderConfig.styles?this.sliderConfig.styles:{},this.sliderConfig.styles.card=this.sliderConfig.styles.card?this.sliderConfig.styles.card:{},this.sliderConfig.styles.card.width=this.sliderConfig.styles.card.width?this.sliderConfig.styles.card.width:"35px"),U` - - `):U``}initializeConfig(){var t,e,i,n,s,o,r,a,l,c,h,d,u,p,f,g,m,y,v,_,b,S,w;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=this._objectEvalTemplate(this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return U`Error with this._config...`;const C=this._config.entity.split(".")[0],x={show:!0,icon:"mdi:lightbulb-outline"};"cover"===C?x.icon=(null===(t=this.entity.attributes)||void 0===t?void 0:t.current_position)>=50?"mdi:blinds-open":"mdi:blinds":"switch"===C&&(x.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off");const P={show:!0,text:this.entity.attributes.friendly_name};this.layout=this._config.layout?this._config.layout:"vertical","cover"===this._config.entity.split(".")[0]&&(this.layout=this._config.layout?this._config.layout:"horizontal"),this.iconConfig="string"==typeof this._config.icon?Object.assign(Object.assign({},x),{icon:this._config.icon}):"object"==typeof this._config.icon?qt(x,this._config.icon):x,this.labelConfig="string"==typeof this._config.label?Object.assign(Object.assign({},P),{text:this._config.label}):"object"==typeof this._config.label?qt(P,this._config.label):P;const T={show:!!this.entity.attributes.brightness,text:this.entity.attributes.brightness&&Math.ceil(Ft(this.entity.attributes.brightness,256))};this.statsConfig="string"==typeof this._config.stats?Object.assign(Object.assign({},T),{text:this._config.stats}):"object"==typeof this._config.stats?qt(T,this._config.stats):T;const E={show:!0,entity:this.entity.entity_id,styles:{card:[{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"}],container:[{"border-radius":"0px"}],thumb:"vertical"===this.layout?[{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"}]:[{width:"20px",height:"3px",bottom:"2px",left:"7px","border-radius":"50px"}],track:[{background:"transparent"}],progress:"vertical"===this.layout?[{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"}]:[{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"}]}};"switch"===C&&(E.show=!1),this.sliderConfig=this._config.slider?qt(E,this._config.slider):E;let k=[];if("light"===C)if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;k=[{background:`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(Ft(this.entity.attributes.brightness,256))/t+"%"})`}]}else k=[{background:"radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)"}];else if("switch"===C){k=[{background:"on"===this.entity.state?"radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 50%)":"radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)"}]}const N=(null===(e=this._config.styles)||void 0===e?void 0:e.card)?Object.assign(Object.assign({},k),this._config.styles.card):k,O=[{color:"on"===this.entity.state?"var(--paper-item-icon-active-color)":"var(--paper-item-icon-color)"},{filter:"on"===this.entity.state?"drop-shadow(2px 2px 2px rgba(0,0,0,0.6)":"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"}],M=(null===(i=this._config.styles)||void 0===i?void 0:i.icon)?Object.assign(Object.assign({},O),this._config.styles.icon):O;return this.cardStl=Rt("card",It(N)?It(N):{}),this.containerStl=Rt("container",It(null===(n=this._config.styles)||void 0===n?void 0:n.container)?It(null===(s=this._config.styles)||void 0===s?void 0:s.container):{}),this.containerColumnStl=Rt("container-column",It(null===(o=this._config.styles)||void 0===o?void 0:o.containerColumn)?It(null===(r=this._config.styles)||void 0===r?void 0:r.containerColumn):{}),this.iconStl=Rt("icon",It(M)?It(M):{}),this.statsStl=Rt("stats",It(null===(a=this._config.styles)||void 0===a?void 0:a.stats)?It(null===(l=this._config.styles)||void 0===l?void 0:l.stats):{}),this.labelWrapperStl=Rt("label-wrapper",It(null===(c=this._config.styles)||void 0===c?void 0:c.labelWrapper)?It(null===(h=this._config.styles)||void 0===h?void 0:h.labelWrapper):{}),this.labelStl=Rt("label",It(null===(d=this._config.styles)||void 0===d?void 0:d.label)?It(null===(u=this._config.styles)||void 0===u?void 0:u.label):{}),this.row1Stl=Rt("row1",It(null===(p=this._config.styles)||void 0===p?void 0:p.row1)?It(null===(f=this._config.styles)||void 0===f?void 0:f.row1):{}),this.row2Stl=Rt("row2",It(null===(g=this._config.styles)||void 0===g?void 0:g.row2)?It(null===(m=this._config.styles)||void 0===m?void 0:m.row2):{}),this.row3Stl=Rt("row3",It(null===(y=this._config.styles)||void 0===y?void 0:y.row3)?It(null===(v=this._config.styles)||void 0===v?void 0:v.row3):{}),this.column1Stl=Rt("column1",It(null===(_=this._config.styles)||void 0===_?void 0:_.column1)?It(null===(b=this._config.styles)||void 0===b?void 0:b.column1):{}),this.column2Stl=Rt("column2",It(null===(S=this._config.styles)||void 0===S?void 0:S.column2)?It(null===(w=this._config.styles)||void 0===w?void 0:w.column2):{}),null}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<100)&&(this.lastAction=(new Date).getTime(),e.entity||(e.entity=this._config.entity),null===(i=t.detail)||void 0===i?void 0:i.action))switch(t.detail.action){case"tap":e.tap_action&&this._handleTap(e);break;case"hold":e.hold_action&&this._handleHold(e);break;case"double_tap":e.double_tap_action&&this._handleDblTap(e)}}_handleTap(t){Mt(this,this.hass,this._evalActions(this._config,"tap_action"),!1,!1)}_handleHold(t){Mt(this,this.hass,this._evalActions(this._config,"hold_action"),!0,!1)}_handleDblTap(t){Mt(this,this.hass,this._evalActions(this._config,"double_tap_action"),!1,!0)}_evalActions(t,e){const i=JSON.parse(JSON.stringify(t)),n=t=>t?(Object.keys(t).forEach(e=>{"object"==typeof t[e]?t[e]=n(t[e]):t[e]=this._getTemplateOrValue(this.entity,t[e])}),t):t;return i[e]=n(i[e]),!i[e].confirmation&&i.confirmation&&(i[e].confirmation=n(i.confirmation)),i}_objectEvalTemplate(t,e){const i=JSON.parse(JSON.stringify(e));return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach(i=>{e[i]=this._getTemplateOrValue(t,e[i])}),e;const i=e.trim();if("[[["===i.substring(0,3)&&"]]]"===i.slice(-3)){return this._evalTemplate(t,i.slice(3,-3))}return e}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","html","'use strict'; "+e).call(this,this.hass.states,t,this.hass.user,this.hass,U)}catch(t){if(t instanceof Error){const i=e.length<=100?e.trim():e.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${i}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}}static get styles(){return tt``}};var Jt,Zt;t([X()],Bt.prototype,"_config",void 0),t([X({attribute:!1})],Bt.prototype,"hass",void 0),t([function(t){return X({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(Jt)],Bt.prototype,"config",void 0),Bt=t([(Zt="my-button",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(Zt,t):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(Zt,t))],Bt);export{Bt as MyButton}; + `:R``}sliderElement(){return this._config.slider.show?R` + + `:R``}buttonsElement(){if(!this._config.buttons.show)return R``;let t=Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>{var e,i,n,s;return this._config.buttons[t].show?this._config.buttons[t].tap_action||this._config.buttons[t].double_tap_action||this._config.buttons[t].hold_action?R` +
this._handleAction(e,this._config.buttons[t])} + .actionHandler=${Wt({hasDoubleClick:"none"!==(null===(e=this._config.buttons[t].double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(i=this._config.buttons[t].hold_action)||void 0===i?void 0:i.action),repeat:null===(n=this._config.buttons[t].hold_action)||void 0===n?void 0:n.repeat,repeatLimit:null===(s=this._config.buttons[t].hold_action)||void 0===s?void 0:s.repeat_limit})}> + ${this._config.buttons[t].text?R`

${this._config.buttons[t].text}

`:""} + ${this._config.buttons[t].icon?R``:""} +
`:R` +
+ ${this._config.buttons[t].text?R`

${this._config.buttons[t].text}

`:""} + ${this._config.buttons[t].icon?R``:""} +
`:R``});return R` +
+ ${t} + +
+ `}seekbarElement(){return this._config.slider.show?R` + + `:R``}initializeConfig(){var t,e;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=((t,e,i)=>{const n=JSON.parse(JSON.stringify(i));return ie(t,e,n)})(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return R`Error with this._config...`;const i=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",n={},s={show:!0,icon:"mdi:power"},o={show:!0},r={show:!1},a={show:!1,vertical:!0,styles:{}},l={show:!0,vertical:!1,entity:this._config.entity,allowTapping:!1,marginOfError:10},c={show:!1,entity:this._config.entity};if("none"!==i){const t="cover"===i,d="cover"===i,h=this.entity.state;o.text=this.entity.attributes.friendly_name,r.text=h.charAt(0).toUpperCase()+h.slice(1),l.entity=this.entity.entity_id,l.vertical=t,l.flipped=d,"light"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},this.entity.attributes.brightness&&(n.hold_action={action:"more-info"},r.text=Math.ceil($t(this.entity.attributes.brightness,256))+"%"),r.show=!0,l.allowSliding=!0,l.slideDistance=15):"cover"===i?(n.hold_action={action:"more-info"},s.icon=(null===(e=this.entity.attributes)||void 0===e?void 0:e.current_position)>=50?"mdi:blinds-open":"mdi:blinds"):"switch"===i||"input_boolean"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},r.show=!0,l.show=!1,s.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off"):"button"===i?(n.tap_action={action:"call-service",service:"button.press",service_data:{entity_id:this.entity.entity_id}},n.hold_action={action:"more-info"},l.show=!1):"lock"===i?(n.hold_action={action:"more-info"},l.show=!1,r.show=!0,this._config.camera&&"string"==typeof this._config.camera&&(this._config.camera=this.hass.states[this._config.camera],r.entity=this._config.camera.entity_id,r.tap_action={action:"more-info"}),"locked"===this.entity.state?(s.icon="mdi:lock-outline",n.tap_action={action:"call-service",service:"lock.unlock",service_data:{entity_id:this.entity.entity_id}}):"unlocked"===this.entity.state&&(s.icon="mdi:lock-open-variant-outline",n.tap_action={action:"call-service",service:"lock.lock",service_data:{entity_id:this.entity.entity_id}})):"media_player"===i&&(n.tap_action={action:"more-info"},"speaker"===this.entity.attributes.device_class?(s.icon=At(this.entity,this.entity.state)?"mdi:speaker":"mdi:speaker-off","playing"===this.entity.state?s.icon="mdi:speaker-play":"paused"===this.entity.state&&(s.icon="mdi:speaker-pause")):"tv"===this.entity.attributes.device_class&&(s.icon=At(this.entity,this.entity.state)?"mdi:television":"mdi:television-off","playing"===this.entity.state?s.icon="mdi:television-play":"paused"===this.entity.state&&(s.icon="mdi:television-pause")),l.show="paused"!==this.entity.state&&At(this.entity,this.entity.state),l.vertical=!0,l.sliderMin=5,l.min=1,l.allowTapping=!1,l.marginOfError=10,c.show=At(this.entity,this.entity.state),c.vertical=!1,c.allowTapping=!1,c.marginOfError=5,c.mode="seekbar",this.entity.attributes.media_title&&(o.extra=this.entity.attributes.media_title+" - "+this.entity.attributes.media_artist),a.vertical=!1,a.show=!0,a.button0={show:!0,icon:"playing"===this.entity.state?"mdi:pause":"mdi:play",styles:{container:{position:"absolute"}},tap_action:{action:"call-service",service:"playing"===this.entity.state?"media_player.media_pause":"media_player.media_play",service_data:{entity_id:this.entity.entity_id}}})}else l.show=!1;const d=Mt(n,this._config);return this._config=void 0!==d?d:this._config,this._config.icon="string"==typeof this._config.icon?Object.assign(Object.assign({},s),{icon:this._config.icon}):"object"==typeof this._config.icon?Mt(s,this._config.icon):s,this._config.label="string"==typeof this._config.label?Object.assign(Object.assign({},o),{text:this._config.label}):"object"==typeof this._config.label?Mt(o,this._config.label):o,this._config.stats="string"==typeof this._config.stats?Object.assign(Object.assign({},r),{text:this._config.stats}):"object"==typeof this._config.stats?Mt(r,this._config.stats):r,this._config.buttons="object"==typeof this._config.buttons?Mt(a,this._config.buttons):a,this._config.slider=this._config.slider?Mt(l,this._config.slider):l,this._config.seekbar=this._config.seekbar?Mt(c,this._config.seekbar):c,void 0!==this._config.styles&&null!==this._config.styles||(this._config.styles={}),this.initializeStyles(),null}initializeStyles(){var t,e,i,n,s,o,r,a,l,c,d,h,u,p,g,f,m,_,y,v,b,w,x,S,k,C,T,P,E,N,$,M,O,A,H,j,D,V,R,L,U,Y,z,I,F,q,B,W,J,Z,X,G,K,Q,tt,et;if(!this._config)return;const it=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",nt={background:"radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)"},st={filter:"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"},ot={card:Qt("sliderCard",ee(null===(e=this._config.styles)||void 0===e?void 0:e.sliderCard)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.sliderCard):{}),container:Qt("sliderContainer",ee(null===(n=this._config.styles)||void 0===n?void 0:n.sliderContainer)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.sliderContainer):{}),track:Qt("sliderTrack",ee(null===(o=this._config.styles)||void 0===o?void 0:o.sliderTrack)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.sliderTrack):{}),progress:this._config.slider.vertical?Qt("sliderProgressVer",ee(null===(a=this._config.styles)||void 0===a?void 0:a.sliderProgressVer)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.sliderProgressVer):{}):Qt("sliderProgressHor",ee(null===(c=this._config.styles)||void 0===c?void 0:c.sliderProgressHor)?ee(null===(d=this._config.styles)||void 0===d?void 0:d.sliderProgressHor):{}),thumb:this._config.slider.vertical?Qt("sliderThumbVer",ee(null===(h=this._config.styles)||void 0===h?void 0:h.sliderThumbVer)?ee(null===(u=this._config.styles)||void 0===u?void 0:u.sliderThumbVer):{}):Qt("sliderThumbHor",ee(null===(p=this._config.styles)||void 0===p?void 0:p.sliderThumbHor)?ee(null===(g=this._config.styles)||void 0===g?void 0:g.sliderThumbHor):{})},rt={container:Qt("stats",ee(null===(f=this._config.styles)||void 0===f?void 0:f.stats)?ee(null===(m=this._config.styles)||void 0===m?void 0:m.stats):{}),camera:Qt("camera",ee(null===(_=this._config.styles)||void 0===_?void 0:_.camera)?ee(null===(y=this._config.styles)||void 0===y?void 0:y.camera):{})},at={container:Qt("labelContainer",ee(null===(v=this._config.styles)||void 0===v?void 0:v.labelContainer)?ee(null===(b=this._config.styles)||void 0===b?void 0:b.labelContainer):{}),label:Qt("label",ee(null===(w=this._config.styles)||void 0===w?void 0:w.label)?ee(null===(x=this._config.styles)||void 0===x?void 0:x.label):{}),extraText:Qt("extraText",ee(null===(S=this._config.styles)||void 0===S?void 0:S.extraText)?ee(null===(k=this._config.styles)||void 0===k?void 0:k.extraText):{})},lt={container:Qt("buttonsContainer",ee(null===(C=this._config.styles)||void 0===C?void 0:C.buttonsContainer)?ee(null===(T=this._config.styles)||void 0===T?void 0:T.buttonsContainer):{}),button:Qt("button",ee(null===(P=this._config.styles)||void 0===P?void 0:P.button)?ee(null===(E=this._config.styles)||void 0===E?void 0:E.button):{}),text:Qt("buttonText",ee(null===(N=this._config.styles)||void 0===N?void 0:N.buttonText)?ee(null===($=this._config.styles)||void 0===$?void 0:$.buttonText):{}),icon:Qt("buttonIcon",ee(null===(M=this._config.styles)||void 0===M?void 0:M.buttonIcon)?ee(null===(O=this._config.styles)||void 0===O?void 0:O.buttonIcon):{})},ct={card:Qt("seekbarCard",ee(null===(A=this._config.styles)||void 0===A?void 0:A.seekbarCard)?ee(null===(H=this._config.styles)||void 0===H?void 0:H.seekbarCard):{}),container:Qt("seekbarContainer",ee(null===(j=this._config.styles)||void 0===j?void 0:j.seekbarContainer)?ee(null===(D=this._config.styles)||void 0===D?void 0:D.seekbarContainer):{}),track:Qt("seekbarTrack",ee(null===(V=this._config.styles)||void 0===V?void 0:V.seekbarTrack)?ee(null===(R=this._config.styles)||void 0===R?void 0:R.seekbarTrack):{}),progress:Qt("seekbarProgress",ee(null===(L=this._config.styles)||void 0===L?void 0:L.seekbarProgress)?ee(null===(U=this._config.styles)||void 0===U?void 0:U.seekbarProgress):{}),thumb:Qt("seekbarThumb",ee(null===(Y=this._config.styles)||void 0===Y?void 0:Y.seekbarThumb)?ee(null===(z=this._config.styles)||void 0===z?void 0:z.seekbarThumb):{})};if(this._config.slider.vertical&&this._config.slider.flipped&&(ot.thumb.top="initial",ot.thumb.bottom="2px"),this._config.buttons.vertical&&(lt.container["flex-direction"]="column"),"none"!==it)if(At(this.entity,this.entity.state)&&(st.color="var(--paper-item-icon-active-color)",st.filter="drop-shadow(2px 2px 2px rgba(0,0,0,0.75)",nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)"),"light"===it){if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;nt.background=`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil($t(this.entity.attributes.brightness,256))/t+"%"})`}}else"switch"===it||"input_boolean"===it||("lock"===it?"locked"===this.entity.state||"unlocked"===this.entity.state&&(st.color="var(--paper-item-icon-active-color)",nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)"):"media_player"===it||"cover"===it&&(this.entity.attributes.current_position<=50?nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)":st.color="var(--paper-item-icon-color)"));Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>(this._config.buttons[t].styles?(this._config.buttons[t].styles.container?this._config.buttons[t].styles.container=Mt(lt.button,this._config.buttons[t].styles.container?ee(this._config.buttons[t].styles.container):{}):this._config.buttons[t].styles.container=Mt(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),this._config.buttons[t].styles.text?this._config.buttons[t].styles.text=Mt(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.text=Mt(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),this._config.buttons[t].styles.icon?this._config.buttons[t].styles.icon=Mt(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.icon=Mt(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})):this._config.buttons[t].styles={container:Mt(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),text:Mt(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),icon:Mt(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})},null));const dt=(null===(I=this._config.styles)||void 0===I?void 0:I.card)?Object.assign(Object.assign({},nt),ee(this._config.styles.card)):nt,ht=(null===(F=this._config.styles)||void 0===F?void 0:F.icon)?Object.assign(Object.assign({},st),ee(this._config.styles.icon)):st;this._config.styles.card=Qt("card",ee(dt)),this._config.styles.icon=Qt("icon",ee(ht)),this._config.styles.row1=Qt("row1",ee(null===(q=this._config.styles)||void 0===q?void 0:q.row1)?ee(null===(B=this._config.styles)||void 0===B?void 0:B.row1):{}),this._config.styles.row2=Qt("row2",ee(null===(W=this._config.styles)||void 0===W?void 0:W.row2)?ee(null===(J=this._config.styles)||void 0===J?void 0:J.row2):{}),this._config.styles.button=Qt("button",ee(null===(Z=this._config.styles)||void 0===Z?void 0:Z.button)?ee(null===(X=this._config.styles)||void 0===X?void 0:X.button):{}),this._config.slider.styles=(null===(G=this._config.slider)||void 0===G?void 0:G.styles)?Mt(ot,this._config.slider.styles):ot,this._config.stats.styles=(null===(K=this._config.stats)||void 0===K?void 0:K.styles)?Mt(rt,this._config.stats.styles):rt,this._config.label.styles=(null===(Q=this._config.label)||void 0===Q?void 0:Q.styles)?Mt(at,this._config.label.styles):at,this._config.buttons.styles=(null===(tt=this._config.buttons)||void 0===tt?void 0:tt.styles)?Mt(lt,this._config.buttons.styles):lt,this._config.seekbar.styles=(null===(et=this._config.seekbar)||void 0===et?void 0:et.styles)?Mt(ct,this._config.seekbar.styles):ct}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<25)&&(this.lastAction=(new Date).getTime(),e.entity||(e.entity=this._config.entity),null===(i=t.detail)||void 0===i?void 0:i.action))switch(t.detail.action){case"tap":case"hold":case"double_tap":if(!e)return;const i=t.detail.action,n=((t,e,i)=>{const n=JSON.parse(JSON.stringify(e)),s=e=>e?(Object.keys(e).forEach(i=>{"object"==typeof e[i]?e[i]=s(e[i]):e[i]=ie(t,t.entity,e[i])}),e):e;return n[i]=s(n[i]),!n[i].confirmation&&n.confirmation&&(n[i].confirmation=s(n.confirmation)),n})(this,e,i+"_action");(async(t,e,i,n)=>{Nt(t,"hass-action",{config:i,action:n})})(this,this.hass,n,i)}}static get styles(){return tt` + @keyframes marquee { + 0% { text-indent: 100% } + 100% { text-indent: -100% } + } + `}};var oe,re;t([X()],se.prototype,"_hass",void 0),t([X()],se.prototype,"_config",void 0),t([X({attribute:!1})],se.prototype,"hass",void 0),t([function(t){return X({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(oe)],se.prototype,"config",void 0),se=t([(re="my-button",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(re,t):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(re,t))],se);export{se as MyButton}; diff --git a/dist/my-cards.js b/dist/my-cards.js index f06e3dd..14a2a12 100644 --- a/dist/my-cards.js +++ b/dist/my-cards.js @@ -1,4 +1,4 @@ -var t={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},e={common:t},i={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},s={common:i};const o={en:Object.freeze({__proto__:null,common:t,default:e}),nb:Object.freeze({__proto__:null,common:i,default:s})};function n(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let n;try{n=t.split(".").reduce((t,e)=>t[e],o[s])}catch(e){n=t.split(".").reduce((t,e)=>t[e],o.en)}return void 0===n&&(n=t.split(".").reduce((t,e)=>t[e],o.en)),""!==e&&""!==i&&(n=n.replace(e,i)),n} +const t=(e=["unavailable","unknown"],(t,i)=>e.includes(t,i));var e,i={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},n={common:i},s={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},o={common:s};const r={en:Object.freeze({__proto__:null,common:i,default:n}),nb:Object.freeze({__proto__:null,common:s,default:o})};function a(t,e="",i=""){const n=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let s;try{s=t.split(".").reduce((t,e)=>t[e],r[n])}catch(e){s=t.split(".").reduce((t,e)=>t[e],r.en)}return void 0===s&&(s=t.split(".").reduce((t,e)=>t[e],r.en)),""!==e&&""!==i&&(s=s.replace(e,i)),s} /*! ***************************************************************************** Copyright (c) Microsoft Corporation. @@ -12,7 +12,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */function r(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r +***************************************************************************** */function l(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -25,7 +25,7 @@ PERFORMANCE OF THIS SOFTWARE. * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */}const a="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,l=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},c=`{{lit-${String(Math.random()).slice(2)}}}`,h=`\x3c!--${c}--\x3e`,d=new RegExp(`${c}|${h}`);class u{constructor(t,e){this.parts=[],this.element=e;const i=[],s=[],o=document.createTreeWalker(e.content,133,null,!1);let n=0,r=-1,a=0;const{strings:l,values:{length:h}}=t;for(;a0;){const e=l[a],i=f.exec(e)[2],s=i.toLowerCase()+"$lit$",o=t.getAttribute(s);t.removeAttribute(s);const n=o.split(d);this.parts.push({type:"attribute",index:r,name:i,strings:n}),a+=n.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),o.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const s=t.parentNode,o=e.split(d),n=o.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},m=t=>-1!==t.index,g=()=>document.createComment(""),f=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function v(t,e){const{element:{content:i},parts:s}=t,o=document.createTreeWalker(i,133,null,!1);let n=_(s),r=s[n],a=-1,l=0;const c=[];let h=null;for(;o.nextNode();){a++;const t=o.currentNode;for(t.previousSibling===h&&(h=null),e.has(t)&&(c.push(t),null===h&&(h=t)),null!==h&&l++;void 0!==r&&r.index===a;)r.index=null!==h?-1:r.index-l,n=_(s,n),r=s[n]}c.forEach(t=>t.parentNode.removeChild(t))}const y=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},_=(t,e=-1)=>{for(let i=e+1;i{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},h=`{{lit-${String(Math.random()).slice(2)}}}`,u=`\x3c!--${h}--\x3e`,g=new RegExp(`${h}|${u}`);class p{constructor(t,e){this.parts=[],this.element=e;const i=[],n=[],s=document.createTreeWalker(e.content,133,null,!1);let o=0,r=-1,a=0;const{strings:l,values:{length:c}}=t;for(;a0;){const e=l[a],i=v.exec(e)[2],n=i.toLowerCase()+"$lit$",s=t.getAttribute(n);t.removeAttribute(n);const o=s.split(g);this.parts.push({type:"attribute",index:r,name:i,strings:o}),a+=o.length-1}}"TEMPLATE"===t.tagName&&(n.push(t),s.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(h)>=0){const n=t.parentNode,s=e.split(g),o=s.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},f=t=>-1!==t.index,_=()=>document.createComment(""),v=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function y(t,e){const{element:{content:i},parts:n}=t,s=document.createTreeWalker(i,133,null,!1);let o=w(n),r=n[o],a=-1,l=0;const c=[];let d=null;for(;s.nextNode();){a++;const t=s.currentNode;for(t.previousSibling===d&&(d=null),e.has(t)&&(c.push(t),null===d&&(d=t)),null!==d&&l++;void 0!==r&&r.index===a;)r.index=null!==d?-1:r.index-l,o=w(n,o),r=n[o]}c.forEach(t=>t.parentNode.removeChild(t))}const b=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},w=(t,e=-1)=>{for(let i=e+1;i(...e)=>{const i=t(...e);return b.set(i,!0),i},S=t=>"function"==typeof t&&b.has(t),x={},C={}; +const x=new WeakMap,S=t=>(...e)=>{const i=t(...e);return x.set(i,!0),i},k=t=>"function"==typeof t&&x.has(t),$={},T={}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -53,7 +53,7 @@ const b=new WeakMap,w=t=>(...e)=>{const i=t(...e);return b.set(i,!0),i},S=t=>"fu * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=a?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),e=[],i=this.template.parts,s=document.createTreeWalker(t,133,null,!1);let o,n=0,r=0,l=s.nextNode();for(;nt}),k=` ${c} `;class M{constructor(t,e,i,s){this.strings=t,this.values=e,this.type=i,this.processor=s}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let s=0;s-1||i)&&-1===t.indexOf("--\x3e",o+1);const n=f.exec(t);e+=null===n?t+(i?k:h):t.substr(0,n.index)+n[1]+n[2]+"$lit$"+n[3]+c}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==T&&(e=T.createHTML(e)),t.innerHTML=e,t}} + */const C=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),E=` ${h} `;class P{constructor(t,e,i,n){this.strings=t,this.values=e,this.type=i,this.processor=n}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let n=0;n-1||i)&&-1===t.indexOf("--\x3e",s+1);const o=v.exec(t);e+=null===o?t+(i?E:u):t.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[3]+h}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==C&&(e=C.createHTML(e)),t.innerHTML=e,t}} /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -79,7 +79,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */const E=t=>null===t||!("object"==typeof t||"function"==typeof t),P=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class O{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return D=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class H{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;S(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=x,t(this)}if(this.__pendingValue===x)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),s=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=Y(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=x}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const Y=t=>t&&(D?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */const N=t=>null===t||!("object"==typeof t||"function"==typeof t),O=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class V{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return R=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class Y{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;k(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=$,t(this)}if(this.__pendingValue===$)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),n=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),n&&(this.__options=I(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=$}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const I=t=>t&&(R?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -92,7 +92,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */;function R(t){let e=z.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},z.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const s=t.strings.join(c);return i=e.keyString.get(s),void 0===i&&(i=new u(t,t.getTemplateElement()),e.keyString.set(s,i)),e.stringsArray.set(t.strings,i),i}const z=new Map,F=new WeakMap; + */;function z(t){let e=F.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},F.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(h);return i=e.keyString.get(n),void 0===i&&(i=new p(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const F=new Map,U=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -105,7 +105,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */const I=new + */const B=new /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -119,7 +119,7 @@ class ${constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j(t,e.slice(1),i).parts}if("@"===o)return[new H(t,e.slice(1),s.eventContext)];if("?"===o)return[new A(t,e.slice(1),i)];return new O(t,e,i).parts}handleTextExpression(t){return new V(t)}}; +class{handleAttributeExpressions(t,e,i,n){const s=e[0];if("."===s){return new D(t,e.slice(1),i).parts}if("@"===s)return[new Y(t,e.slice(1),n.eventContext)];if("?"===s)return[new L(t,e.slice(1),i)];return new V(t,e,i).parts}handleTextExpression(t){return new H(t)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -132,7 +132,7 @@ class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new M(t,e,"html",I) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const q=(t,...e)=>new P(t,e,"html",B) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -145,7 +145,7 @@ class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */,B=(t,e)=>`${t}--${e}`;let W=!0;void 0===window.ShadyCSS?W=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),W=!1);const q=t=>e=>{const i=B(e.type,t);let s=z.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},z.set(i,s));let o=s.stringsArray.get(e.strings);if(void 0!==o)return o;const n=e.strings.join(c);if(o=s.keyString.get(n),void 0===o){const i=e.getTemplateElement();W&&window.ShadyCSS.prepareTemplateDom(i,t),o=new u(e,i),s.keyString.set(n,o)}return s.stringsArray.set(e.strings,o),o},J=["html","svg"],X=new Set,Z=(t,e,i)=>{X.add(t);const s=i?i.element:document.createElement("template"),o=e.querySelectorAll("style"),{length:n}=o;if(0===n)return void window.ShadyCSS.prepareTemplateStyles(s,t);const r=document.createElement("style");for(let t=0;t{J.forEach(e=>{const i=z.get(B(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),v(t,i)})})})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:o}=t;if(null==i)return void s.appendChild(e);const n=document.createTreeWalker(s,133,null,!1);let r=_(o),a=0,l=-1;for(;n.nextNode();){l++;for(n.currentNode===i&&(a=y(e),i.parentNode.insertBefore(e,i));-1!==r&&o[r].index===l;){if(a>0){for(;-1!==r;)o[r].index+=a,r=_(o,r);return}r=_(o,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(s,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),v(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const G={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},K=(t,e)=>e!==t&&(e==e||t==t),Q={attribute:!0,type:String,converter:G,reflect:!1,hasChanged:K};class tt extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const s=this._attributeNameForProperty(i,e);void 0!==s&&(this._attributeToPropertyMap.set(s,i),t.push(s))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=Q){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const o=this[t];this[e]=s,this.requestUpdateInternal(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||Q}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=K){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||G,o="function"==typeof s?s:s.fromAttribute;return o?o(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||G.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=Q){const s=this.constructor,o=s._attributeNameForProperty(t,i);if(void 0!==o){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(o):this.setAttribute(o,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(t);if(void 0!==s){const t=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let s=!0;if(void 0!==t){const o=this.constructor;i=i||o.getPropertyOptions(t),o._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):s=!1}!this._hasRequestedUpdate&&s&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}tt.finalized=!0; + */,W=(t,e)=>`${t}--${e}`;let X=!0;void 0===window.ShadyCSS?X=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),X=!1);const J=t=>e=>{const i=W(e.type,t);let n=F.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},F.set(i,n));let s=n.stringsArray.get(e.strings);if(void 0!==s)return s;const o=e.strings.join(h);if(s=n.keyString.get(o),void 0===s){const i=e.getTemplateElement();X&&window.ShadyCSS.prepareTemplateDom(i,t),s=new p(e,i),n.keyString.set(o,s)}return n.stringsArray.set(e.strings,s),s},Z=["html","svg"],G=new Set,K=(t,e,i)=>{G.add(t);const n=i?i.element:document.createElement("template"),s=e.querySelectorAll("style"),{length:o}=s;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(n,t);const r=document.createElement("style");for(let t=0;t{Z.forEach(e=>{const i=F.get(W(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),y(t,i)})})})(t);const a=n.content;i?function(t,e,i=null){const{element:{content:n},parts:s}=t;if(null==i)return void n.appendChild(e);const o=document.createTreeWalker(n,133,null,!1);let r=w(s),a=0,l=-1;for(;o.nextNode();){l++;for(o.currentNode===i&&(a=b(e),i.parentNode.insertBefore(e,i));-1!==r&&s[r].index===l;){if(a>0){for(;-1!==r;)s[r].index+=a,r=w(s,r);return}r=w(s,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(n,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),y(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const Q={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},tt=(t,e)=>e!==t&&(e==e||t==t),et={attribute:!0,type:String,converter:Q,reflect:!1,hasChanged:tt};class it extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const n=this._attributeNameForProperty(i,e);void 0!==n&&(this._attributeToPropertyMap.set(n,i),t.push(n))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=et){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,n=this.getPropertyDescriptor(t,i,e);void 0!==n&&Object.defineProperty(this.prototype,t,n)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(n){const s=this[t];this[e]=n,this.requestUpdateInternal(t,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||et}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=tt){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,n=e.converter||Q,s="function"==typeof n?n:n.fromAttribute;return s?s(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,n=e.converter;return(n&&n.toAttribute||Q.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=et){const n=this.constructor,s=n._attributeNameForProperty(t,i);if(void 0!==s){const t=n._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(s):this.setAttribute(s,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,n=i._attributeToPropertyMap.get(t);if(void 0!==n){const t=i.getPropertyOptions(n);this._updateState=16|this._updateState,this[n]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let n=!0;if(void 0!==t){const s=this.constructor;i=i||s.getPropertyOptions(t),s._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):n=!1}!this._hasRequestedUpdate&&n&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}it.finalized=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -159,7 +159,7 @@ class{handleAttributeExpressions(t,e,i,s){const o=e[0];if("."===o){return new j( * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const et=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})(t,e),it=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function st(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):it(t,e)}function ot(t){return st({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}const nt=t=>ot(t) +const nt=t=>e=>"function"==typeof e?((t,e)=>(window.customElements.define(t,e),e))(t,e):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(t,e),st=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?Object.assign(Object.assign({},e),{finisher(i){i.createProperty(e.key,t)}}):{kind:"field",key:Symbol(),placement:"own",descriptor:{},initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}};function ot(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):st(t,e)}function rt(t){return ot({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}const at=t=>rt(t) /** @license Copyright (c) 2019 The Polymer Project Authors. All rights reserved. @@ -169,7 +169,7 @@ http://polymer.github.io/AUTHORS.txt The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as part of the polymer project is also subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt -*/,rt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,at=Symbol();class lt{constructor(t,e){if(e!==at)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(rt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const ct=(t,...e)=>{const i=e.reduce((e,i,s)=>e+(t=>{if(t instanceof lt)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[s+1],t[0]);return new lt(i,at)}; +*/,lt=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ct=Symbol();class dt{constructor(t,e){if(e!==ct)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(lt?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const ht=(t,...e)=>{const i=e.reduce((e,i,n)=>e+(t=>{if(t instanceof dt)return t.cssText;if("number"==typeof t)return t;throw new Error(`Value passed to 'css' function must be a 'css' function result: ${t}. Use 'unsafeCSS' to pass non-literal values, but\n take care to ensure page security.`)})(i)+t[n+1],t[0]);return new dt(i,ct)}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -183,81 +183,81 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ht={};class dt extends tt{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),s=[];i.forEach(t=>s.unshift(t)),this._styles=s}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!rt){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new lt(String(e),at)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?rt?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ht&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return ht}}dt.finalized=!0,dt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const s=i.scopeName,o=F.has(e),n=W&&11===e.nodeType&&!!e.host,r=n&&!X.has(s),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let s=F.get(e);void 0===s&&(l(e,e.firstChild),F.set(e,s=new V(Object.assign({templateFactory:R},i))),s.appendInto(e)),s.setValue(t),s.commit()})(t,a,Object.assign({templateFactory:q(s)},i)),r){const t=F.get(a);F.delete(a);const i=t.value instanceof $?t.value.template:void 0;Z(s,a,i),l(e,e.firstChild),e.appendChild(a),F.set(e,t)}!o&&n&&window.ShadyCSS.styleElement(e.host)},dt.shadowRootOptions={mode:"open"};var ut=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,pt="[^\\s]+",mt=/\[([^]*?)\]/gm;function gt(t,e){for(var i=[],s=0,o=t.length;s-1?s:null}};function vt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},St=vt({},wt),xt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+xt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+xt(Math.floor(Math.abs(e)/60),2)+":"+xt(Math.abs(e)%60,2)}},$t=function(t){return+t-1},Tt=[null,"[1-9]\\d?"],kt=[null,pt],Mt=["isPm",pt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],Et=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Pt=(ft("monthNamesShort"),ft("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Ot,Nt,Vt=function(t,e,i){if(void 0===e&&(e=Pt.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];e=(e=Pt[e]||e).replace(mt,(function(t,e){return s.push(e),"@@@"}));var o=vt(vt({},St),i);return(e=e.replace(ut,(function(e){return Ct[e](t,o)}))).replace(/@@@/g,(function(){return s.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function At(){return(At=Object.assign||function(t){for(var e=1;e1),It=[],Ut=!1,Bt=-1,Wt=void 0,qt=void 0,Jt=void 0,Xt=function(t){return It.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Zt=function(t){var e=t||window.event;return!!Xt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Gt=function(t,e){if(t){if(!It.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};It=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e=s&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Jt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var s=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Jt=document.body.style.paddingRight,document.body.style.paddingRight=s+i+"px"}}void 0===Wt&&(Wt=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Ft&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(Bt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-Bt;!Xt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Zt(t):t.stopPropagation())}(e,t)},Ut||(document.addEventListener("touchmove",Zt,Rt?{passive:!1}:void 0),Ut=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Kt=function(t){t?(It=It.filter((function(e){return e.targetElement!==t})),Ft&&(t.ontouchstart=null,t.ontouchmove=null,Ut&&0===It.length&&(document.removeEventListener("touchmove",Zt,Rt?{passive:!1}:void 0),Ut=!1)),Ft?function(){if(void 0!==qt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=qt.position,document.body.style.top=qt.top,document.body.style.left=qt.left,window.scrollTo(e,t),qt=void 0}}():(void 0!==Jt&&(document.body.style.paddingRight=Jt,Jt=void 0),void 0!==Wt&&(document.body.style.overflow=Wt,Wt=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};console.info(`%c ---- MY-SLIDER ---- \n%c ${n("common.version")} 3.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Qt=class extends dt{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&Yt(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const i=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",s=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+i]);var o=e.step?e.step:"1",n=e.minBar?e.minBar:0,r=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(i.includes("input_number.")||i.includes("number."))&&(o=e.step?e.step:s.attributes.step,a=e.minSet?e.minSet:s.attributes.min,l=e.maxSet?e.maxSet:s.attributes.max);var c=e.width?e.width:"100%",h=e.height?e.height:"50px",d=e.radius?e.radius:"4px",u=e.top?e.top:"0px",p=e.bottom?e.bottom:"0px",m=e.right?e.right:"0px",g=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",v=e.containerHeight?e.containerHeight:h;"0"!=f&&(f+="deg");var y=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",_=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",w=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",S=e.border?e.border:"0",x=e.thumbWidth?e.thumbWidth:"25px",C=e.thumbHeight?e.thumbHeight:"80px",$=e.thumbColor?e.thumbColor:"#FFFFFF",T=e.thumbColorOff?e.thumbColorOff:"#969696",k=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",M=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",E=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",P=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",O=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",N=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",A=!!e.lockTrack&&e.lockTrack,j=`\n\t\t\t--slider-width: ${c};\n\t\t\t--slider-width-inverse: -${c};\n\t\t\t--slider-height: ${h};\n\t\t\t--slider-main-color: ${"off"===s.state||"locked"===s.state||null==s.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${y};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===s.state||"locked"===s.state||null==s.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${_};\n\t\t\t--slider-secondary-color-off: ${w};\n\t\t\t--slider-radius: ${d};\n\t\t\t--border: ${S};\n\n\t\t\t--thumb-width: ${x};\n\t\t\t--thumb-height: ${C};\n\t\t\t--thumb-color: ${"off"===s.state||null==s.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${$};\n\t\t\t--thumb-color-off: ${T};\n\t\t\t--thumb-horizontal-padding: ${k};\n\t\t\t--thumb-vertical-padding: ${M};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${u};\n\t\t\t--bottom: ${p};\n\t\t\t--right: ${m};\n\t\t\t--left: ${g};\n\t\t\t--container-height: ${v};\n\t\t\t--thumb-top: ${E};\n\t\t\t--thumb-border-right: ${P};\n\t\t\t--thumb-border-left: ${O};\n\t\t\t--thumb-border-top: ${N};\n\t\t\t--thumb-border-bottom: ${V};\n\t\t\t\n\t\t\t--lock-track-container: ${A?"none":"auto"};\n\t\t`;const L=t=>{i.includes("light.")?"Warmth"==e.function?this._setWarmth(s,t.target,a,l):this._setBrightness(s,t.target,a,l):i.includes("input_number.")||i.includes("number.")?this._setInputNumber(s,t.target,a,l):i.includes("media_player.")?this._setMediaVolume(s,t.target,a,l):i.includes("cover.")?this._setCover(s,t.target,a,l):i.includes("fan.")?this._setFan(s,t.target,a,l):i.includes("switch.")?this._setSwitch(s,t.target,a,l,n,r):i.includes("lock.")&&this._setLock(s,t.target,a,l,n,r)},D=t=>{e.intermediate&&L(t)},H=t=>{e.intermediate||L(t)},Y=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Gt(window):Kt(window)};if(i.includes("light."))return"Warmth"==e.function?U` +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const ut={};class gt extends it{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),n=[];i.forEach(t=>n.unshift(t)),this._styles=n}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!lt){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new dt(String(e),ct)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?lt?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==ut&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return ut}}gt.finalized=!0,gt.render=(t,e,i)=>{if(!i||"object"!=typeof i||!i.scopeName)throw new Error("The `scopeName` option is required.");const n=i.scopeName,s=U.has(e),o=X&&11===e.nodeType&&!!e.host,r=o&&!G.has(n),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let n=U.get(e);void 0===n&&(d(e,e.firstChild),U.set(e,n=new H(Object.assign({templateFactory:z},i))),n.appendInto(e)),n.setValue(t),n.commit()})(t,a,Object.assign({templateFactory:J(n)},i)),r){const t=U.get(a);U.delete(a);const i=t.value instanceof M?t.value.template:void 0;K(n,a,i),d(e,e.firstChild),e.appendChild(a),U.set(e,t)}!s&&o&&window.ShadyCSS.styleElement(e.host)},gt.shadowRootOptions={mode:"open"};var pt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,mt="[^\\s]+",ft=/\[([^]*?)\]/gm;function _t(t,e){for(var i=[],n=0,s=t.length;n-1?n:null}};function yt(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},kt=yt({},St),$t=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+$t(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+$t(Math.floor(Math.abs(e)/60),2)+":"+$t(Math.abs(e)%60,2)}},Mt=function(t){return+t-1},Ct=[null,"[1-9]\\d?"],Et=[null,mt],Pt=["isPm",mt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],Nt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],Ot=(vt("monthNamesShort"),vt("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Vt,At,Ht=function(t,e,i){if(void 0===e&&(e=Ot.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var n=[];e=(e=Ot[e]||e).replace(ft,(function(t,e){return n.push(e),"@@@"}));var s=yt(yt({},kt),i);return(e=e.replace(pt,(function(e){return Tt[e](t,s)}))).replace(/@@@/g,(function(){return n.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();function Lt(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var n=e.get("hass");return!n||n.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(At=Vt||(Vt={})).language="language",At.system="system",At.comma_decimal="comma_decimal",At.decimal_comma="decimal_comma",At.space_comma="space_comma",At.none="none";var Dt=!1;if("undefined"!=typeof window){var jt={get passive(){Dt=!0}};window.addEventListener("testPassive",null,jt),window.removeEventListener("testPassive",null,jt)}var Rt="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Yt=[],It=!1,zt=-1,Ft=void 0,Ut=void 0,Bt=void 0,qt=function(t){return Yt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Wt=function(t){var e=t||window.event;return!!qt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Xt=function(t,e){if(t){if(!Yt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};Yt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,i=Array(t.length);e=n&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===Bt){var e=!!t&&!0===t.reserveScrollBarGap,i=window.innerWidth-document.documentElement.clientWidth;if(e&&i>0){var n=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);Bt=document.body.style.paddingRight,document.body.style.paddingRight=n+i+"px"}}void 0===Ft&&(Ft=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Rt&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(zt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var i=t.targetTouches[0].clientY-zt;!qt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Wt(t):t.stopPropagation())}(e,t)},It||(document.addEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Jt=function(t){t?(Yt=Yt.filter((function(e){return e.targetElement!==t})),Rt&&(t.ontouchstart=null,t.ontouchmove=null,It&&0===Yt.length&&(document.removeEventListener("touchmove",Wt,Dt?{passive:!1}:void 0),It=!1)),Rt?function(){if(void 0!==Ut){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=Ut.position,document.body.style.top=Ut.top,document.body.style.left=Ut.left,window.scrollTo(e,t),Ut=void 0}}():(void 0!==Bt&&(document.body.style.paddingRight=Bt,Bt=void 0),void 0!==Ft&&(document.body.style.overflow=Ft,Ft=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};console.info(`%c ---- MY-SLIDER ---- \n%c ${a("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Zt=class extends gt{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const i=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",n=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+i]);var s=e.step?e.step:"1",o=e.minBar?e.minBar:0,r=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(i.includes("input_number.")||i.includes("number."))&&(s=e.step?e.step:n.attributes.step,a=e.minSet?e.minSet:n.attributes.min,l=e.maxSet?e.maxSet:n.attributes.max);var c=e.width?e.width:"100%",d=e.height?e.height:"50px",h=e.radius?e.radius:"4px",u=e.top?e.top:"0px",g=e.bottom?e.bottom:"0px",p=e.right?e.right:"0px",m=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",_=e.containerHeight?e.containerHeight:d;"0"!=f&&(f+="deg");var v=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",y=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",w=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",x=e.border?e.border:"0",S=e.thumbWidth?e.thumbWidth:"25px",k=e.thumbHeight?e.thumbHeight:"80px",$=e.thumbColor?e.thumbColor:"#FFFFFF",T=e.thumbColorOff?e.thumbColorOff:"#969696",M=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",C=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",E=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",P=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",N=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",O=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",A=!!e.lockTrack&&e.lockTrack,H=`\n\t\t\t--slider-width: ${c};\n\t\t\t--slider-width-inverse: -${c};\n\t\t\t--slider-height: ${d};\n\t\t\t--slider-main-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${v};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===n.state||"locked"===n.state||null==n.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${y};\n\t\t\t--slider-secondary-color-off: ${w};\n\t\t\t--slider-radius: ${h};\n\t\t\t--border: ${x};\n\n\t\t\t--thumb-width: ${S};\n\t\t\t--thumb-height: ${k};\n\t\t\t--thumb-color: ${"off"===n.state||null==n.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${$};\n\t\t\t--thumb-color-off: ${T};\n\t\t\t--thumb-horizontal-padding: ${M};\n\t\t\t--thumb-vertical-padding: ${C};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${u};\n\t\t\t--bottom: ${g};\n\t\t\t--right: ${p};\n\t\t\t--left: ${m};\n\t\t\t--container-height: ${_};\n\t\t\t--thumb-top: ${E};\n\t\t\t--thumb-border-right: ${P};\n\t\t\t--thumb-border-left: ${N};\n\t\t\t--thumb-border-top: ${O};\n\t\t\t--thumb-border-bottom: ${V};\n\t\t\t\n\t\t\t--lock-track-container: ${A?"none":"auto"};\n\t\t`;const L=t=>{i.includes("light.")?"Warmth"==e.function?this._setWarmth(n,t.target,a,l):this._setBrightness(n,t.target,a,l):i.includes("input_number.")||i.includes("number.")?this._setInputNumber(n,t.target,a,l):i.includes("media_player.")?this._setMediaVolume(n,t.target,a,l):i.includes("cover.")?this._setCover(n,t.target,a,l):i.includes("fan.")?this._setFan(n,t.target,a,l):i.includes("switch.")?this._setSwitch(n,t.target,a,l,o,r):i.includes("lock.")&&this._setLock(n,t.target,a,l,o,r)},D=t=>{e.intermediate&&L(t)},j=t=>{e.intermediate||L(t)},R=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Xt(window):Jt(window)};if(i.includes("light."))return"Warmth"==e.function?q` -
- +
+
- `:U` + `:q` -
- +
+
- `;if(i.includes("input_number.")||i.includes("number."))return U` + `;if(i.includes("input_number.")||i.includes("number."))return q` -
- + + step="${s}" .value="${n.state}" + @input=${D} @change=${j} + @touchstart=${e.toggle_scroll?R:null} + @touchend=${e.toggle_scroll?R:null} >
- `;if(i.includes("media_player.")){var R=0;if(null!=s.attributes.volume_level)R=Number(100*s.attributes.volume_level);return U` + `;if(i.includes("media_player.")){var Y=0;if(null!=n.attributes.volume_level)Y=Number(100*n.attributes.volume_level);return q` -
- +
+
- `}return i.includes("cover.")?U` + `}return i.includes("cover.")?q` -
- +
+
- `:i.includes("fan.")?U` + `:i.includes("fan.")?q` -
- +
+
- `:i.includes("switch.")||i.includes("lock.")?U` + `:i.includes("switch.")||i.includes("lock.")?q` -
- +
+
- `:void 0}_setBrightness(t,e,i,s){var o=e.value;o>s?o=s:os?o=s:os?o=s:os?o=s:os?o=s:os?o=s:on?s=n:sn?s=n:sn?s=n:sn?s=n:sn?s=n:sn?s=n:se=>{if(!(e instanceof N)||e instanceof L||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:s}=i.element;let o=te.get(e);void 0===o&&(s.cssText=i.strings.join(" "),te.set(e,o=new Set)),o.forEach(e=>{e in t||(o.delete(e),-1===e.indexOf("-")?s[e]=null:s.removeProperty(e))});for(const e in t)o.add(e),-1===e.indexOf("-")?s[e]=t[e]:s.setProperty(e,t[e])}),ie=(t,e={})=>{const i=se[t];return i?i(e):void console.log(t+": Not found in styles")},se={card:t=>Object.assign({height:"30px"},t),container:t=>Object.assign({width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},t),track:t=>Object.assign({width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},t),progress:t=>Object.assign({height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},t),thumb:t=>Object.assign({height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"},t)},oe=function(t,e,i){var s,o;for(var n in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(n)&&(s=n,o=t[n],e.push(s),"object"==typeof o&&null!==o?i=oe(o,e,i):i[e[e.length-1]]=o,e.pop());return i},ne=(t,e=100,i=0)=>t/(e-i)*100,re=t=>Math.round(100*(t+Number.EPSILON))/100;function ae(t,e){const i=Object.assign({},t);return le(t)&&le(e)&&Object.keys(e).forEach(s=>{Array.isArray(e[s])?i[s]=e[s].map((e,i)=>t[s]&&le(t[s][i])&&le(e)?ae(t[s][i],e):e):le(e[s])?s in t?i[s]=ae(t[s],e[s]):Object.assign(i,{[s]:e[s]}):Object.assign(i,{[s]:e[s]})}),i}function le(t){return t&&"object"==typeof t&&!Array.isArray(t)}console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${n("common.version")} 3.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let ce=class extends dt{constructor(){super(...arguments),this.colorMode="brightness",this.coverMode="position",this.sliderId="",this.touchInput=!1,this.disableScroll=!0,this.allowTapping=!0,this.allowSliding=!1,this.slideDistance=10,this.marginOfError=10,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.vertical=!1,this.flipped=!1,this.inverse=!1,this.showMin=!1,this.zero=0,this.savedMin=1,this.min=0,this.max=100,this.minThreshold=0,this.maxThreshold=100,this.step=1,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0}setSliderValues(t,e){this.inverse?(this.sliderVal=this.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&Yt(this,t,!1)}render(){var t,e,i,s,o,n,r,a,l,c;const h=this.initializeConfig();if(null!==h)return h;const d=oe(null===(t=this._config.styles)||void 0===t?void 0:t.card)?oe(null===(e=this._config.styles)||void 0===e?void 0:e.card):{},u=oe(null===(i=this._config.styles)||void 0===i?void 0:i.container)?oe(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=oe(null===(o=this._config.styles)||void 0===o?void 0:o.track)?oe(null===(n=this._config.styles)||void 0===n?void 0:n.track):{},m=oe(null===(r=this._config.styles)||void 0===r?void 0:r.progress)?oe(null===(a=this._config.styles)||void 0===a?void 0:a.progress):{},g=oe(null===(l=this._config.styles)||void 0===l?void 0:l.thumb)?oe(null===(c=this._config.styles)||void 0===c?void 0:c.thumb):{},f=ie("card",d),v=ie("container",u),y=ie("track",p),_=ie("progress",m),b=ie("thumb",g);this.vertical?(_.height=this.sliderValPercent.toString()+"%",f.height=d.height?d.height:"100%",f.width=d.width?d.width:"30px",_.width=m.width?m.width:"100%",_.right=m.right?m.right:"auto",b.right=g.right?g:"auto",b.width=g.width?g.width:"100%",b.height=g.height?g.height:"10px",this.flipped?(_.top=m.top?m.top:"0",b.bottom=g.bottom?g.bottom:"-5px"):(_.bottom=m.bottom?m.bottom:"0",b.top=g.top?g.top:"-5px")):(_.width=this.sliderValPercent.toString()+"%",this.flipped&&(_.right=m.right?m.right:"0",b.right=g.right?g.right:"auto",b.left=g.left?g.left:"-5px"));const w=t=>{const e=t.composedPath().find(t=>t.classList.contains("my-slider-custom-container"));this.sliderEl=e||t.target},S=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;x(t);break;case"touchstart":this.touchInput=!0,x(t);break;case"mousemove":if(this.touchInput)return;$(t);break;case"touchmove":this.disableScroll&&t.preventDefault(),$(t);break;case"mouseup":case"touchend":case"touchcancel":C(t)}},x=t=>{var e;if(this.actionTaken)return;w(t);const i=t.clientX||t.touches[0].clientX,s=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=s),this.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const o=t.composedPath()[0],n=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(o.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(n){const e=n.getBoundingClientRect();if(i>=e.left-this.marginOfError&&i<=e.right+this.marginOfError&&s>=e.top-this.marginOfError&&s<=e.bottom+this.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this.allowSliding&&(this.actionTaken=!0),this.clientYLast=s,this.clientXLast=i},C=t=>{this.actionTaken&&((this.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.actionTaken=!1,this.touchInput=!1,this.isSliding=!1)},$=t=>{if(this.actionTaken){const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this.allowTapping||this.isSliding||!this.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this.allowSliding&&(this.vertical?Math.abs(i-this.clientYLast)>=this.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(S),U` - -
e=>{if(!(e instanceof A)||e instanceof j||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:n}=i.element;let s=Gt.get(e);void 0===s&&(n.cssText=i.strings.join(" "),Gt.set(e,s=new Set)),s.forEach(e=>{e in t||(s.delete(e),-1===e.indexOf("-")?n[e]=null:n.removeProperty(e))});for(const e in t)s.add(e),-1===e.indexOf("-")?n[e]=t[e]:n.setProperty(e,t[e])}),Qt=(t,e={})=>{const i=te[t];return i?Object.assign(Object.assign({},i),e):void console.log(t+": Not found in styles")},te={card:{height:"30px"},container:{width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},track:{width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},progress:{height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},thumb:{height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"}},ee=function(t,e,i){var n,s;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(n=o,s=t[o],e.push(n),"object"==typeof s&&null!==s?i=ee(s,e,i):i[e[e.length-1]]=s,e.pop());return i},ie=(t,e=100,i=0)=>t/(e-i)*100,ne=t=>Math.round(100*(t+Number.EPSILON))/100;function se(t,e){if(!oe(t))return oe(e)?e:{};if(!oe(e))return oe(t)?t:{};if(oe(t)&&oe(e)){const i=Object.assign({},t);return Object.keys(e).forEach(n=>{Array.isArray(e[n])?i[n]=e[n].map((e,i)=>t[n]&&oe(t[n][i])&&oe(e)?se(t[n][i],e):e):oe(e[n])?n in t?i[n]=se(t[n],e[n]):Object.assign(i,{[n]:e[n]}):Object.assign(i,{[n]:e[n]})}),i}return{}}function oe(t){return t&&"object"==typeof t&&!Array.isArray(t)}function re(e,i){if(void 0===e)return!1;const n=(s=e.entity_id).substring(0,s.indexOf("."));var s;const o=void 0!==i?i:null==e?void 0:e.state;if(["button","event","input_button","scene"].includes(n))return"unavailable"!==o;if(t(o))return!1;if("off"===o&&"alert"!==n)return!1;switch(n){case"alarm_control_panel":return"disarmed"!==o;case"alert":return"idle"!==o;case"cover":return"closed"!==o;case"device_tracker":case"person":return"not_home"!==o;case"lock":return"locked"!==o;case"media_player":return"standby"!==o;case"vacuum":return!["idle","docked","paused"].includes(o);case"plant":return"problem"===o;case"group":return["on","home","open","locked","problem"].includes(o);case"timer":return"active"===o;case"camera":return"streaming"===o}return!0}const ae=(t,e)=>{if(t===e)return!0;if(t&&e&&"object"==typeof t&&"object"==typeof e){if(t.constructor!==e.constructor)return!1;let i,n;if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(!ae(t[i],e[i]))return!1;return!0}if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;for(i of t.entries())if(!ae(i[1],e.get(i[0])))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(i of t.entries())if(!e.has(i[0]))return!1;return!0}if(ArrayBuffer.isView(t)&&ArrayBuffer.isView(e)){if(n=t.length,n!==e.length)return!1;for(i=n;0!=i--;)if(t[i]!==e[i])return!1;return!0}if(t.constructor===RegExp)return t.source===e.source&&t.flags===e.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===e.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===e.toString();const s=Object.keys(t);if(n=s.length,n!==Object.keys(e).length)return!1;for(i=n;0!=i--;)if(!Object.prototype.hasOwnProperty.call(e,s[i]))return!1;for(i=n;0!=i--;){const n=s[i];if(!ae(t[n],e[n]))return!1}return!0}return t!=t&&e!=e},le=(t,e,i)=>{const n=JSON.parse(JSON.stringify(i));return ce(t,e,n)},ce=(t,e,i)=>{if(["number","boolean"].includes(typeof i))return i;if(!i)return i;if("object"==typeof i)return Object.keys(i).forEach(n=>{i[n]=ce(t,e,i[n])}),i;const n=i.trim();if("[[["===n.substring(0,3)&&"]]]"===n.slice(-3)){return de(t,e,n.slice(3,-3))}return i},de=(t,e,i)=>{try{return new Function("states","entity","user","hass","html","'use strict'; "+i).call(t,t.hass.states,e,t.hass.user,t.hass,q)}catch(t){if(t instanceof Error){const e=i.length<=100?i.trim():i.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${e}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}};console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${a("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let he=class extends gt{constructor(){super(...arguments),this.touchInput=!1,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.zero=0,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0,this.initialTransition=""}setSliderValues(t,e){this._config.inverse?(this.sliderVal=this._config.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","input_boolean","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&(void 0!==this._config&&"seekbar"===this._config.mode&&this.entity.state,Lt(this,t,!1))}updated(t){super.updated(t),requestAnimationFrame(()=>{if(void 0===this.sliderEl&&null!==this.shadowRoot){this.sliderEl=this.shadowRoot.querySelector(".my-slider-custom-container");const t=this.sliderEl.querySelector(".my-slider-custom-progress");this.initialTransition=t.style.transition}})}render(){var t,e,i,n,s,o,r,a,l;const c=this.initializeConfig();if(null!==c)return c;const d=[{transition:this._config.vertical?"height 0.2s ease 0s":"width 0.2s ease 0s"}],h=(null===(t=this._config.styles)||void 0===t?void 0:t.progress)?Object.assign(Object.assign({},d),this._config.styles.progress):d,u=ee(null===(e=this._config.styles)||void 0===e?void 0:e.card)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},g=ee(null===(n=this._config.styles)||void 0===n?void 0:n.container)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=ee(null===(o=this._config.styles)||void 0===o?void 0:o.track)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.track):{},m=ee(h),f=ee(null===(a=this._config.styles)||void 0===a?void 0:a.thumb)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.thumb):{},_=Qt("card",u),v=Qt("container",g),y=Qt("track",p),b=Qt("progress",m),w=Qt("thumb",f);this._config.vertical?(b.height=this.sliderValPercent.toString()+"%",_.height=u.height?u.height:"100%",_.width=u.width?u.width:"30px",b.width=m.width?m.width:"100%",b.right=m.right?m.right:"auto",w.right=f.right?f:"auto",w.width=f.width?f.width:"100%",w.height=f.height?f.height:"10px",this._config.flipped?(b.top=m.top?m.top:"0",w.bottom=f.bottom?f.bottom:"-5px"):(b.bottom=m.bottom?m.bottom:"0",w.top=f.top?f.top:"-5px")):(b.width=this.sliderValPercent.toString()+"%",this._config.flipped&&(b.right=m.right?m.right:"0",w.right=f.right?f.right:"auto",w.left=f.left?f.left:"-5px"));const x=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;S(t);break;case"touchstart":this.touchInput=!0,S(t);break;case"mousemove":if(this.touchInput)return;$(t);break;case"touchmove":this._config.disableScroll&&t.preventDefault(),$(t);break;case"mouseup":case"touchend":case"touchcancel":k(t)}},S=t=>{var e;if(this.actionTaken)return;const i=t.clientX||t.touches[0].clientX,n=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=n),this._config.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const s=t.composedPath()[0],o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(s.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(o){const e=o.getBoundingClientRect();if(i>=e.left-this._config.marginOfError&&i<=e.right+this._config.marginOfError&&n>=e.top-this._config.marginOfError&&n<=e.bottom+this._config.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this._config.allowSliding&&(this.actionTaken=!0),this.clientYLast=n,this.clientXLast=i},k=t=>{if(!this.actionTaken)return;this.sliderEl.querySelector(".my-slider-custom-progress").style.transition=this.initialTransition,(this._config.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.touchInput=!1,this.isSliding=!1,setTimeout(()=>{this.actionTaken=!1},50)},$=t=>{if(this.actionTaken){this.sliderEl.querySelector(".my-slider-custom-progress").style.transition="";const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this._config.allowTapping||this.isSliding||!this._config.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this._config.allowSliding&&(this._config.vertical?Math.abs(i-this.clientYLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(x),q` + +
-
-
-
+
+
+
- `}initializeConfig(){this.entity=this.hass.states[""+this.config.entity];try{this._config=this._objectEvalTemplate(this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}this.sliderId="slider-"+this._config.entity.replace(".","-"),this.colorMode=void 0!==this._config.colorMode?this._config.colorMode:"brightness",this.coverMode=void 0!==this._config.coverMode?this._config.coverMode:"position",this.vertical=void 0!==this._config.vertical&&this._config.vertical,this.flipped=void 0!==this._config.flipped&&this._config.flipped,this.inverse=void 0!==this._config.inverse&&this._config.inverse,this.disableScroll=void 0===this._config.disableScroll||this._config.disableScroll,this.allowTapping=void 0===this._config.allowTapping||this._config.allowTapping,this.allowSliding=void 0!==this._config.allowSliding&&this._config.allowSliding,this.marginOfError=void 0!==this._config.marginOfError?this._config.marginOfError:10,this.slideDistance=void 0!==this._config.slideDistance?this._config.slideDistance:10,this.showMin=void 0!==this._config.showMin&&this._config.showMin,this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:100,this.minThreshold=this._config.minThreshold?this._config.minThreshold:0,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:100,this.step=this._config.step?this._config.step:1;let t=0;switch(this._config.entity.split(".")[0]){case"light":if("brightness"===this.colorMode)this.oldVal=Math.ceil(ne(this.entity.attributes.brightness,256)),"on"===this.entity.state?(t=Math.round(this.entity.attributes.brightness/2.56),this.showMin||(t-=this.min)):t=0;else if("temperature"===this.colorMode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:this.entity.attributes.min_mireds,this.max=this._config.max?this._config.max:this.entity.attributes.max_mireds,t=parseFloat(this.entity.attributes.color_temp),this.oldVal=parseFloat(this.entity.attributes.color_temp),this.showMin||(this.max=this.max-this.min,t-=this.min)}else if("hue"===this.colorMode&&"hs"===this.entity.attributes.color_mode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:360,this.oldVal=parseFloat(this.entity.attributes.hs_color[0]),t=parseFloat(this.entity.attributes.hs_color[0]),this.showMin||(this.max=this.max-this.min,t-=this.min)}else if("saturation"===this.colorMode&&"hs"===this.entity.attributes.color_mode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:100,this.oldVal=parseFloat(this.entity.attributes.hs_color[1]),t=parseFloat(this.entity.attributes.hs_color[1]),this.showMin||(this.max=this.max-this.min,t-=this.min)}this.setSliderValues(t,re(ne(t,this.max)));break;case"input_number":case"number":this.step=this._config.step?this._config.step:this.entity.attributes.step,this.min=this._config.min?this._config.min:this.entity.attributes.min,this.max=this._config.max?this._config.max:this.entity.attributes.max,this.oldVal=parseFloat(this.entity.state),t=parseFloat(this.entity.state),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,re(ne(t,this.max)));break;case"media_player":t=0,null!=this.entity.attributes.volume_level&&(t=Number(100*this.entity.attributes.volume_level)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,re(ne(t,this.max)));break;case"cover":t=0,"position"===this.coverMode?null!=this.entity.attributes.current_position&&(t=Number(this.entity.attributes.current_position)):"tilt"===this.coverMode&&null!=this.entity.attributes.current_tilt_position&&(t=Number(this.entity.attributes.current_tilt_position)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.inverse=void 0===this._config.inverse||this._config.inverse,this.vertical=void 0===this._config.vertical||this._config.vertical,this.flipped=void 0===this._config.flipped||this._config.flipped,this.setSliderValues(t,re(ne(t,this.max)));break;case"fan":t=0,null!=this.entity.attributes.percentage&&(t=Number(this.entity.attributes.percentage)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,re(ne(t,this.max)));break;case"switch":this.minThreshold=this._config.minThreshold?this._config.minThreshold:15,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:75,t=Number(Math.max(this.zero,this.minThreshold)),this.setSliderValues(t,t);break;case"lock":this.minThreshold=this._config.minThreshold?this._config.minThreshold:15,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:75,t=Number(Math.max(this.zero,this.minThreshold)),this.oldVal=t,this.setSliderValues(t,t);break;default:console.log("No Entity type initiated... ("+this._config.entity.split(".")[0]+")")}return null}calcProgress(t){if(null==this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,s=e.touches[0]||e.changedTouches[0];i.x=s.clientX,i.y=s.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let s=e.getBoundingClientRect(),o=i.x-s.left,n=i.y-s.top;return n=e.offsetHeight-n,{x:o,y:n}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,s=this.sliderEl.offsetHeight,o=(this.vertical?re(e.y/s*100):re(e.x/i*100))/100*(this.max-0),n=this.max-o;let r=this.flipped?Math.round(n):Math.round(o);r=rthis.max?this.max:r{n.style.transition=r},200)}_setLock(t,e){var i=Math.min(this.max,this.maxThreshold);if(Number(i)<=e){var s="locked"===t.state?"unlock":"lock";this.hass.callService("lock",s,{entity_id:t.entity_id})}const o=Number(Math.max(this.zero,this.minThreshold)),n=re(ne(o,this.max));this.setSliderValues(o,n);const r=this.sliderEl.querySelector(".my-slider-custom-progress");r.style.transition="width 0.2s ease 0s",r.style.width=n.toString()+"%",setTimeout(()=>{r.style.transition="initial"},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}_objectEvalTemplate(t,e){const i=JSON.parse(JSON.stringify(e));return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach(i=>{e[i]=this._getTemplateOrValue(t,e[i])}),e;const i=e.trim();if("[[["===i.substring(0,3)&&"]]]"===i.slice(-3)){return this._evalTemplate(t,i.slice(3,-3))}return e}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","html","'use strict'; "+e).call(this,this.hass.states,t,this.hass.user,this.hass,U)}catch(t){if(t instanceof Error){const i=e.length<=100?e.trim():e.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${i}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}}static get styles(){return ct` - `}};r([st()],ce.prototype,"_config",void 0),r([st({attribute:!1})],ce.prototype,"hass",void 0),r([nt()],ce.prototype,"config",void 0),ce=r([et("my-slider-v2")],ce);const he="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class de extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:he?"100px":"50px",height:he?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),this.appendChild(this.ripple),this.ripple.primary=!0,["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0},{passive:!0})})}bind(t,e){if(t.actionHandler)return;t.actionHandler=!0,t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1});const i=t=>{let e,i;this.held=!1,t.touches?(e=t.touches[0].pageX,i=t.touches[0].pageY):(e=t.pageX,i=t.pageY),this.timer=window.setTimeout(()=>{this.startAnimation(e,i),this.held=!0},this.holdTime)},s=i=>{i.preventDefault(),["touchend","touchcancel"].includes(i.type)&&void 0===this.timer||(clearTimeout(this.timer),this.stopAnimation(),this.timer=void 0,this.held?Lt(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Lt(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Lt(t,"action",{action:"double_tap"})):Lt(t,"action",{action:"tap"}))};t.addEventListener("touchstart",i,{passive:!0}),t.addEventListener("touchend",s),t.addEventListener("touchcancel",s),t.addEventListener("mousedown",i,{passive:!0}),t.addEventListener("click",s),t.addEventListener("keyup",t=>{13===t.keyCode&&s(t)})}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null}),this.ripple.disabled=!1,this.ripple.active=!0,this.ripple.unbounded=!0}stopAnimation(){this.ripple.active=!1,this.ripple.disabled=!0,this.style.display="none"}}customElements.define("action-handler-my-footer",de);const ue=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("action-handler-my-footer"))return t.querySelector("action-handler-my-footer");const e=document.createElement("action-handler-my-footer");return t.appendChild(e),e})();i&&i.bind(t,e)},pe=w((t={})=>e=>{ue(e.committer.element,t)}),me=(t,e={})=>{const i=ge[t];return i?i(e):void console.log(t+": Not found in styles")},ge={card:t=>Object.assign({height:"125px",width:"100%","min-width":"fit-content",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer"},t),icon:t=>Object.assign({"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",padding:"10px 0 0 10px",color:"var(--paper-item-icon-color)"},t),stats:t=>Object.assign({"margin-left":"auto","margin-right":"5px","margin-top":"5px","margin-bottom":"5px",color:"var(--primary-text-color)",display:"grid","place-items":"center","aspect-ratio":"1 / 1","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, 0.5)"},t),"label-wrapper":t=>Object.assign({width:"100%",height:"100%",display:"flex"},t),label:t=>Object.assign({padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},t),container:t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"column",height:"100%"},t),row1:t=>Object.assign({flex:"0 1 auto",display:"flex","justify-content":"space-between"},t),row2:t=>Object.assign({flex:"1 1 auto"},t),row3:t=>Object.assign({flex:"0 1 auto"},t),"container-column":t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"row",height:"100%"},t),column1:t=>Object.assign({flex:"1"},t),column2:t=>Object.assign({flex:"0"},t)};console.info(`%c ---- MY-BUTTON ---- \n%c ${n("common.version")} 1.0.1 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-button",name:"My Button Card",description:"Custom Button Card for Lovelace."});let fe=class extends dt{constructor(){super(...arguments),this.lastAction=0,this.layout="vertical",this.iconConfig={},this.labelConfig={},this.sliderConfig={},this.statsConfig={},this.cardStl={},this.containerStl={},this.containerColumnStl={},this.iconStl={},this.statsStl={},this.labelWrapperStl={},this.labelStl={},this.row1Stl={},this.row2Stl={},this.row3Stl={},this.column1Stl={},this.column2Stl={}}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","cover","switch"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MyButton"},t)}shouldUpdate(t){return!!this.config&&Yt(this,t,!1)}render(){const t=this.initializeConfig();return null!==t?t:this.entity&&this._config?"vertical"===this.layout?this.verticalLayoutCard():this.horizontalLayoutCard():U``}verticalLayoutCard(){var t,e,i,s,o,n,r,a;return U` - -
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(e=null===(t=this.config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(s=null===(i=this.config)||void 0===i?void 0:i.hold_action)||void 0===s?void 0:s.action)})}> - ${this.iconElement()} + `}initializeConfig(){var t;if(this.actionTaken)return null;this.entity=this.hass.states[""+this.config.entity];try{this._config=le(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return q`Error with evaluated _config`;const e=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:this._config.entity?this._config.entity.split(".")[0]:"none",i={sliderId:`slider-${this._config.entity.replace(".","-")}-${this._config.mode}`,type:this._config.type,disableScroll:void 0===this._config.disableScroll||this._config.disableScroll,allowTapping:void 0===this._config.allowTapping||this._config.allowTapping,allowSliding:void 0!==this._config.allowSliding&&this._config.allowSliding,marginOfError:void 0!==this._config.marginOfError?this._config.marginOfError:10,slideDistance:void 0!==this._config.slideDistance?this._config.slideDistance:10,showMin:void 0!==this._config.showMin&&this._config.showMin,minThreshold:0,maxThreshold:100,sliderMin:this._config.sliderMin?this._config.sliderMin:0,vertical:void 0!==this._config.vertical&&this._config.vertical,flipped:void 0!==this._config.flipped&&this._config.flipped,inverse:void 0!==this._config.inverse&&this._config.inverse,intermediate:void 0!==this._config.intermediate&&this._config.intermediate,min:this._config.min?this._config.min:0,max:this._config.max?this._config.max:100,step:this._config.step?this._config.step:1,mode:void 0!==this._config.mode?this._config.mode:void 0!==this._config.colorMode?this._config.colorMode:void 0!==this._config.coverMode?this._config.coverMode:"light"===e?"brightness":"cover"===e?"position":"media_player"===e?"volume":"brightness"};let n=0,s=0,o=0;switch(e){case"light":if("brightness"===i.mode)this.oldVal=Math.ceil(ie(this.entity.attributes.brightness,256)),"on"===this.entity.state&&(n=Math.ceil(ie(this.entity.attributes.brightness,256)),!i.showMin&&i.min&&(n-=i.min)),n=n*(100-i.sliderMin)/100+i.sliderMin,n=nthis.updateSeekbar(),500);if("playing"!==this.entity.state)return;let t=0;this._config.max=this.entity.attributes.media_duration;const e=new Date,i=new Date(this.entity.attributes.media_position_updated_at);let n=this.entity.attributes.media_position+(e.getTime()-i.getTime())/1e3;n=Math.min(n,this._config.max),t=n,this.setSliderValues(t,ne(ie(t,this._config.max))),this.setProgress(this.sliderEl,Math.round(t),"updateSeekbar"),setTimeout(()=>this.updateSeekbar(),1e3)}calcProgress(t){if(void 0===this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,n=e.touches[0]||e.changedTouches[0];i.x=n.clientX,i.y=n.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let n=e.getBoundingClientRect(),s=i.x-n.left,o=i.y-n.top;return o=e.offsetHeight-o,{x:s,y:o}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,n=this.sliderEl.offsetHeight,s=(this._config.vertical?ne(e.y/n*100):ne(e.x/i*100))/100*(this._config.max-0),o=this._config.max-s;let r=this._config.flipped?o:s;r=rthis._config.max?this._config.max:r{o.style.transition=this.initialTransition},200)}_setLock(t,e){var i=Math.min(this._config.max,this._config.maxThreshold);if(Number(i)<=e){var n="locked"===t.state?"unlock":"lock";this.hass.callService("lock",n,{entity_id:t.entity_id})}const s=Number(Math.max(this.zero,this._config.minThreshold)),o=ne(ie(s,this._config.max)),r=this.sliderEl.querySelector(".my-slider-custom-progress");this._config.vertical?r.style.transition="height 0.2s ease 0s":r.style.transition="width 0.2s ease 0s",this.setSliderValues(s,o),this.setProgress(this.sliderEl,s,"setLock"),setTimeout(()=>{r.style.transition=this.initialTransition},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}static get styles(){return ht` + `}};l([ot()],he.prototype,"_config",void 0),l([ot({attribute:!1})],he.prototype,"hass",void 0),l([at()],he.prototype,"config",void 0),he=l([nt("my-slider-v2")],he);const ue=(t,e,i,n)=>{n=n||{},i=null==i?{}:i;const s=new Event(e,{bubbles:void 0===n.bubbles||n.bubbles,cancelable:Boolean(n.cancelable),composed:void 0===n.composed||n.composed});return s.detail=i,t.dispatchEvent(s),s},ge=1,pe=2,me=3,fe=4,_e=5; +/** + * @license + * Copyright (c) 2021 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at + * http://polymer.github.io/LICENSE.txt + * The complete set of authors may be found at + * http://polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at + * http://polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at + * http://polymer.github.io/PATENTS.txt + */class ve{constructor(t){this.type=pe,this.options=t.options,this.legacyPart=t}get parentNode(){return this.legacyPart.startNode.parentNode}get startNode(){return this.legacyPart.startNode}get endNode(){return this.legacyPart.endNode}}class ye{constructor(t){this.legacyPart=t,this.type=t instanceof j?me:ge}get options(){}get name(){return this.legacyPart.committer.name}get element(){return this.legacyPart.committer.element}get strings(){return this.legacyPart.committer.strings}get tagName(){return this.element.tagName}}class be{constructor(t){this.type=fe,this.legacyPart=t}get options(){}get name(){return this.legacyPart.name}get element(){return this.legacyPart.element}get strings(){return this.legacyPart.strings}get tagName(){return this.element.tagName}}class we{constructor(t){this.type=_e,this.legacyPart=t}get options(){}get name(){return this.legacyPart.eventName}get element(){return this.legacyPart.element}get strings(){}get tagName(){return this.element.tagName}handleEvent(t){this.legacyPart.handleEvent(t)}}const xe="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class Se extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.cancelled=!1,this.isRepeating=!1,this.repeatCount=0}connectedCallback(){Object.assign(this.style,{position:"fixed",width:xe?"100px":"50px",height:xe?"100px":"50px",transform:"translate(-50%, -50%)",pointerEvents:"none",zIndex:"999"}),["touchcancel","mouseout","mouseup","touchmove","mousewheel","wheel","scroll"].forEach(t=>{document.addEventListener(t,()=>{this.cancelled=!0,this.timer&&(this.stopAnimation(),clearTimeout(this.timer),this.timer=void 0,this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1))},{passive:!0})})}bind(t,e){t.actionHandler&&ae(e,t.actionHandler.options)||(t.actionHandler?(t.removeEventListener("touchstart",t.actionHandler.start),t.removeEventListener("touchend",t.actionHandler.end),t.removeEventListener("touchcancel",t.actionHandler.end),t.removeEventListener("mousedown",t.actionHandler.start),t.removeEventListener("click",t.actionHandler.end),t.removeEventListener("keyup",t.actionHandler.handleEnter)):t.addEventListener("contextmenu",t=>{const e=t||window.event;return e.preventDefault&&e.preventDefault(),e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.returnValue=!1,!1}),t.actionHandler={options:e},e.disabled||(t.actionHandler.start=i=>{let n,s;this.cancelled=!1,i.touches?(n=i.touches[0].clientX,s=i.touches[0].clientY):(n=i.clientX,s=i.clientY),e.hasHold&&(this.held=!1,this.timer=window.setTimeout(()=>{this.startAnimation(n,s),this.held=!0,e.repeat&&!this.isRepeating&&(this.repeatCount=0,this.isRepeating=!0,this.repeatTimeout=setInterval(()=>{ue(t,"action",{action:"hold"}),this.repeatCount++,this.repeatTimeout&&e.repeatLimit&&this.repeatCount>=e.repeatLimit&&(clearInterval(this.repeatTimeout),this.isRepeating=!1)},e.repeat))},this.holdTime))},t.actionHandler.end=t=>{if(["touchend","touchcancel"].includes(t.type)&&this.cancelled)return void(this.isRepeating&&this.repeatTimeout&&(clearInterval(this.repeatTimeout),this.isRepeating=!1));const i=t.target;t.cancelable&&t.preventDefault(),e.hasHold&&(clearTimeout(this.timer),this.isRepeating&&this.repeatTimeout&&clearInterval(this.repeatTimeout),this.isRepeating=!1,this.stopAnimation(),this.timer=void 0),e.hasHold&&this.held?e.repeat||ue(i,"action",{action:"hold"}):e.hasDoubleClick?"click"===t.type&&t.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,ue(i,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,ue(i,"action",{action:"double_tap"})):ue(i,"action",{action:"tap"})},t.actionHandler.handleEnter=t=>{13===t.keyCode&&t.currentTarget.actionHandler.end(t)},t.addEventListener("touchstart",t.actionHandler.start,{passive:!0}),t.addEventListener("touchend",t.actionHandler.end),t.addEventListener("touchcancel",t.actionHandler.end),t.addEventListener("mousedown",t.actionHandler.start,{passive:!0}),t.addEventListener("click",t.actionHandler.end),t.addEventListener("keyup",t.actionHandler.handleEnter)))}startAnimation(t,e){Object.assign(this.style,{left:t+"px",top:e+"px",display:null})}stopAnimation(){}}customElements.define("my-card-action-handler",Se);const ke=(t,e)=>{const i=(()=>{const t=document.body;if(t.querySelector("my-card-action-handler"))return t.querySelector("my-card-action-handler");const e=document.createElement("my-card-action-handler");return t.appendChild(e),e})();i&&i.bind(t,e)},$e=function(t){const e=new WeakMap;return S((...i)=>n=>{const s=e.get(n);let o,r;void 0===s?(o=function(t){if(t instanceof H)return new ve(t);if(t instanceof Y)return new we(t);if(t instanceof L)return new be(t);if(t instanceof j||t instanceof A)return new ye(t);throw new Error("Unknown part type")}(n),r=new t(o),e.set(n,[o,r])):(o=s[0],r=s[1]),n.setValue(r.update(o,i)),n.commit()})}(class extends class{constructor(t){}update(t,e){return this.render(...e)}}{update(t,[e]){return ke(t.element,e),$}render(t){}}),Te=(t,e={})=>{const i=Me[t];return i?se(i,e):(console.log(t+": Not found in styles"),e)},Me={card:{height:"125px",width:"100%",background:"var(--card-background-color)",overflow:"hidden",cursor:"pointer",display:"flex","flex-direction":"column"},icon:{"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",color:"var(--paper-item-icon-color)","border-radius":"50%",margin:"7px 0px 0px 7px"},stats:{margin:"5px 2px 0px auto",color:"var(--primary-text-color)",display:"inline-block","font-family":'"Arial", sans-serif',"font-size":"11px","text-align":"center","text-shadow":"2px 2px 4px rgba(0, 0, 0, .9)",width:"50px",height:"50px",padding:"0px 3px"},camera:{"border-radius":"3px",overflow:"hidden"},labelContainer:{width:"100%",height:"100%",display:"flex","flex-direction":"column","align-items":"flex-start",overflow:"hidden"},label:{padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold",cursor:"pointer"},extraText:{margin:"0 10px",color:"var(--primary-text-color)","font-weight":"normal","font-size":"12px","white-space":"nowrap",overflow:"hidden"},row1:{display:"flex","justify-content":"space-between","min-height":"55px"},row2:{},buttonsContainer:{display:"flex","align-items":"flex-start","flex-direction":"row",padding:"0px 5px"},button:{padding:"3px 5px 3px 5px","aspect-ratio":"1 / 1",display:"flex","align-items":"center","justify-content":"center"},buttonText:{padding:"0px",margin:"0px"},buttonIcon:{padding:"0px",margin:"0px",position:"relative","--mdc-icon-size":"100%",display:"flex",height:"20px",width:"20px"},sliderCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"},sliderContainer:{"border-radius":"0px"},sliderTrack:{background:"transparent"},sliderThumbHor:{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"},sliderThumbVer:{width:"20px",height:"3px",top:"2px",left:"7px","border-radius":"50px"},sliderProgressHor:{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"},sliderProgressVer:{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"},seekbarCard:{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default","margin-left":"30px"},seekbarContainer:{"border-radius":"0px"},seekbarTrack:{background:"transparent"},seekbarThumb:{height:"100%",width:"3px",right:"0px","border-radius":"50px",background:"linear-gradient(to top, var(--paper-item-icon-active-color) -20%, transparent 70%)"},seekbarProgress:{background:"transparent"}};console.info(`%c ---- MY-BUTTON ---- \n%c ${a("common.version")} 1.0.2 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-button",name:"My Button Card",description:"Custom Button Card for Lovelace."});let Ce=class extends gt{constructor(){super(...arguments),this.lastAction=0}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["","light","cover","switch","input_boolean","button","lock","media_player"];if(t.entity&&!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MyButton"},t)}shouldUpdate(t){return!!this.config&&Lt(this,t,!1)}updated(t){super.updated(t),requestAnimationFrame(()=>{var t;const e=null===(t=this.shadowRoot)||void 0===t?void 0:t.querySelector('[data-container="label-row"]'),i=null==e?void 0:e.querySelector("p");if(e&&i){const t=window.getComputedStyle(i),n=window.getComputedStyle(e),s=e.offsetWidth,o=i.offsetWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),r=s-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight);i.style.animation=o +
+
this._handleAction(t,this._config)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(e=null===(t=this._config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(n=null===(i=this._config)||void 0===i?void 0:i.hold_action)||void 0===n?void 0:n.action),repeat:null===(o=null===(s=this._config)||void 0===s?void 0:s.hold_action)||void 0===o?void 0:o.repeat,repeatLimit:null===(a=null===(r=this._config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.repeat_limit})}> +
+ ${this.iconElement()} + ${this.statsElement()} +
+
+ ${this.labelElement()} +
- ${this.statsElement()}
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(n=null===(o=this.config)||void 0===o?void 0:o.double_tap_action)||void 0===n?void 0:n.action),hasHold:"none"!==(null===(a=null===(r=this.config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.action)})}> - ${this.labelElement()} +
+ ${!1===this._config.buttons.vertical?this.buttonsElement():""}
-
- ${this.sliderElement()} +
+ ${!1===this._config.slider.vertical?this.sliderElement():""} + ${this._config.seekbar.show?this.seekbarElement():""} +
+
+ ${!0===this._config.buttons.vertical?this.buttonsElement():""} +
+
+ ${!0===this._config.slider.vertical?this.sliderElement():""}
- `}horizontalLayoutCard(){var t,e,i,s,o,n,r,a;return U` - -
-
-
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(e=null===(t=this.config)||void 0===t?void 0:t.double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(s=null===(i=this.config)||void 0===i?void 0:i.hold_action)||void 0===s?void 0:s.action)})}> - ${this.iconElement()} -
-
this._handleAction(t,this.config)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(n=null===(o=this.config)||void 0===o?void 0:o.double_tap_action)||void 0===n?void 0:n.action),hasHold:"none"!==(null===(a=null===(r=this.config)||void 0===r?void 0:r.hold_action)||void 0===a?void 0:a.action)})}> - ${this.labelElement()} -
-
-
+ `}iconElement(){var t,e,i,n;return this._config.icon.show?this._config.icon.tap_action||this._config.icon.double_tap_action||this._config.icon.hold_action?q` + this._handleAction(t,this._config.icon)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(t=this._config.icon.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this._config.icon.hold_action)||void 0===e?void 0:e.action),repeat:null===(i=this._config.icon.hold_action)||void 0===i?void 0:i.repeat,repeatLimit:null===(n=this._config.icon.hold_action)||void 0===n?void 0:n.repeat_limit})} /> + `:q` + + `:q``}statsElement(){var t,e,i,n,s,o,r,a;return this._config.stats.show?this._config.stats.tap_action||this._config.stats.double_tap_action||this._config.stats.hold_action?this._config.camera?q` +
this._handleAction(t,this._config.stats)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(t=this._config.stats.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this._config.stats.hold_action)||void 0===e?void 0:e.action),repeat:null===(i=this._config.stats.hold_action)||void 0===i?void 0:i.repeat,repeatLimit:null===(n=this._config.stats.hold_action)||void 0===n?void 0:n.repeat_limit})}> +
+ + ${this._config.stats.text}
-
- ${this.sliderElement()} + `:q` +
this._handleAction(t,this._config.stats)} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(s=this._config.stats.double_tap_action)||void 0===s?void 0:s.action),hasHold:"none"!==(null===(o=this._config.stats.hold_action)||void 0===o?void 0:o.action),repeat:null===(r=this._config.stats.hold_action)||void 0===r?void 0:r.repeat,repeatLimit:null===(a=this._config.stats.hold_action)||void 0===a?void 0:a.repeat_limit})}> + +
+ ${this._config.stats.text} +
+
+ `:this._config.camera?q` +
+
+ +
+
+ `:q` +
+
+ ${this._config.stats.text} +
+
+ `:q``}labelElement(){var t,e,i,n;return this._config.label.show?this._config.label.tap_action||this._config.label.double_tap_action||this._config.label.hold_action?q` +
+ + ${this._config.label.extra?q`

${this._config.label.extra}

`:""} +
- - `}iconElement(){var t,e;return this.iconConfig.show?this.iconConfig.tap_action||this.iconConfig.double_tap_action||this.iconConfig.hold_action?U` - this._handleAction(t,this.iconConfig)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(t=this.iconConfig.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this.iconConfig.hold_action)||void 0===e?void 0:e.action)})} /> - `:U` - - `:U``}statsElement(){var t,e;return this.statsConfig.show?this.statsConfig.tap_action||this.statsConfig.double_tap_action||this.statsConfig.hold_action?U` -
this._handleAction(t,this.statsConfig)} - .actionHandler=${pe({hasDoubleClick:"none"!==(null===(t=this.statsConfig.double_tap_action)||void 0===t?void 0:t.action),hasHold:"none"!==(null===(e=this.statsConfig.hold_action)||void 0===e?void 0:e.action)})}> - - ${this.statsConfig.text} - -
- `:U` -
- ${this.statsConfig.text} -
- `:U``}labelElement(){var t,e;return this.labelConfig.show?this.labelConfig.tap_action||this.labelConfig.double_tap_action||this.labelConfig.hold_action?U` -
- -
- `:U` -
- + `:q` +
+ + ${this._config.label.extra?q`

${this._config.label.extra}

`:""}
- `:U``}sliderElement(){return this.sliderConfig.show?("horizontal"===this.layout&&(this.sliderConfig.vertical=void 0===this.sliderConfig.vertical||this.sliderConfig.vertical,this.sliderConfig.styles=this.sliderConfig.styles?this.sliderConfig.styles:{},this.sliderConfig.styles.card=this.sliderConfig.styles.card?this.sliderConfig.styles.card:{},this.sliderConfig.styles.card.width=this.sliderConfig.styles.card.width?this.sliderConfig.styles.card.width:"35px"),U` - - `):U``}initializeConfig(){var t,e,i,s,o,n,r,a,l,c,h,d,u,p,m,g,f,v,y,_,b,w,S;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=this._objectEvalTemplate(this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return U`Error with this._config...`;const x=this._config.entity.split(".")[0],C={show:!0,icon:"mdi:lightbulb-outline"};"cover"===x?C.icon=(null===(t=this.entity.attributes)||void 0===t?void 0:t.current_position)>=50?"mdi:blinds-open":"mdi:blinds":"switch"===x&&(C.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off");const $={show:!0,text:this.entity.attributes.friendly_name};this.layout=this._config.layout?this._config.layout:"vertical","cover"===this._config.entity.split(".")[0]&&(this.layout=this._config.layout?this._config.layout:"horizontal"),this.iconConfig="string"==typeof this._config.icon?Object.assign(Object.assign({},C),{icon:this._config.icon}):"object"==typeof this._config.icon?ae(C,this._config.icon):C,this.labelConfig="string"==typeof this._config.label?Object.assign(Object.assign({},$),{text:this._config.label}):"object"==typeof this._config.label?ae($,this._config.label):$;const T={show:!!this.entity.attributes.brightness,text:this.entity.attributes.brightness&&Math.ceil(ne(this.entity.attributes.brightness,256))};this.statsConfig="string"==typeof this._config.stats?Object.assign(Object.assign({},T),{text:this._config.stats}):"object"==typeof this._config.stats?ae(T,this._config.stats):T;const k={show:!0,entity:this.entity.entity_id,styles:{card:[{"border-radius":"0px",background:"transparent","box-shadow":"none",cursor:"default"}],container:[{"border-radius":"0px"}],thumb:"vertical"===this.layout?[{height:"20px",width:"3px",top:"6px",right:"2px","border-radius":"50px"}]:[{width:"20px",height:"3px",bottom:"2px",left:"7px","border-radius":"50px"}],track:[{background:"transparent"}],progress:"vertical"===this.layout?[{background:"linear-gradient(to top, var(--paper-item-icon-active-color), transparent)"}]:[{background:"linear-gradient(to left, var(--paper-item-icon-active-color), transparent)"}]}};"switch"===x&&(k.show=!1),this.sliderConfig=this._config.slider?ae(k,this._config.slider):k;let M=[];if("light"===x)if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;M=[{background:`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(ne(this.entity.attributes.brightness,256))/t+"%"})`}]}else M=[{background:"radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)"}];else if("switch"===x){M=[{background:"on"===this.entity.state?"radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 50%)":"radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)"}]}const E=(null===(e=this._config.styles)||void 0===e?void 0:e.card)?Object.assign(Object.assign({},M),this._config.styles.card):M,P=[{color:"on"===this.entity.state?"var(--paper-item-icon-active-color)":"var(--paper-item-icon-color)"},{filter:"on"===this.entity.state?"drop-shadow(2px 2px 2px rgba(0,0,0,0.6)":"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"}],O=(null===(i=this._config.styles)||void 0===i?void 0:i.icon)?Object.assign(Object.assign({},P),this._config.styles.icon):P;return this.cardStl=me("card",oe(E)?oe(E):{}),this.containerStl=me("container",oe(null===(s=this._config.styles)||void 0===s?void 0:s.container)?oe(null===(o=this._config.styles)||void 0===o?void 0:o.container):{}),this.containerColumnStl=me("container-column",oe(null===(n=this._config.styles)||void 0===n?void 0:n.containerColumn)?oe(null===(r=this._config.styles)||void 0===r?void 0:r.containerColumn):{}),this.iconStl=me("icon",oe(O)?oe(O):{}),this.statsStl=me("stats",oe(null===(a=this._config.styles)||void 0===a?void 0:a.stats)?oe(null===(l=this._config.styles)||void 0===l?void 0:l.stats):{}),this.labelWrapperStl=me("label-wrapper",oe(null===(c=this._config.styles)||void 0===c?void 0:c.labelWrapper)?oe(null===(h=this._config.styles)||void 0===h?void 0:h.labelWrapper):{}),this.labelStl=me("label",oe(null===(d=this._config.styles)||void 0===d?void 0:d.label)?oe(null===(u=this._config.styles)||void 0===u?void 0:u.label):{}),this.row1Stl=me("row1",oe(null===(p=this._config.styles)||void 0===p?void 0:p.row1)?oe(null===(m=this._config.styles)||void 0===m?void 0:m.row1):{}),this.row2Stl=me("row2",oe(null===(g=this._config.styles)||void 0===g?void 0:g.row2)?oe(null===(f=this._config.styles)||void 0===f?void 0:f.row2):{}),this.row3Stl=me("row3",oe(null===(v=this._config.styles)||void 0===v?void 0:v.row3)?oe(null===(y=this._config.styles)||void 0===y?void 0:y.row3):{}),this.column1Stl=me("column1",oe(null===(_=this._config.styles)||void 0===_?void 0:_.column1)?oe(null===(b=this._config.styles)||void 0===b?void 0:b.column1):{}),this.column2Stl=me("column2",oe(null===(w=this._config.styles)||void 0===w?void 0:w.column2)?oe(null===(S=this._config.styles)||void 0===S?void 0:S.column2):{}),null}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<100)&&(this.lastAction=(new Date).getTime(),e.entity||(e.entity=this._config.entity),null===(i=t.detail)||void 0===i?void 0:i.action))switch(t.detail.action){case"tap":e.tap_action&&this._handleTap(e);break;case"hold":e.hold_action&&this._handleHold(e);break;case"double_tap":e.double_tap_action&&this._handleDblTap(e)}}_handleTap(t){Ht(this,this.hass,this._evalActions(this._config,"tap_action"),!1,!1)}_handleHold(t){Ht(this,this.hass,this._evalActions(this._config,"hold_action"),!0,!1)}_handleDblTap(t){Ht(this,this.hass,this._evalActions(this._config,"double_tap_action"),!1,!0)}_evalActions(t,e){const i=JSON.parse(JSON.stringify(t)),s=t=>t?(Object.keys(t).forEach(e=>{"object"==typeof t[e]?t[e]=s(t[e]):t[e]=this._getTemplateOrValue(this.entity,t[e])}),t):t;return i[e]=s(i[e]),!i[e].confirmation&&i.confirmation&&(i[e].confirmation=s(i.confirmation)),i}_objectEvalTemplate(t,e){const i=JSON.parse(JSON.stringify(e));return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach(i=>{e[i]=this._getTemplateOrValue(t,e[i])}),e;const i=e.trim();if("[[["===i.substring(0,3)&&"]]]"===i.slice(-3)){return this._evalTemplate(t,i.slice(3,-3))}return e}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","html","'use strict'; "+e).call(this,this.hass.states,t,this.hass.user,this.hass,U)}catch(t){if(t instanceof Error){const i=e.length<=100?e.trim():e.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${i}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}}static get styles(){return ct``}};r([st()],fe.prototype,"_config",void 0),r([st({attribute:!1})],fe.prototype,"hass",void 0),r([nt()],fe.prototype,"config",void 0),fe=r([et("my-button")],fe),console.info(`%c ---- MY-CARDS ---- \n%c ${n("common.version")} 2.0.3 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green");export{fe as MyButton,Qt as MySlider,ce as MySliderV2}; + `:q``}sliderElement(){return this._config.slider.show?q` + + `:q``}buttonsElement(){if(!this._config.buttons.show)return q``;let t=Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>{var e,i,n,s;return this._config.buttons[t].show?this._config.buttons[t].tap_action||this._config.buttons[t].double_tap_action||this._config.buttons[t].hold_action?q` +
this._handleAction(e,this._config.buttons[t])} + .actionHandler=${$e({hasDoubleClick:"none"!==(null===(e=this._config.buttons[t].double_tap_action)||void 0===e?void 0:e.action),hasHold:"none"!==(null===(i=this._config.buttons[t].hold_action)||void 0===i?void 0:i.action),repeat:null===(n=this._config.buttons[t].hold_action)||void 0===n?void 0:n.repeat,repeatLimit:null===(s=this._config.buttons[t].hold_action)||void 0===s?void 0:s.repeat_limit})}> + ${this._config.buttons[t].text?q`

${this._config.buttons[t].text}

`:""} + ${this._config.buttons[t].icon?q``:""} +
`:q` +
+ ${this._config.buttons[t].text?q`

${this._config.buttons[t].text}

`:""} + ${this._config.buttons[t].icon?q``:""} +
`:q``});return q` +
+ ${t} + +
+ `}seekbarElement(){return this._config.slider.show?q` + + `:q``}initializeConfig(){var t,e;this.entity=this.hass.states[""+this.config.entity],0===this.lastAction&&(this.lastAction=(new Date).getTime());try{this._config=le(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return q`Error with this._config...`;const i=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",n={},s={show:!0,icon:"mdi:power"},o={show:!0},r={show:!1},a={show:!1,vertical:!0,styles:{}},l={show:!0,vertical:!1,entity:this._config.entity,allowTapping:!1,marginOfError:10},c={show:!1,entity:this._config.entity};if("none"!==i){const t="cover"===i,d="cover"===i,h=this.entity.state;o.text=this.entity.attributes.friendly_name,r.text=h.charAt(0).toUpperCase()+h.slice(1),l.entity=this.entity.entity_id,l.vertical=t,l.flipped=d,"light"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},this.entity.attributes.brightness&&(n.hold_action={action:"more-info"},r.text=Math.ceil(ie(this.entity.attributes.brightness,256))+"%"),r.show=!0,l.allowSliding=!0,l.slideDistance=15):"cover"===i?(n.hold_action={action:"more-info"},s.icon=(null===(e=this.entity.attributes)||void 0===e?void 0:e.current_position)>=50?"mdi:blinds-open":"mdi:blinds"):"switch"===i||"input_boolean"===i?(n.tap_action={action:"toggle"},n.hold_action={action:"more-info"},r.show=!0,l.show=!1,s.icon="on"===this.entity.state?"mdi:power-plug":"mdi:power-plug-off"):"button"===i?(n.tap_action={action:"call-service",service:"button.press",service_data:{entity_id:this.entity.entity_id}},n.hold_action={action:"more-info"},l.show=!1):"lock"===i?(n.hold_action={action:"more-info"},l.show=!1,r.show=!0,this._config.camera&&"string"==typeof this._config.camera&&(this._config.camera=this.hass.states[this._config.camera],r.entity=this._config.camera.entity_id,r.tap_action={action:"more-info"}),"locked"===this.entity.state?(s.icon="mdi:lock-outline",n.tap_action={action:"call-service",service:"lock.unlock",service_data:{entity_id:this.entity.entity_id}}):"unlocked"===this.entity.state&&(s.icon="mdi:lock-open-variant-outline",n.tap_action={action:"call-service",service:"lock.lock",service_data:{entity_id:this.entity.entity_id}})):"media_player"===i&&(n.tap_action={action:"more-info"},"speaker"===this.entity.attributes.device_class?(s.icon=re(this.entity,this.entity.state)?"mdi:speaker":"mdi:speaker-off","playing"===this.entity.state?s.icon="mdi:speaker-play":"paused"===this.entity.state&&(s.icon="mdi:speaker-pause")):"tv"===this.entity.attributes.device_class&&(s.icon=re(this.entity,this.entity.state)?"mdi:television":"mdi:television-off","playing"===this.entity.state?s.icon="mdi:television-play":"paused"===this.entity.state&&(s.icon="mdi:television-pause")),l.show="paused"!==this.entity.state&&re(this.entity,this.entity.state),l.vertical=!0,l.sliderMin=5,l.min=1,l.allowTapping=!1,l.marginOfError=10,c.show=re(this.entity,this.entity.state),c.vertical=!1,c.allowTapping=!1,c.marginOfError=5,c.mode="seekbar",this.entity.attributes.media_title&&(o.extra=this.entity.attributes.media_title+" - "+this.entity.attributes.media_artist),a.vertical=!1,a.show=!0,a.button0={show:!0,icon:"playing"===this.entity.state?"mdi:pause":"mdi:play",styles:{container:{position:"absolute"}},tap_action:{action:"call-service",service:"playing"===this.entity.state?"media_player.media_pause":"media_player.media_play",service_data:{entity_id:this.entity.entity_id}}})}else l.show=!1;const d=se(n,this._config);return this._config=void 0!==d?d:this._config,this._config.icon="string"==typeof this._config.icon?Object.assign(Object.assign({},s),{icon:this._config.icon}):"object"==typeof this._config.icon?se(s,this._config.icon):s,this._config.label="string"==typeof this._config.label?Object.assign(Object.assign({},o),{text:this._config.label}):"object"==typeof this._config.label?se(o,this._config.label):o,this._config.stats="string"==typeof this._config.stats?Object.assign(Object.assign({},r),{text:this._config.stats}):"object"==typeof this._config.stats?se(r,this._config.stats):r,this._config.buttons="object"==typeof this._config.buttons?se(a,this._config.buttons):a,this._config.slider=this._config.slider?se(l,this._config.slider):l,this._config.seekbar=this._config.seekbar?se(c,this._config.seekbar):c,void 0!==this._config.styles&&null!==this._config.styles||(this._config.styles={}),this.initializeStyles(),null}initializeStyles(){var t,e,i,n,s,o,r,a,l,c,d,h,u,g,p,m,f,_,v,y,b,w,x,S,k,$,T,M,C,E,P,N,O,V,A,H,L,D,j,R,Y,I,z,F,U,B,q,W,X,J,Z,G,K,Q,tt,et;if(!this._config)return;const it=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:"none",nt={background:"radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)"},st={filter:"drop-shadow(3px 3px 2px rgba(0,0,0,0.3)"},ot={card:Te("sliderCard",ee(null===(e=this._config.styles)||void 0===e?void 0:e.sliderCard)?ee(null===(i=this._config.styles)||void 0===i?void 0:i.sliderCard):{}),container:Te("sliderContainer",ee(null===(n=this._config.styles)||void 0===n?void 0:n.sliderContainer)?ee(null===(s=this._config.styles)||void 0===s?void 0:s.sliderContainer):{}),track:Te("sliderTrack",ee(null===(o=this._config.styles)||void 0===o?void 0:o.sliderTrack)?ee(null===(r=this._config.styles)||void 0===r?void 0:r.sliderTrack):{}),progress:this._config.slider.vertical?Te("sliderProgressVer",ee(null===(a=this._config.styles)||void 0===a?void 0:a.sliderProgressVer)?ee(null===(l=this._config.styles)||void 0===l?void 0:l.sliderProgressVer):{}):Te("sliderProgressHor",ee(null===(c=this._config.styles)||void 0===c?void 0:c.sliderProgressHor)?ee(null===(d=this._config.styles)||void 0===d?void 0:d.sliderProgressHor):{}),thumb:this._config.slider.vertical?Te("sliderThumbVer",ee(null===(h=this._config.styles)||void 0===h?void 0:h.sliderThumbVer)?ee(null===(u=this._config.styles)||void 0===u?void 0:u.sliderThumbVer):{}):Te("sliderThumbHor",ee(null===(g=this._config.styles)||void 0===g?void 0:g.sliderThumbHor)?ee(null===(p=this._config.styles)||void 0===p?void 0:p.sliderThumbHor):{})},rt={container:Te("stats",ee(null===(m=this._config.styles)||void 0===m?void 0:m.stats)?ee(null===(f=this._config.styles)||void 0===f?void 0:f.stats):{}),camera:Te("camera",ee(null===(_=this._config.styles)||void 0===_?void 0:_.camera)?ee(null===(v=this._config.styles)||void 0===v?void 0:v.camera):{})},at={container:Te("labelContainer",ee(null===(y=this._config.styles)||void 0===y?void 0:y.labelContainer)?ee(null===(b=this._config.styles)||void 0===b?void 0:b.labelContainer):{}),label:Te("label",ee(null===(w=this._config.styles)||void 0===w?void 0:w.label)?ee(null===(x=this._config.styles)||void 0===x?void 0:x.label):{}),extraText:Te("extraText",ee(null===(S=this._config.styles)||void 0===S?void 0:S.extraText)?ee(null===(k=this._config.styles)||void 0===k?void 0:k.extraText):{})},lt={container:Te("buttonsContainer",ee(null===($=this._config.styles)||void 0===$?void 0:$.buttonsContainer)?ee(null===(T=this._config.styles)||void 0===T?void 0:T.buttonsContainer):{}),button:Te("button",ee(null===(M=this._config.styles)||void 0===M?void 0:M.button)?ee(null===(C=this._config.styles)||void 0===C?void 0:C.button):{}),text:Te("buttonText",ee(null===(E=this._config.styles)||void 0===E?void 0:E.buttonText)?ee(null===(P=this._config.styles)||void 0===P?void 0:P.buttonText):{}),icon:Te("buttonIcon",ee(null===(N=this._config.styles)||void 0===N?void 0:N.buttonIcon)?ee(null===(O=this._config.styles)||void 0===O?void 0:O.buttonIcon):{})},ct={card:Te("seekbarCard",ee(null===(V=this._config.styles)||void 0===V?void 0:V.seekbarCard)?ee(null===(A=this._config.styles)||void 0===A?void 0:A.seekbarCard):{}),container:Te("seekbarContainer",ee(null===(H=this._config.styles)||void 0===H?void 0:H.seekbarContainer)?ee(null===(L=this._config.styles)||void 0===L?void 0:L.seekbarContainer):{}),track:Te("seekbarTrack",ee(null===(D=this._config.styles)||void 0===D?void 0:D.seekbarTrack)?ee(null===(j=this._config.styles)||void 0===j?void 0:j.seekbarTrack):{}),progress:Te("seekbarProgress",ee(null===(R=this._config.styles)||void 0===R?void 0:R.seekbarProgress)?ee(null===(Y=this._config.styles)||void 0===Y?void 0:Y.seekbarProgress):{}),thumb:Te("seekbarThumb",ee(null===(I=this._config.styles)||void 0===I?void 0:I.seekbarThumb)?ee(null===(z=this._config.styles)||void 0===z?void 0:z.seekbarThumb):{})};if(this._config.slider.vertical&&this._config.slider.flipped&&(ot.thumb.top="initial",ot.thumb.bottom="2px"),this._config.buttons.vertical&&(lt.container["flex-direction"]="column"),"none"!==it)if(re(this.entity,this.entity.state)&&(st.color="var(--paper-item-icon-active-color)",st.filter="drop-shadow(2px 2px 2px rgba(0,0,0,0.75)",nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)"),"light"===it){if(this.entity.attributes.brightness){let t=1+this.entity.attributes.brightness/256;nt.background=`radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(ie(this.entity.attributes.brightness,256))/t+"%"})`}}else"switch"===it||"input_boolean"===it||("lock"===it?"locked"===this.entity.state||"unlocked"===this.entity.state&&(st.color="var(--paper-item-icon-active-color)",nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) 40%)"):"media_player"===it||"cover"===it&&(this.entity.attributes.current_position<=50?nt.background="radial-gradient(circle at top left, rgba(230, 230, 230, 0.25), var(--card-background-color) 40%)":st.color="var(--paper-item-icon-color)"));Object.keys(this._config.buttons).filter(t=>t.startsWith("button")).map(t=>(this._config.buttons[t].styles?(this._config.buttons[t].styles.container?this._config.buttons[t].styles.container=se(lt.button,this._config.buttons[t].styles.container?ee(this._config.buttons[t].styles.container):{}):this._config.buttons[t].styles.container=se(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),this._config.buttons[t].styles.text?this._config.buttons[t].styles.text=se(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.text=se(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),this._config.buttons[t].styles.icon?this._config.buttons[t].styles.icon=se(lt.text,this._config.buttons[t].styles.text?ee(this._config.buttons[t].styles.text):{}):this._config.buttons[t].styles.icon=se(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})):this._config.buttons[t].styles={container:se(lt.button,this._config.buttons.styles.button?ee(this._config.buttons.styles.button):{}),text:se(lt.text,this._config.buttons.styles.text?ee(this._config.buttons.styles.text):{}),icon:se(lt.icon,this._config.buttons.styles.icon?ee(this._config.buttons.styles.icon):{})},null));const dt=(null===(F=this._config.styles)||void 0===F?void 0:F.card)?Object.assign(Object.assign({},nt),ee(this._config.styles.card)):nt,ht=(null===(U=this._config.styles)||void 0===U?void 0:U.icon)?Object.assign(Object.assign({},st),ee(this._config.styles.icon)):st;this._config.styles.card=Te("card",ee(dt)),this._config.styles.icon=Te("icon",ee(ht)),this._config.styles.row1=Te("row1",ee(null===(B=this._config.styles)||void 0===B?void 0:B.row1)?ee(null===(q=this._config.styles)||void 0===q?void 0:q.row1):{}),this._config.styles.row2=Te("row2",ee(null===(W=this._config.styles)||void 0===W?void 0:W.row2)?ee(null===(X=this._config.styles)||void 0===X?void 0:X.row2):{}),this._config.styles.button=Te("button",ee(null===(J=this._config.styles)||void 0===J?void 0:J.button)?ee(null===(Z=this._config.styles)||void 0===Z?void 0:Z.button):{}),this._config.slider.styles=(null===(G=this._config.slider)||void 0===G?void 0:G.styles)?se(ot,this._config.slider.styles):ot,this._config.stats.styles=(null===(K=this._config.stats)||void 0===K?void 0:K.styles)?se(rt,this._config.stats.styles):rt,this._config.label.styles=(null===(Q=this._config.label)||void 0===Q?void 0:Q.styles)?se(at,this._config.label.styles):at,this._config.buttons.styles=(null===(tt=this._config.buttons)||void 0===tt?void 0:tt.styles)?se(lt,this._config.buttons.styles):lt,this._config.seekbar.styles=(null===(et=this._config.seekbar)||void 0===et?void 0:et.styles)?se(ct,this._config.seekbar.styles):ct}_handleAction(t,e){var i;t.stopPropagation(),t.stopImmediatePropagation();if(!((new Date).getTime()-this.lastAction<25)&&(this.lastAction=(new Date).getTime(),e.entity||(e.entity=this._config.entity),null===(i=t.detail)||void 0===i?void 0:i.action))switch(t.detail.action){case"tap":case"hold":case"double_tap":if(!e)return;const i=t.detail.action,n=((t,e,i)=>{const n=JSON.parse(JSON.stringify(e)),s=e=>e?(Object.keys(e).forEach(i=>{"object"==typeof e[i]?e[i]=s(e[i]):e[i]=ce(t,t.entity,e[i])}),e):e;return n[i]=s(n[i]),!n[i].confirmation&&n.confirmation&&(n[i].confirmation=s(n.confirmation)),n})(this,e,i+"_action");(async(t,e,i,n)=>{ue(t,"hass-action",{config:i,action:n})})(this,this.hass,n,i)}}static get styles(){return ht` + @keyframes marquee { + 0% { text-indent: 100% } + 100% { text-indent: -100% } + } + `}};l([ot()],Ce.prototype,"_hass",void 0),l([ot()],Ce.prototype,"_config",void 0),l([ot({attribute:!1})],Ce.prototype,"hass",void 0),l([at()],Ce.prototype,"config",void 0),Ce=l([nt("my-button")],Ce),console.info(`%c ---- MY-CARDS ---- \n%c ${a("common.version")} 2.0.4 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green");export{Ce as MyButton,Zt as MySlider,he as MySliderV2}; diff --git a/dist/my-slider-v2.js b/dist/my-slider-v2.js index 532e731..b3ae078 100644 --- a/dist/my-slider-v2.js +++ b/dist/my-slider-v2.js @@ -12,7 +12,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ -function t(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(r=(o<3?n(r):o>3?n(e,i,r):n(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r +function t(t,e,i,s){var n,r=arguments.length,o=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(n=t[a])&&(o=(r<3?n(o):r>3?n(e,i,o):n(e,i))||o);return r>3&&o&&Object.defineProperty(e,i,o),o /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -25,7 +25,7 @@ function t(t,e,i,s){var n,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPro * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */}const e="undefined"!=typeof window&&null!=window.customElements&&void 0!==window.customElements.polyfillWrapFlushCallback,i=(t,e,i=null)=>{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},s=`{{lit-${String(Math.random()).slice(2)}}}`,n=`\x3c!--${s}--\x3e`,o=new RegExp(`${s}|${n}`);class r{constructor(t,e){this.parts=[],this.element=e;const i=[],n=[],r=document.createTreeWalker(e.content,133,null,!1);let h=0,d=-1,u=0;const{strings:p,values:{length:m}}=t;for(;u0;){const e=p[u],i=c.exec(e)[2],s=i.toLowerCase()+"$lit$",n=t.getAttribute(s);t.removeAttribute(s);const r=n.split(o);this.parts.push({type:"attribute",index:d,name:i,strings:r}),u+=r.length-1}}"TEMPLATE"===t.tagName&&(n.push(t),r.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(s)>=0){const s=t.parentNode,n=e.split(o),r=n.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},h=t=>-1!==t.index,l=()=>document.createComment(""),c=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function d(t,e){const{element:{content:i},parts:s}=t,n=document.createTreeWalker(i,133,null,!1);let o=p(s),r=s[o],a=-1,h=0;const l=[];let c=null;for(;n.nextNode();){a++;const t=n.currentNode;for(t.previousSibling===c&&(c=null),e.has(t)&&(l.push(t),null===c&&(c=t)),null!==c&&h++;void 0!==r&&r.index===a;)r.index=null!==c?-1:r.index-h,o=p(s,o),r=s[o]}l.forEach(t=>t.parentNode.removeChild(t))}const u=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},p=(t,e=-1)=>{for(let i=e+1;i{for(;e!==i;){const i=e.nextSibling;t.removeChild(e),e=i}},s=`{{lit-${String(Math.random()).slice(2)}}}`,n=`\x3c!--${s}--\x3e`,r=new RegExp(`${s}|${n}`);class o{constructor(t,e){this.parts=[],this.element=e;const i=[],n=[],o=document.createTreeWalker(e.content,133,null,!1);let l=0,d=-1,u=0;const{strings:p,values:{length:m}}=t;for(;u0;){const e=p[u],i=c.exec(e)[2],s=i.toLowerCase()+"$lit$",n=t.getAttribute(s);t.removeAttribute(s);const o=n.split(r);this.parts.push({type:"attribute",index:d,name:i,strings:o}),u+=o.length-1}}"TEMPLATE"===t.tagName&&(n.push(t),o.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(s)>=0){const s=t.parentNode,n=e.split(r),o=n.length-1;for(let e=0;e{const i=t.length-e.length;return i>=0&&t.slice(i)===e},l=t=>-1!==t.index,h=()=>document.createComment(""),c=/([ \x09\x0a\x0c\x0d])([^\0-\x1F\x7F-\x9F "'>=/]+)([ \x09\x0a\x0c\x0d]*=[ \x09\x0a\x0c\x0d]*(?:[^ \x09\x0a\x0c\x0d"'`<>=]*|"[^"]*|'[^']*))$/;function d(t,e){const{element:{content:i},parts:s}=t,n=document.createTreeWalker(i,133,null,!1);let r=p(s),o=s[r],a=-1,l=0;const h=[];let c=null;for(;n.nextNode();){a++;const t=n.currentNode;for(t.previousSibling===c&&(c=null),e.has(t)&&(h.push(t),null===c&&(c=t)),null!==c&&l++;void 0!==o&&o.index===a;)o.index=null!==c?-1:o.index-l,r=p(s,r),o=s[r]}h.forEach(t=>t.parentNode.removeChild(t))}const u=t=>{let e=11===t.nodeType?0:1;const i=document.createTreeWalker(t,133,null,!1);for(;i.nextNode();)e++;return e},p=(t,e=-1)=>{for(let i=e+1;i"function"==typeof t&&m.has(t),f={},_={}; * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class y{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this.options=i}update(t){let e=0;for(const i of this.__parts)void 0!==i&&i.setValue(t[e]),e++;for(const t of this.__parts)void 0!==t&&t.commit()}_clone(){const t=e?this.template.element.content.cloneNode(!0):document.importNode(this.template.element.content,!0),i=[],s=this.template.parts,n=document.createTreeWalker(t,133,null,!1);let o,r=0,a=0,l=n.nextNode();for(;rt}),S=` ${s} `;class b{constructor(t,e,i,s){this.strings=t,this.values=e,this.type=i,this.processor=s}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let o=0;o-1||i)&&-1===t.indexOf("--\x3e",r+1);const a=c.exec(t);e+=null===a?t+(i?S:n):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+s}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==v&&(e=v.createHTML(e)),t.innerHTML=e,t}} + */const v=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),b=` ${s} `;class S{constructor(t,e,i,s){this.strings=t,this.values=e,this.type=i,this.processor=s}getHTML(){const t=this.strings.length-1;let e="",i=!1;for(let r=0;r-1||i)&&-1===t.indexOf("--\x3e",o+1);const a=c.exec(t);e+=null===a?t+(i?b:n):t.substr(0,a.index)+a[1]+a[2]+"$lit$"+a[3]+s}return e+=this.strings[t],e}getTemplateElement(){const t=document.createElement("template");let e=this.getHTML();return void 0!==v&&(e=v.createHTML(e)),t.innerHTML=e,t}} /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -79,7 +79,7 @@ class y{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */const w=t=>null===t||!("object"==typeof t||"function"==typeof t),x=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class T{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return V=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class k{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;g(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=f,t(this)}if(this.__pendingValue===f)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),s=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=O(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=f}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const O=t=>t&&(V?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */const w=t=>null===t||!("object"==typeof t||"function"==typeof t),x=t=>Array.isArray(t)||!(!t||!t[Symbol.iterator]);class M{constructor(t,e,i){this.dirty=!0,this.element=t,this.name=e,this.strings=i,this.parts=[];for(let t=0;t{try{const t={get capture(){return C=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class V{constructor(t,e,i){this.value=void 0,this.__pendingValue=void 0,this.element=t,this.eventName=e,this.eventContext=i,this.__boundHandleEvent=t=>this.handleEvent(t)}setValue(t){this.__pendingValue=t}commit(){for(;g(this.__pendingValue);){const t=this.__pendingValue;this.__pendingValue=f,t(this)}if(this.__pendingValue===f)return;const t=this.__pendingValue,e=this.value,i=null==t||null!=e&&(t.capture!==e.capture||t.once!==e.once||t.passive!==e.passive),s=null!=t&&(null==e||i);i&&this.element.removeEventListener(this.eventName,this.__boundHandleEvent,this.__options),s&&(this.__options=O(t),this.element.addEventListener(this.eventName,this.__boundHandleEvent,this.__options)),this.value=t,this.__pendingValue=f}handleEvent(t){"function"==typeof this.value?this.value.call(this.eventContext||this.element,t):this.value.handleEvent(t)}}const O=t=>t&&(C?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -92,7 +92,7 @@ class y{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */;function A(t){let e=D.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},D.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(s);return i=e.keyString.get(n),void 0===i&&(i=new r(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const D=new Map,Y=new WeakMap; + */;function A(t){let e=D.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},D.set(t.type,e));let i=e.stringsArray.get(t.strings);if(void 0!==i)return i;const n=t.strings.join(s);return i=e.keyString.get(n),void 0===i&&(i=new o(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const D=new Map,Y=new WeakMap; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -119,7 +119,7 @@ class y{constructor(t,e,i){this.__parts=[],this.template=t,this.processor=e,this * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){return new C(t,e.slice(1),i).parts}if("@"===n)return[new k(t,e.slice(1),s.eventContext)];if("?"===n)return[new N(t,e.slice(1),i)];return new T(t,e,i).parts}handleTextExpression(t){return new P(t)}}; +class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){return new E(t,e.slice(1),i).parts}if("@"===n)return[new V(t,e.slice(1),s.eventContext)];if("?"===n)return[new k(t,e.slice(1),i)];return new M(t,e,i).parts}handleTextExpression(t){return new P(t)}}; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -132,7 +132,7 @@ class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){return new C( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new b(t,e,"html",L) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new S(t,e,"html",L) /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -145,7 +145,7 @@ class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){return new C( * Code distributed by Google as part of the polymer project is also * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt - */,R=(t,e)=>`${t}--${e}`;let $=!0;void 0===window.ShadyCSS?$=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),$=!1);const j=t=>e=>{const i=R(e.type,t);let n=D.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},D.set(i,n));let o=n.stringsArray.get(e.strings);if(void 0!==o)return o;const a=e.strings.join(s);if(o=n.keyString.get(a),void 0===o){const i=e.getTemplateElement();$&&window.ShadyCSS.prepareTemplateDom(i,t),o=new r(e,i),n.keyString.set(a,o)}return n.stringsArray.set(e.strings,o),o},H=["html","svg"],F=new Set,I=(t,e,i)=>{F.add(t);const s=i?i.element:document.createElement("template"),n=e.querySelectorAll("style"),{length:o}=n;if(0===o)return void window.ShadyCSS.prepareTemplateStyles(s,t);const r=document.createElement("style");for(let t=0;t{H.forEach(e=>{const i=D.get(R(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),d(t,i)})})})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:n}=t;if(null==i)return void s.appendChild(e);const o=document.createTreeWalker(s,133,null,!1);let r=p(n),a=0,h=-1;for(;o.nextNode();){h++;for(o.currentNode===i&&(a=u(e),i.parentNode.insertBefore(e,i));-1!==r&&n[r].index===h;){if(a>0){for(;-1!==r;)n[r].index+=a,r=p(n,r);return}r=p(n,r)}}}(i,r,a.firstChild):a.insertBefore(r,a.firstChild),window.ShadyCSS.prepareTemplateStyles(s,t);const h=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==h)e.insertBefore(h.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(r,a.firstChild);const t=new Set;t.add(r),d(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const z={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},q=(t,e)=>e!==t&&(e==e||t==t),B={attribute:!0,type:String,converter:z,reflect:!1,hasChanged:q};class W extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const s=this._attributeNameForProperty(i,e);void 0!==s&&(this._attributeToPropertyMap.set(s,i),t.push(s))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=B){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const n=this[t];this[e]=s,this.requestUpdateInternal(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||B}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=q){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||z,n="function"==typeof s?s:s.fromAttribute;return n?n(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||z.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=B){const s=this.constructor,n=s._attributeNameForProperty(t,i);if(void 0!==n){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(n):this.setAttribute(n,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(t);if(void 0!==s){const t=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let s=!0;if(void 0!==t){const n=this.constructor;i=i||n.getPropertyOptions(t),n._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):s=!1}!this._hasRequestedUpdate&&s&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}W.finalized=!0; + */,R=(t,e)=>`${t}--${e}`;let $=!0;void 0===window.ShadyCSS?$=!1:void 0===window.ShadyCSS.prepareTemplateDom&&(console.warn("Incompatible ShadyCSS version detected. Please update to at least @webcomponents/webcomponentsjs@2.0.2 and @webcomponents/shadycss@1.3.1."),$=!1);const j=t=>e=>{const i=R(e.type,t);let n=D.get(i);void 0===n&&(n={stringsArray:new WeakMap,keyString:new Map},D.set(i,n));let r=n.stringsArray.get(e.strings);if(void 0!==r)return r;const a=e.strings.join(s);if(r=n.keyString.get(a),void 0===r){const i=e.getTemplateElement();$&&window.ShadyCSS.prepareTemplateDom(i,t),r=new o(e,i),n.keyString.set(a,r)}return n.stringsArray.set(e.strings,r),r},H=["html","svg"],F=new Set,I=(t,e,i)=>{F.add(t);const s=i?i.element:document.createElement("template"),n=e.querySelectorAll("style"),{length:r}=n;if(0===r)return void window.ShadyCSS.prepareTemplateStyles(s,t);const o=document.createElement("style");for(let t=0;t{H.forEach(e=>{const i=D.get(R(e,t));void 0!==i&&i.keyString.forEach(t=>{const{element:{content:e}}=t,i=new Set;Array.from(e.querySelectorAll("style")).forEach(t=>{i.add(t)}),d(t,i)})})})(t);const a=s.content;i?function(t,e,i=null){const{element:{content:s},parts:n}=t;if(null==i)return void s.appendChild(e);const r=document.createTreeWalker(s,133,null,!1);let o=p(n),a=0,l=-1;for(;r.nextNode();){l++;for(r.currentNode===i&&(a=u(e),i.parentNode.insertBefore(e,i));-1!==o&&n[o].index===l;){if(a>0){for(;-1!==o;)n[o].index+=a,o=p(n,o);return}o=p(n,o)}}}(i,o,a.firstChild):a.insertBefore(o,a.firstChild),window.ShadyCSS.prepareTemplateStyles(s,t);const l=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==l)e.insertBefore(l.cloneNode(!0),e.firstChild);else if(i){a.insertBefore(o,a.firstChild);const t=new Set;t.add(o),d(i,t)}};window.JSCompiler_renameProperty=(t,e)=>t;const z={toAttribute(t,e){switch(e){case Boolean:return t?"":null;case Object:case Array:return null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){switch(e){case Boolean:return null!==t;case Number:return null===t?null:Number(t);case Object:case Array:return JSON.parse(t)}return t}},q=(t,e)=>e!==t&&(e==e||t==t),B={attribute:!0,type:String,converter:z,reflect:!1,hasChanged:q};class W extends HTMLElement{constructor(){super(),this.initialize()}static get observedAttributes(){this.finalize();const t=[];return this._classProperties.forEach((e,i)=>{const s=this._attributeNameForProperty(i,e);void 0!==s&&(this._attributeToPropertyMap.set(s,i),t.push(s))}),t}static _ensureClassProperties(){if(!this.hasOwnProperty(JSCompiler_renameProperty("_classProperties",this))){this._classProperties=new Map;const t=Object.getPrototypeOf(this)._classProperties;void 0!==t&&t.forEach((t,e)=>this._classProperties.set(e,t))}}static createProperty(t,e=B){if(this._ensureClassProperties(),this._classProperties.set(t,e),e.noAccessor||this.prototype.hasOwnProperty(t))return;const i="symbol"==typeof t?Symbol():"__"+t,s=this.getPropertyDescriptor(t,i,e);void 0!==s&&Object.defineProperty(this.prototype,t,s)}static getPropertyDescriptor(t,e,i){return{get(){return this[e]},set(s){const n=this[t];this[e]=s,this.requestUpdateInternal(t,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this._classProperties&&this._classProperties.get(t)||B}static finalize(){const t=Object.getPrototypeOf(this);if(t.hasOwnProperty("finalized")||t.finalize(),this.finalized=!0,this._ensureClassProperties(),this._attributeToPropertyMap=new Map,this.hasOwnProperty(JSCompiler_renameProperty("properties",this))){const t=this.properties,e=[...Object.getOwnPropertyNames(t),..."function"==typeof Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t):[]];for(const i of e)this.createProperty(i,t[i])}}static _attributeNameForProperty(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}static _valueHasChanged(t,e,i=q){return i(t,e)}static _propertyValueFromAttribute(t,e){const i=e.type,s=e.converter||z,n="function"==typeof s?s:s.fromAttribute;return n?n(t,i):t}static _propertyValueToAttribute(t,e){if(void 0===e.reflect)return;const i=e.type,s=e.converter;return(s&&s.toAttribute||z.toAttribute)(t,i)}initialize(){this._updateState=0,this._updatePromise=new Promise(t=>this._enableUpdatingResolver=t),this._changedProperties=new Map,this._saveInstanceProperties(),this.requestUpdateInternal()}_saveInstanceProperties(){this.constructor._classProperties.forEach((t,e)=>{if(this.hasOwnProperty(e)){const t=this[e];delete this[e],this._instanceProperties||(this._instanceProperties=new Map),this._instanceProperties.set(e,t)}})}_applyInstanceProperties(){this._instanceProperties.forEach((t,e)=>this[e]=t),this._instanceProperties=void 0}connectedCallback(){this.enableUpdating()}enableUpdating(){void 0!==this._enableUpdatingResolver&&(this._enableUpdatingResolver(),this._enableUpdatingResolver=void 0)}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this._attributeToProperty(t,i)}_propertyToAttribute(t,e,i=B){const s=this.constructor,n=s._attributeNameForProperty(t,i);if(void 0!==n){const t=s._propertyValueToAttribute(e,i);if(void 0===t)return;this._updateState=8|this._updateState,null==t?this.removeAttribute(n):this.setAttribute(n,t),this._updateState=-9&this._updateState}}_attributeToProperty(t,e){if(8&this._updateState)return;const i=this.constructor,s=i._attributeToPropertyMap.get(t);if(void 0!==s){const t=i.getPropertyOptions(s);this._updateState=16|this._updateState,this[s]=i._propertyValueFromAttribute(e,t),this._updateState=-17&this._updateState}}requestUpdateInternal(t,e,i){let s=!0;if(void 0!==t){const n=this.constructor;i=i||n.getPropertyOptions(t),n._valueHasChanged(this[t],e,i.hasChanged)?(this._changedProperties.has(t)||this._changedProperties.set(t,e),!0!==i.reflect||16&this._updateState||(void 0===this._reflectingProperties&&(this._reflectingProperties=new Map),this._reflectingProperties.set(t,i))):s=!1}!this._hasRequestedUpdate&&s&&(this._updatePromise=this._enqueueUpdate())}requestUpdate(t,e){return this.requestUpdateInternal(t,e),this.updateComplete}async _enqueueUpdate(){this._updateState=4|this._updateState;try{await this._updatePromise}catch(t){}const t=this.performUpdate();return null!=t&&await t,!this._hasRequestedUpdate}get _hasRequestedUpdate(){return 4&this._updateState}get hasUpdated(){return 1&this._updateState}performUpdate(){if(!this._hasRequestedUpdate)return;this._instanceProperties&&this._applyInstanceProperties();let t=!1;const e=this._changedProperties;try{t=this.shouldUpdate(e),t?this.update(e):this._markUpdated()}catch(e){throw t=!1,this._markUpdated(),e}t&&(1&this._updateState||(this._updateState=1|this._updateState,this.firstUpdated(e)),this.updated(e))}_markUpdated(){this._changedProperties=new Map,this._updateState=-5&this._updateState}get updateComplete(){return this._getUpdateComplete()}_getUpdateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._updatePromise}shouldUpdate(t){return!0}update(t){void 0!==this._reflectingProperties&&this._reflectingProperties.size>0&&(this._reflectingProperties.forEach((t,e)=>this._propertyToAttribute(e,this[e],t)),this._reflectingProperties=void 0),this._markUpdated()}updated(t){}firstUpdated(t){}}W.finalized=!0; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -183,7 +183,7 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const tt={};class et extends W{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),s=[];i.forEach(t=>s.unshift(t)),this._styles=s}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!Z){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new K(String(e),G)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Z?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==tt&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return tt}}et.finalized=!0,et.render=(t,e,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,o=Y.has(e),r=$&&11===e.nodeType&&!!e.host,a=r&&!F.has(n),h=a?document.createDocumentFragment():e;if(((t,e,s)=>{let n=Y.get(e);void 0===n&&(i(e,e.firstChild),Y.set(e,n=new P(Object.assign({templateFactory:A},s))),n.appendInto(e)),n.setValue(t),n.commit()})(t,h,Object.assign({templateFactory:j(n)},s)),a){const t=Y.get(h);Y.delete(h);const s=t.value instanceof y?t.value.template:void 0;I(n,h,s),i(e,e.firstChild),e.appendChild(h),Y.set(e,t)}!o&&r&&window.ShadyCSS.styleElement(e.host)},et.shadowRootOptions={mode:"open"}; +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const tt={};class et extends W{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,i)=>t.reduceRight((t,i)=>Array.isArray(i)?e(i,t):(t.add(i),t),i),i=e(t,new Set),s=[];i.forEach(t=>s.unshift(t)),this._styles=s}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!Z){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new K(String(e),G)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?Z?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==tt&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return tt}}et.finalized=!0,et.render=(t,e,s)=>{if(!s||"object"!=typeof s||!s.scopeName)throw new Error("The `scopeName` option is required.");const n=s.scopeName,r=Y.has(e),o=$&&11===e.nodeType&&!!e.host,a=o&&!F.has(n),l=a?document.createDocumentFragment():e;if(((t,e,s)=>{let n=Y.get(e);void 0===n&&(i(e,e.firstChild),Y.set(e,n=new P(Object.assign({templateFactory:A},s))),n.appendInto(e)),n.setValue(t),n.commit()})(t,l,Object.assign({templateFactory:j(n)},s)),a){const t=Y.get(l);Y.delete(l);const s=t.value instanceof y?t.value.template:void 0;I(n,l,s),i(e,e.firstChild),e.appendChild(l),Y.set(e,t)}!r&&o&&window.ShadyCSS.styleElement(e.host)},et.shadowRootOptions={mode:"open"}; /** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. @@ -197,9 +197,9 @@ found at http://polymer.github.io/PATENTS.txt * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const it=new WeakMap,st=(nt=t=>e=>{if(!(e instanceof M)||e instanceof E||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:s}=i.element;let n=it.get(e);void 0===n&&(s.cssText=i.strings.join(" "),it.set(e,n=new Set)),n.forEach(e=>{e in t||(n.delete(e),-1===e.indexOf("-")?s[e]=null:s.removeProperty(e))});for(const e in t)n.add(e),-1===e.indexOf("-")?s[e]=t[e]:s.setProperty(e,t[e])},(...t)=>{const e=nt(...t);return m.set(e,!0),e});var nt,ot=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,rt="[^\\s]+",at=/\[([^]*?)\]/gm;function ht(t,e){for(var i=[],s=0,n=t.length;s-1?s:null}};function ct(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},gt=ct({},mt),ft=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+ft(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+ft(Math.floor(Math.abs(e)/60),2)+":"+ft(Math.abs(e)%60,2)}},yt=function(t){return+t-1},vt=[null,"[1-9]\\d?"],St=[null,rt],bt=["isPm",rt,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],wt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],xt=(lt("monthNamesShort"),lt("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Tt,Mt,Pt=function(t,e,i){if(void 0===e&&(e=xt.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];e=(e=xt[e]||e).replace(at,(function(t,e){return s.push(e),"@@@"}));var n=ct(ct({},gt),i);return(e=e.replace(ot,(function(e){return _t[e](t,n)}))).replace(/@@@/g,(function(){return s.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();(Mt=Tt||(Tt={})).language="language",Mt.system="system",Mt.comma_decimal="comma_decimal",Mt.decimal_comma="decimal_comma",Mt.space_comma="space_comma",Mt.none="none";var Nt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Ct={common:Nt},Et={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Vt={common:Et};const kt={en:Object.freeze({__proto__:null,common:Nt,default:Ct}),nb:Object.freeze({__proto__:null,common:Et,default:Vt})};const Ot=(t,e={})=>{const i=At[t];return i?i(e):void console.log(t+": Not found in styles")},At={card:t=>Object.assign({height:"30px"},t),container:t=>Object.assign({width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},t),track:t=>Object.assign({width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},t),progress:t=>Object.assign({height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},t),thumb:t=>Object.assign({height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"},t)},Dt=function(t,e,i){var s,n;for(var o in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(o)&&(s=o,n=t[o],e.push(s),"object"==typeof n&&null!==n?i=Dt(n,e,i):i[e[e.length-1]]=n,e.pop());return i},Yt=(t,e=100,i=0)=>t/(e-i)*100,Lt=t=>Math.round(100*(t+Number.EPSILON))/100;console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${function(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let n;try{n=t.split(".").reduce((t,e)=>t[e],kt[s])}catch(e){n=t.split(".").reduce((t,e)=>t[e],kt.en)}return void 0===n&&(n=t.split(".").reduce((t,e)=>t[e],kt.en)),""!==e&&""!==i&&(n=n.replace(e,i)),n}("common.version")} 3.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let Ut=class extends et{constructor(){super(...arguments),this.colorMode="brightness",this.coverMode="position",this.sliderId="",this.touchInput=!1,this.disableScroll=!0,this.allowTapping=!0,this.allowSliding=!1,this.slideDistance=10,this.marginOfError=10,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.vertical=!1,this.flipped=!1,this.inverse=!1,this.showMin=!1,this.zero=0,this.savedMin=1,this.min=0,this.max=100,this.minThreshold=0,this.maxThreshold=100,this.step=1,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0}setSliderValues(t,e){this.inverse?(this.sliderVal=this.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&function(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var s=e.get("hass");return!s||s.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}render(){var t,e,i,s,n,o,r,a,h,l;const c=this.initializeConfig();if(null!==c)return c;const d=Dt(null===(t=this._config.styles)||void 0===t?void 0:t.card)?Dt(null===(e=this._config.styles)||void 0===e?void 0:e.card):{},u=Dt(null===(i=this._config.styles)||void 0===i?void 0:i.container)?Dt(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=Dt(null===(n=this._config.styles)||void 0===n?void 0:n.track)?Dt(null===(o=this._config.styles)||void 0===o?void 0:o.track):{},m=Dt(null===(r=this._config.styles)||void 0===r?void 0:r.progress)?Dt(null===(a=this._config.styles)||void 0===a?void 0:a.progress):{},g=Dt(null===(h=this._config.styles)||void 0===h?void 0:h.thumb)?Dt(null===(l=this._config.styles)||void 0===l?void 0:l.thumb):{},f=Ot("card",d),_=Ot("container",u),y=Ot("track",p),v=Ot("progress",m),S=Ot("thumb",g);this.vertical?(v.height=this.sliderValPercent.toString()+"%",f.height=d.height?d.height:"100%",f.width=d.width?d.width:"30px",v.width=m.width?m.width:"100%",v.right=m.right?m.right:"auto",S.right=g.right?g:"auto",S.width=g.width?g.width:"100%",S.height=g.height?g.height:"10px",this.flipped?(v.top=m.top?m.top:"0",S.bottom=g.bottom?g.bottom:"-5px"):(v.bottom=m.bottom?m.bottom:"0",S.top=g.top?g.top:"-5px")):(v.width=this.sliderValPercent.toString()+"%",this.flipped&&(v.right=m.right?m.right:"0",S.right=g.right?g.right:"auto",S.left=g.left?g.left:"-5px"));const b=t=>{const e=t.composedPath().find(t=>t.classList.contains("my-slider-custom-container"));this.sliderEl=e||t.target},w=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;x(t);break;case"touchstart":this.touchInput=!0,x(t);break;case"mousemove":if(this.touchInput)return;M(t);break;case"touchmove":this.disableScroll&&t.preventDefault(),M(t);break;case"mouseup":case"touchend":case"touchcancel":T(t)}},x=t=>{var e;if(this.actionTaken)return;b(t);const i=t.clientX||t.touches[0].clientX,s=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=s),this.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const n=t.composedPath()[0],o=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(n.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(o){const e=o.getBoundingClientRect();if(i>=e.left-this.marginOfError&&i<=e.right+this.marginOfError&&s>=e.top-this.marginOfError&&s<=e.bottom+this.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this.allowSliding&&(this.actionTaken=!0),this.clientYLast=s,this.clientXLast=i},T=t=>{this.actionTaken&&((this.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.actionTaken=!1,this.touchInput=!1,this.isSliding=!1)},M=t=>{if(this.actionTaken){const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this.allowTapping||this.isSliding||!this.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this.allowSliding&&(this.vertical?Math.abs(i-this.clientYLast)>=this.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(w),U` - -
e=>{if(!(e instanceof T)||e instanceof N||"style"!==e.committer.name||e.committer.parts.length>1)throw new Error("The `styleMap` directive must be used in the style attribute and must be the only part in the attribute.");const{committer:i}=e,{style:s}=i.element;let n=it.get(e);void 0===n&&(s.cssText=i.strings.join(" "),it.set(e,n=new Set)),n.forEach(e=>{e in t||(n.delete(e),-1===e.indexOf("-")?s[e]=null:s.removeProperty(e))});for(const e in t)n.add(e),-1===e.indexOf("-")?s[e]=t[e]:s.setProperty(e,t[e])},(...t)=>{const e=nt(...t);return m.set(e,!0),e});var nt,rt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,ot="[^\\s]+",at=/\[([^]*?)\]/gm;function lt(t,e){for(var i=[],s=0,n=t.length;s-1?s:null}};function ct(t){for(var e=[],i=1;i3?0:(t-t%10!=10?1:0)*t%10]}},gt=ct({},mt),ft=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+ft(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+ft(Math.floor(Math.abs(e)/60),2)+":"+ft(Math.abs(e)%60,2)}},yt=function(t){return+t-1},vt=[null,"[1-9]\\d?"],bt=[null,ot],St=["isPm",ot,function(t,e){var i=t.toLowerCase();return i===e.amPm[0]?0:i===e.amPm[1]?1:null}],wt=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var i=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?i:-i}return 0}],xt=(ht("monthNamesShort"),ht("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var Mt,Tt,Pt=function(t,e,i){if(void 0===e&&(e=xt.default),void 0===i&&(i={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var s=[];e=(e=xt[e]||e).replace(at,(function(t,e){return s.push(e),"@@@"}));var n=ct(ct({},gt),i);return(e=e.replace(rt,(function(e){return _t[e](t,n)}))).replace(/@@@/g,(function(){return s.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();(Tt=Mt||(Mt={})).language="language",Tt.system="system",Tt.comma_decimal="comma_decimal",Tt.decimal_comma="decimal_comma",Tt.space_comma="space_comma",Tt.none="none";var kt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Et={common:kt},Nt={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Ct={common:Nt};const Vt={en:Object.freeze({__proto__:null,common:kt,default:Et}),nb:Object.freeze({__proto__:null,common:Nt,default:Ct})};const Ot=(t,e={})=>{const i=At[t];return i?Object.assign(Object.assign({},i),e):void console.log(t+": Not found in styles")},At={card:{height:"30px"},container:{width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},track:{width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},progress:{height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},thumb:{height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"}},Dt=function(t,e,i){var s,n;for(var r in e=void 0===e?[]:e,i=void 0===i?{}:i,t)t.hasOwnProperty(r)&&(s=r,n=t[r],e.push(s),"object"==typeof n&&null!==n?i=Dt(n,e,i):i[e[e.length-1]]=n,e.pop());return i},Yt=(t,e=100,i=0)=>t/(e-i)*100,Lt=t=>Math.round(100*(t+Number.EPSILON))/100;function Ut(t){return t&&"object"==typeof t&&!Array.isArray(t)}const Rt=(t,e,i)=>{if(["number","boolean"].includes(typeof i))return i;if(!i)return i;if("object"==typeof i)return Object.keys(i).forEach(s=>{i[s]=Rt(t,e,i[s])}),i;const s=i.trim();if("[[["===s.substring(0,3)&&"]]]"===s.slice(-3)){return $t(t,e,s.slice(3,-3))}return i},$t=(t,e,i)=>{try{return new Function("states","entity","user","hass","html","'use strict'; "+i).call(t,t.hass.states,e,t.hass.user,t.hass,U)}catch(t){if(t instanceof Error){const e=i.length<=100?i.trim():i.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${e}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}};console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${function(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let n;try{n=t.split(".").reduce((t,e)=>t[e],Vt[s])}catch(e){n=t.split(".").reduce((t,e)=>t[e],Vt.en)}return void 0===n&&(n=t.split(".").reduce((t,e)=>t[e],Vt.en)),""!==e&&""!==i&&(n=n.replace(e,i)),n}("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider-v2",name:"Slider Card V2",description:"Custom Slider Card V2 for Lovelace."});let jt=class extends et{constructor(){super(...arguments),this.touchInput=!1,this.thumbTapped=!1,this.isSliding=!1,this.clientXLast=0,this.clientYLast=0,this.actionTaken=!1,this.zero=0,this.oldVal=0,this.sliderVal=0,this.sliderValPercent=0,this.initialTransition=""}setSliderValues(t,e){this._config.inverse?(this.sliderVal=this._config.max-t,this.sliderValPercent=100-e):(this.sliderVal=t,this.sliderValPercent=e)}static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["light","input_number","number","media_player","cover","fan","switch","input_boolean","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySliderV2"},t)}shouldUpdate(t){return!!this.config&&(void 0!==this._config&&"seekbar"===this._config.mode&&this.entity.state,function(t,e,i){if(e.has("config")||i)return!0;if(t.config.entity){var s=e.get("hass");return!s||s.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1))}updated(t){super.updated(t),requestAnimationFrame(()=>{if(void 0===this.sliderEl&&null!==this.shadowRoot){this.sliderEl=this.shadowRoot.querySelector(".my-slider-custom-container");const t=this.sliderEl.querySelector(".my-slider-custom-progress");this.initialTransition=t.style.transition}})}render(){var t,e,i,s,n,r,o,a,l;const h=this.initializeConfig();if(null!==h)return h;const c=[{transition:this._config.vertical?"height 0.2s ease 0s":"width 0.2s ease 0s"}],d=(null===(t=this._config.styles)||void 0===t?void 0:t.progress)?Object.assign(Object.assign({},c),this._config.styles.progress):c,u=Dt(null===(e=this._config.styles)||void 0===e?void 0:e.card)?Dt(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},p=Dt(null===(s=this._config.styles)||void 0===s?void 0:s.container)?Dt(null===(n=this._config.styles)||void 0===n?void 0:n.container):{},m=Dt(null===(r=this._config.styles)||void 0===r?void 0:r.track)?Dt(null===(o=this._config.styles)||void 0===o?void 0:o.track):{},g=Dt(d),f=Dt(null===(a=this._config.styles)||void 0===a?void 0:a.thumb)?Dt(null===(l=this._config.styles)||void 0===l?void 0:l.thumb):{},_=Ot("card",u),y=Ot("container",p),v=Ot("track",m),b=Ot("progress",g),S=Ot("thumb",f);this._config.vertical?(b.height=this.sliderValPercent.toString()+"%",_.height=u.height?u.height:"100%",_.width=u.width?u.width:"30px",b.width=g.width?g.width:"100%",b.right=g.right?g.right:"auto",S.right=f.right?f:"auto",S.width=f.width?f.width:"100%",S.height=f.height?f.height:"10px",this._config.flipped?(b.top=g.top?g.top:"0",S.bottom=f.bottom?f.bottom:"-5px"):(b.bottom=g.bottom?g.bottom:"0",S.top=f.top?f.top:"-5px")):(b.width=this.sliderValPercent.toString()+"%",this._config.flipped&&(b.right=g.right?g.right:"0",S.right=f.right?f.right:"auto",S.left=f.left?f.left:"-5px"));const w=t=>{switch(t.type){case"mousedown":if(this.touchInput)return;x(t);break;case"touchstart":this.touchInput=!0,x(t);break;case"mousemove":if(this.touchInput)return;T(t);break;case"touchmove":this._config.disableScroll&&t.preventDefault(),T(t);break;case"mouseup":case"touchend":case"touchcancel":M(t)}},x=t=>{var e;if(this.actionTaken)return;const i=t.clientX||t.touches[0].clientX,s=t.clientY||t.touches[0].clientY;if(0===this.clientXLast&&(this.clientXLast=i),0===this.clientYLast&&(this.clientYLast=s),this._config.allowTapping)return this.actionTaken=!0,void this.calcProgress(t);{const n=t.composedPath()[0],r=null===(e=this.shadowRoot)||void 0===e?void 0:e.querySelector(".my-slider-custom-thumb");if(n.classList.contains("my-slider-custom-thumb"))return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t);if(r){const e=r.getBoundingClientRect();if(i>=e.left-this._config.marginOfError&&i<=e.right+this._config.marginOfError&&s>=e.top-this._config.marginOfError&&s<=e.bottom+this._config.marginOfError)return this.thumbTapped=!0,this.actionTaken=!0,void this.calcProgress(t)}}this._config.allowSliding&&(this.actionTaken=!0),this.clientYLast=s,this.clientXLast=i},M=t=>{if(!this.actionTaken)return;this.sliderEl.querySelector(".my-slider-custom-progress").style.transition=this.initialTransition,(this._config.allowTapping||this.thumbTapped||this.isSliding)&&this.calcProgress(t),this.thumbTapped=!1,this.touchInput=!1,this.isSliding=!1,setTimeout(()=>{this.actionTaken=!1},50)},T=t=>{if(this.actionTaken){this.sliderEl.querySelector(".my-slider-custom-progress").style.transition="";const e=t.clientX||t.touches[0].clientX,i=t.clientY||t.touches[0].clientY;this._config.allowTapping||this.isSliding||!this._config.allowTapping&&this.thumbTapped?(this.calcProgress(t),this.clientXLast=e,this.clientYLast=i):this._config.allowSliding&&(this._config.vertical?Math.abs(i-this.clientYLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i):Math.abs(e-this.clientXLast)>=this._config.slideDistance&&(this.isSliding=!0,this.clientXLast=e,this.clientYLast=i))}};return this.createAndCleanupEventListeners(w),U` + +
e=>{if(!(e instanceof M)||e instanceof E||"style" @touchcancel="${w}" @touchmove="${w}" > -
-
+
+
- `}initializeConfig(){this.entity=this.hass.states[""+this.config.entity];try{this._config=this._objectEvalTemplate(this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}this.sliderId="slider-"+this._config.entity.replace(".","-"),this.colorMode=void 0!==this._config.colorMode?this._config.colorMode:"brightness",this.coverMode=void 0!==this._config.coverMode?this._config.coverMode:"position",this.vertical=void 0!==this._config.vertical&&this._config.vertical,this.flipped=void 0!==this._config.flipped&&this._config.flipped,this.inverse=void 0!==this._config.inverse&&this._config.inverse,this.disableScroll=void 0===this._config.disableScroll||this._config.disableScroll,this.allowTapping=void 0===this._config.allowTapping||this._config.allowTapping,this.allowSliding=void 0!==this._config.allowSliding&&this._config.allowSliding,this.marginOfError=void 0!==this._config.marginOfError?this._config.marginOfError:10,this.slideDistance=void 0!==this._config.slideDistance?this._config.slideDistance:10,this.showMin=void 0!==this._config.showMin&&this._config.showMin,this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:100,this.minThreshold=this._config.minThreshold?this._config.minThreshold:0,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:100,this.step=this._config.step?this._config.step:1;let t=0;switch(this._config.entity.split(".")[0]){case"light":if("brightness"===this.colorMode)this.oldVal=Math.ceil(Yt(this.entity.attributes.brightness,256)),"on"===this.entity.state?(t=Math.round(this.entity.attributes.brightness/2.56),this.showMin||(t-=this.min)):t=0;else if("temperature"===this.colorMode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:this.entity.attributes.min_mireds,this.max=this._config.max?this._config.max:this.entity.attributes.max_mireds,t=parseFloat(this.entity.attributes.color_temp),this.oldVal=parseFloat(this.entity.attributes.color_temp),this.showMin||(this.max=this.max-this.min,t-=this.min)}else if("hue"===this.colorMode&&"hs"===this.entity.attributes.color_mode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:360,this.oldVal=parseFloat(this.entity.attributes.hs_color[0]),t=parseFloat(this.entity.attributes.hs_color[0]),this.showMin||(this.max=this.max-this.min,t-=this.min)}else if("saturation"===this.colorMode&&"hs"===this.entity.attributes.color_mode){if("on"!==this.entity.state)break;this.min=this._config.min?this._config.min:0,this.max=this._config.max?this._config.max:100,this.oldVal=parseFloat(this.entity.attributes.hs_color[1]),t=parseFloat(this.entity.attributes.hs_color[1]),this.showMin||(this.max=this.max-this.min,t-=this.min)}this.setSliderValues(t,Lt(Yt(t,this.max)));break;case"input_number":case"number":this.step=this._config.step?this._config.step:this.entity.attributes.step,this.min=this._config.min?this._config.min:this.entity.attributes.min,this.max=this._config.max?this._config.max:this.entity.attributes.max,this.oldVal=parseFloat(this.entity.state),t=parseFloat(this.entity.state),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,Lt(Yt(t,this.max)));break;case"media_player":t=0,null!=this.entity.attributes.volume_level&&(t=Number(100*this.entity.attributes.volume_level)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,Lt(Yt(t,this.max)));break;case"cover":t=0,"position"===this.coverMode?null!=this.entity.attributes.current_position&&(t=Number(this.entity.attributes.current_position)):"tilt"===this.coverMode&&null!=this.entity.attributes.current_tilt_position&&(t=Number(this.entity.attributes.current_tilt_position)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.inverse=void 0===this._config.inverse||this._config.inverse,this.vertical=void 0===this._config.vertical||this._config.vertical,this.flipped=void 0===this._config.flipped||this._config.flipped,this.setSliderValues(t,Lt(Yt(t,this.max)));break;case"fan":t=0,null!=this.entity.attributes.percentage&&(t=Number(this.entity.attributes.percentage)),this.oldVal=t,this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,Lt(Yt(t,this.max)));break;case"switch":this.minThreshold=this._config.minThreshold?this._config.minThreshold:15,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:75,t=Number(Math.max(this.zero,this.minThreshold)),this.setSliderValues(t,t);break;case"lock":this.minThreshold=this._config.minThreshold?this._config.minThreshold:15,this.maxThreshold=this._config.maxThreshold?this._config.maxThreshold:75,t=Number(Math.max(this.zero,this.minThreshold)),this.oldVal=t,this.setSliderValues(t,t);break;default:console.log("No Entity type initiated... ("+this._config.entity.split(".")[0]+")")}return null}calcProgress(t){if(null==this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,s=e.touches[0]||e.changedTouches[0];i.x=s.clientX,i.y=s.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let s=e.getBoundingClientRect(),n=i.x-s.left,o=i.y-s.top;return o=e.offsetHeight-o,{x:n,y:o}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,s=this.sliderEl.offsetHeight,n=(this.vertical?Lt(e.y/s*100):Lt(e.x/i*100))/100*(this.max-0),o=this.max-n;let r=this.flipped?Math.round(o):Math.round(n);r=rthis.max?this.max:r{o.style.transition=r},200)}_setLock(t,e){var i=Math.min(this.max,this.maxThreshold);if(Number(i)<=e){var s="locked"===t.state?"unlock":"lock";this.hass.callService("lock",s,{entity_id:t.entity_id})}const n=Number(Math.max(this.zero,this.minThreshold)),o=Lt(Yt(n,this.max));this.setSliderValues(n,o);const r=this.sliderEl.querySelector(".my-slider-custom-progress");r.style.transition="width 0.2s ease 0s",r.style.width=o.toString()+"%",setTimeout(()=>{r.style.transition="initial"},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}_objectEvalTemplate(t,e){const i=JSON.parse(JSON.stringify(e));return this._getTemplateOrValue(t,i)}_getTemplateOrValue(t,e){if(["number","boolean"].includes(typeof e))return e;if(!e)return e;if("object"==typeof e)return Object.keys(e).forEach(i=>{e[i]=this._getTemplateOrValue(t,e[i])}),e;const i=e.trim();if("[[["===i.substring(0,3)&&"]]]"===i.slice(-3)){return this._evalTemplate(t,i.slice(3,-3))}return e}_evalTemplate(t,e){try{return new Function("states","entity","user","hass","html","'use strict'; "+e).call(this,this.hass.states,t,this.hass.user,this.hass,U)}catch(t){if(t instanceof Error){const i=e.length<=100?e.trim():e.trim().substring(0,98)+"...";throw t.message=`${t.name}: ${t.message} in '${i}'`,t.name="MyCardJSTemplateError",t}console.log("Unexpected error (_evalTemplate)",t)}}static get styles(){return Q` - `}};var Rt,$t;t([J()],Ut.prototype,"_config",void 0),t([J({attribute:!1})],Ut.prototype,"hass",void 0),t([function(t){return J({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(Rt)],Ut.prototype,"config",void 0),Ut=t([($t="my-slider-v2",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))($t,t):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})($t,t))],Ut);export{Ut as MySliderV2}; + `}initializeConfig(){var t;if(this.actionTaken)return null;this.entity=this.hass.states[""+this.config.entity];try{this._config=((t,e,i)=>{const s=JSON.parse(JSON.stringify(i));return Rt(t,e,s)})(this,this.entity,this.config)}catch(t){if(t instanceof Error){t.stack?console.error(t.stack):console.error(t);const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t.toString(),origConfig:this.config}),e}console.log("Unexpected error evaluating config on init:",t)}if(!this._config)return U`Error with evaluated _config`;const e=this._config.entity?null===(t=this._config.entity)||void 0===t?void 0:t.split(".")[0]:this._config.entity?this._config.entity.split(".")[0]:"none",i={sliderId:`slider-${this._config.entity.replace(".","-")}-${this._config.mode}`,type:this._config.type,disableScroll:void 0===this._config.disableScroll||this._config.disableScroll,allowTapping:void 0===this._config.allowTapping||this._config.allowTapping,allowSliding:void 0!==this._config.allowSliding&&this._config.allowSliding,marginOfError:void 0!==this._config.marginOfError?this._config.marginOfError:10,slideDistance:void 0!==this._config.slideDistance?this._config.slideDistance:10,showMin:void 0!==this._config.showMin&&this._config.showMin,minThreshold:0,maxThreshold:100,sliderMin:this._config.sliderMin?this._config.sliderMin:0,vertical:void 0!==this._config.vertical&&this._config.vertical,flipped:void 0!==this._config.flipped&&this._config.flipped,inverse:void 0!==this._config.inverse&&this._config.inverse,intermediate:void 0!==this._config.intermediate&&this._config.intermediate,min:this._config.min?this._config.min:0,max:this._config.max?this._config.max:100,step:this._config.step?this._config.step:1,mode:void 0!==this._config.mode?this._config.mode:void 0!==this._config.colorMode?this._config.colorMode:void 0!==this._config.coverMode?this._config.coverMode:"light"===e?"brightness":"cover"===e?"position":"media_player"===e?"volume":"brightness"};let s=0,n=0,r=0;switch(e){case"light":if("brightness"===i.mode)this.oldVal=Math.ceil(Yt(this.entity.attributes.brightness,256)),"on"===this.entity.state&&(s=Math.ceil(Yt(this.entity.attributes.brightness,256)),!i.showMin&&i.min&&(s-=i.min)),s=s*(100-i.sliderMin)/100+i.sliderMin,s=s{Array.isArray(i[n])?s[n]=i[n].map((i,s)=>e[n]&&Ut(e[n][s])&&Ut(i)?t(e[n][s],i):i):Ut(i[n])?n in e?s[n]=t(e[n],i[n]):Object.assign(s,{[n]:i[n]}):Object.assign(s,{[n]:i[n]})}),s}return{}}(i,this._config),this.setSliderValues(n,r),"seekbar"===i.mode&&"playing"===this.entity.state&&this.updateSeekbar(),null}async updateSeekbar(){if(void 0===this.sliderEl)return void setTimeout(()=>this.updateSeekbar(),500);if("playing"!==this.entity.state)return;let t=0;this._config.max=this.entity.attributes.media_duration;const e=new Date,i=new Date(this.entity.attributes.media_position_updated_at);let s=this.entity.attributes.media_position+(e.getTime()-i.getTime())/1e3;s=Math.min(s,this._config.max),t=s,this.setSliderValues(t,Lt(Yt(t,this._config.max))),this.setProgress(this.sliderEl,Math.round(t),"updateSeekbar"),setTimeout(()=>this.updateSeekbar(),1e3)}calcProgress(t){if(void 0===this.sliderEl||null===this.sliderEl)return;const e=((t,e)=>{let i={x:0,y:0};if("touchstart"==t.type||"touchmove"==t.type||"touchend"==t.type||"touchcancel"==t.type){let e=void 0===t.originalEvent?t:t.originalEvent,s=e.touches[0]||e.changedTouches[0];i.x=s.clientX,i.y=s.clientY}else"mousedown"!=t.type&&"mouseup"!=t.type&&"mousemove"!=t.type&&"mouseover"!=t.type&&"mouseout"!=t.type&&"mouseenter"!=t.type&&"mouseleave"!=t.type||(i.x=t.clientX,i.y=t.clientY);let s=e.getBoundingClientRect(),n=i.x-s.left,r=i.y-s.top;return r=e.offsetHeight-r,{x:n,y:r}})(t,this.sliderEl),i=this.sliderEl.offsetWidth,s=this.sliderEl.offsetHeight,n=(this._config.vertical?Lt(e.y/s*100):Lt(e.x/i*100))/100*(this._config.max-0),r=this._config.max-n;let o=this._config.flipped?r:n;o=othis._config.max?this._config.max:o{r.style.transition=this.initialTransition},200)}_setLock(t,e){var i=Math.min(this._config.max,this._config.maxThreshold);if(Number(i)<=e){var s="locked"===t.state?"unlock":"lock";this.hass.callService("lock",s,{entity_id:t.entity_id})}const n=Number(Math.max(this.zero,this._config.minThreshold)),r=Lt(Yt(n,this._config.max)),o=this.sliderEl.querySelector(".my-slider-custom-progress");this._config.vertical?o.style.transition="height 0.2s ease 0s":o.style.transition="width 0.2s ease 0s",this.setSliderValues(n,r),this.setProgress(this.sliderEl,n,"setLock"),setTimeout(()=>{o.style.transition=this.initialTransition},200)}createAndCleanupEventListeners(t){document.removeEventListener("mouseup",t),document.removeEventListener("touchend",t),document.removeEventListener("touchcancel",t),document.addEventListener("mouseup",t),document.addEventListener("touchend",t),document.addEventListener("touchcancel",t),document.addEventListener("mousemove",t)}static get styles(){return Q` + `}};var Ht,Ft;t([J()],jt.prototype,"_config",void 0),t([J({attribute:!1})],jt.prototype,"hass",void 0),t([function(t){return J({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(Ht)],jt.prototype,"config",void 0),jt=t([(Ft="my-slider-v2",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(Ft,t):((t,e)=>{const{kind:i,elements:s}=e;return{kind:i,elements:s,finisher(e){window.customElements.define(t,e)}}})(Ft,t))],jt);export{jt as MySliderV2}; diff --git a/dist/my-slider.js b/dist/my-slider.js index e1f9dd2..4c4278f 100644 --- a/dist/my-slider.js +++ b/dist/my-slider.js @@ -184,7 +184,7 @@ const G=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShad * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const tt={};class et extends q{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,n)=>t.reduceRight((t,n)=>Array.isArray(n)?e(n,t):(t.add(n),t),n),n=e(t,new Set),r=[];n.forEach(t=>r.unshift(t)),this._styles=r}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!G){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new K(String(e),X)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?G?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==tt&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return tt}}et.finalized=!0,et.render=(t,e,r)=>{if(!r||"object"!=typeof r||!r.scopeName)throw new Error("The `scopeName` option is required.");const i=r.scopeName,o=D.has(e),s=U&&11===e.nodeType&&!!e.host,a=s&&!L.has(i),l=a?document.createDocumentFragment():e;if(((t,e,r)=>{let i=D.get(e);void 0===i&&(n(e,e.firstChild),D.set(e,i=new C(Object.assign({templateFactory:O},r))),i.appendInto(e)),i.setValue(t),i.commit()})(t,l,Object.assign({templateFactory:B(i)},r)),a){const t=D.get(l);D.delete(l);const r=t.value instanceof y?t.value.template:void 0;z(i,l,r),n(e,e.firstChild),e.appendChild(l),D.set(e,t)}!o&&s&&window.ShadyCSS.styleElement(e.host)},et.shadowRootOptions={mode:"open"};var nt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,rt="[^\\s]+",it=/\[([^]*?)\]/gm;function ot(t,e){for(var n=[],r=0,i=t.length;r-1?r:null}};function at(t){for(var e=[],n=1;n3?0:(t-t%10!=10?1:0)*t%10]}},ht=at({},ut),pt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+pt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+pt(Math.floor(Math.abs(e)/60),2)+":"+pt(Math.abs(e)%60,2)}},gt=function(t){return+t-1},ft=[null,"[1-9]\\d?"],vt=[null,rt],yt=["isPm",rt,function(t,e){var n=t.toLowerCase();return n===e.amPm[0]?0:n===e.amPm[1]?1:null}],_t=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var n=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?n:-n}return 0}],bt=(st("monthNamesShort"),st("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var St,wt,xt=function(t,e,n){if(void 0===e&&(e=bt.default),void 0===n&&(n={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var r=[];e=(e=bt[e]||e).replace(it,(function(t,e){return r.push(e),"@@@"}));var i=at(at({},ht),n);return(e=e.replace(nt,(function(e){return mt[e](t,i)}))).replace(/@@@/g,(function(){return r.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();(wt=St||(St={})).language="language",wt.system="system",wt.comma_decimal="comma_decimal",wt.decimal_comma="decimal_comma",wt.space_comma="space_comma",wt.none="none";var $t=!1;if("undefined"!=typeof window){var Pt={get passive(){$t=!0}};window.addEventListener("testPassive",null,Pt),window.removeEventListener("testPassive",null,Pt)}var Ct="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Nt=[],Mt=!1,Tt=-1,Et=void 0,kt=void 0,At=void 0,Ot=function(t){return Nt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Vt=function(t){var e=t||window.event;return!!Ot(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Dt=function(t,e){if(t){if(!Nt.some((function(e){return e.targetElement===t}))){var n={targetElement:t,options:e||{}};Nt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e=r&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===At){var e=!!t&&!0===t.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;if(e&&n>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);At=document.body.style.paddingRight,document.body.style.paddingRight=r+n+"px"}}void 0===Et&&(Et=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Ct&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(Tt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var n=t.targetTouches[0].clientY-Tt;!Ot(t.target)&&(e&&0===e.scrollTop&&n>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&n<0?Vt(t):t.stopPropagation())}(e,t)},Mt||(document.addEventListener("touchmove",Vt,$t?{passive:!1}:void 0),Mt=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Rt=function(t){t?(Nt=Nt.filter((function(e){return e.targetElement!==t})),Ct&&(t.ontouchstart=null,t.ontouchmove=null,Mt&&0===Nt.length&&(document.removeEventListener("touchmove",Vt,$t?{passive:!1}:void 0),Mt=!1)),Ct?function(){if(void 0!==kt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=kt.position,document.body.style.top=kt.top,document.body.style.left=kt.left,window.scrollTo(e,t),kt=void 0}}():(void 0!==At&&(document.body.style.paddingRight=At,At=void 0),void 0!==Et&&(document.body.style.overflow=Et,Et=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};var Yt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Ht={common:Yt},Ut={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Bt={common:Ut};const It={en:Object.freeze({__proto__:null,common:Yt,default:Ht}),nb:Object.freeze({__proto__:null,common:Ut,default:Bt})};console.info(`%c ---- MY-SLIDER ---- \n%c ${function(t,e="",n=""){const r=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let i;try{i=t.split(".").reduce((t,e)=>t[e],It[r])}catch(e){i=t.split(".").reduce((t,e)=>t[e],It.en)}return void 0===i&&(i=t.split(".").reduce((t,e)=>t[e],It.en)),""!==e&&""!==n&&(i=i.replace(e,n)),i}("common.version")} 3.0.5 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Lt=class extends et{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&function(t,e,n){if(e.has("config")||n)return!0;if(t.config.entity){var r=e.get("hass");return!r||r.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const n=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",r=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+n]);var i=e.step?e.step:"1",o=e.minBar?e.minBar:0,s=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(n.includes("input_number.")||n.includes("number."))&&(i=e.step?e.step:r.attributes.step,a=e.minSet?e.minSet:r.attributes.min,l=e.maxSet?e.maxSet:r.attributes.max);var d=e.width?e.width:"100%",c=e.height?e.height:"50px",u=e.radius?e.radius:"4px",h=e.top?e.top:"0px",p=e.bottom?e.bottom:"0px",m=e.right?e.right:"0px",g=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",v=e.containerHeight?e.containerHeight:c;"0"!=f&&(f+="deg");var y=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",_=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",S=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",w=e.border?e.border:"0",x=e.thumbWidth?e.thumbWidth:"25px",$=e.thumbHeight?e.thumbHeight:"80px",P=e.thumbColor?e.thumbColor:"#FFFFFF",C=e.thumbColorOff?e.thumbColorOff:"#969696",N=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",M=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",T=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",E=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",k=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",A=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",O=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=!!e.lockTrack&&e.lockTrack,D=`\n\t\t\t--slider-width: ${d};\n\t\t\t--slider-width-inverse: -${d};\n\t\t\t--slider-height: ${c};\n\t\t\t--slider-main-color: ${"off"===r.state||"locked"===r.state||null==r.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${y};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===r.state||"locked"===r.state||null==r.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${_};\n\t\t\t--slider-secondary-color-off: ${S};\n\t\t\t--slider-radius: ${u};\n\t\t\t--border: ${w};\n\n\t\t\t--thumb-width: ${x};\n\t\t\t--thumb-height: ${$};\n\t\t\t--thumb-color: ${"off"===r.state||null==r.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${P};\n\t\t\t--thumb-color-off: ${C};\n\t\t\t--thumb-horizontal-padding: ${N};\n\t\t\t--thumb-vertical-padding: ${M};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${h};\n\t\t\t--bottom: ${p};\n\t\t\t--right: ${m};\n\t\t\t--left: ${g};\n\t\t\t--container-height: ${v};\n\t\t\t--thumb-top: ${T};\n\t\t\t--thumb-border-right: ${E};\n\t\t\t--thumb-border-left: ${k};\n\t\t\t--thumb-border-top: ${A};\n\t\t\t--thumb-border-bottom: ${O};\n\t\t\t\n\t\t\t--lock-track-container: ${V?"none":"auto"};\n\t\t`;const R=t=>{n.includes("light.")?"Warmth"==e.function?this._setWarmth(r,t.target,a,l):this._setBrightness(r,t.target,a,l):n.includes("input_number.")||n.includes("number.")?this._setInputNumber(r,t.target,a,l):n.includes("media_player.")?this._setMediaVolume(r,t.target,a,l):n.includes("cover.")?this._setCover(r,t.target,a,l):n.includes("fan.")?this._setFan(r,t.target,a,l):n.includes("switch.")?this._setSwitch(r,t.target,a,l,o,s):n.includes("lock.")&&this._setLock(r,t.target,a,l,o,s)},H=t=>{e.intermediate&&R(t)},U=t=>{e.intermediate||R(t)},B=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Dt(window):Rt(window)};if(n.includes("light."))return"Warmth"==e.function?Y` +(window.litElementVersions||(window.litElementVersions=[])).push("2.5.1");const tt={};class et extends q{static getStyles(){return this.styles}static _getUniqueStyles(){if(this.hasOwnProperty(JSCompiler_renameProperty("_styles",this)))return;const t=this.getStyles();if(Array.isArray(t)){const e=(t,n)=>t.reduceRight((t,n)=>Array.isArray(n)?e(n,t):(t.add(n),t),n),n=e(t,new Set),r=[];n.forEach(t=>r.unshift(t)),this._styles=r}else this._styles=void 0===t?[]:[t];this._styles=this._styles.map(t=>{if(t instanceof CSSStyleSheet&&!G){const e=Array.prototype.slice.call(t.cssRules).reduce((t,e)=>t+e.cssText,"");return new K(String(e),X)}return t})}initialize(){super.initialize(),this.constructor._getUniqueStyles(),this.renderRoot=this.createRenderRoot(),window.ShadowRoot&&this.renderRoot instanceof window.ShadowRoot&&this.adoptStyles()}createRenderRoot(){return this.attachShadow(this.constructor.shadowRootOptions)}adoptStyles(){const t=this.constructor._styles;0!==t.length&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow?G?this.renderRoot.adoptedStyleSheets=t.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet):this._needsShimAdoptedStyleSheets=!0:window.ShadyCSS.ScopingShim.prepareAdoptedCssText(t.map(t=>t.cssText),this.localName))}connectedCallback(){super.connectedCallback(),this.hasUpdated&&void 0!==window.ShadyCSS&&window.ShadyCSS.styleElement(this)}update(t){const e=this.render();super.update(t),e!==tt&&this.constructor.render(e,this.renderRoot,{scopeName:this.localName,eventContext:this}),this._needsShimAdoptedStyleSheets&&(this._needsShimAdoptedStyleSheets=!1,this.constructor._styles.forEach(t=>{const e=document.createElement("style");e.textContent=t.cssText,this.renderRoot.appendChild(e)}))}render(){return tt}}et.finalized=!0,et.render=(t,e,r)=>{if(!r||"object"!=typeof r||!r.scopeName)throw new Error("The `scopeName` option is required.");const i=r.scopeName,o=D.has(e),s=U&&11===e.nodeType&&!!e.host,a=s&&!L.has(i),l=a?document.createDocumentFragment():e;if(((t,e,r)=>{let i=D.get(e);void 0===i&&(n(e,e.firstChild),D.set(e,i=new C(Object.assign({templateFactory:O},r))),i.appendInto(e)),i.setValue(t),i.commit()})(t,l,Object.assign({templateFactory:B(i)},r)),a){const t=D.get(l);D.delete(l);const r=t.value instanceof y?t.value.template:void 0;z(i,l,r),n(e,e.firstChild),e.appendChild(l),D.set(e,t)}!o&&s&&window.ShadyCSS.styleElement(e.host)},et.shadowRootOptions={mode:"open"};var nt=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,rt="[^\\s]+",it=/\[([^]*?)\]/gm;function ot(t,e){for(var n=[],r=0,i=t.length;r-1?r:null}};function at(t){for(var e=[],n=1;n3?0:(t-t%10!=10?1:0)*t%10]}},ht=at({},ut),pt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+pt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+pt(Math.floor(Math.abs(e)/60),2)+":"+pt(Math.abs(e)%60,2)}},gt=function(t){return+t-1},ft=[null,"[1-9]\\d?"],vt=[null,rt],yt=["isPm",rt,function(t,e){var n=t.toLowerCase();return n===e.amPm[0]?0:n===e.amPm[1]?1:null}],_t=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var n=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?n:-n}return 0}],bt=(st("monthNamesShort"),st("monthNames"),{default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"});var St,wt,xt=function(t,e,n){if(void 0===e&&(e=bt.default),void 0===n&&(n={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var r=[];e=(e=bt[e]||e).replace(it,(function(t,e){return r.push(e),"@@@"}));var i=at(at({},ht),n);return(e=e.replace(nt,(function(e){return mt[e](t,i)}))).replace(/@@@/g,(function(){return r.shift()}))};(function(){try{(new Date).toLocaleDateString("i")}catch(t){return"RangeError"===t.name}})(),function(){try{(new Date).toLocaleString("i")}catch(t){return"RangeError"===t.name}}(),function(){try{(new Date).toLocaleTimeString("i")}catch(t){return"RangeError"===t.name}}();(wt=St||(St={})).language="language",wt.system="system",wt.comma_decimal="comma_decimal",wt.decimal_comma="decimal_comma",wt.space_comma="space_comma",wt.none="none";var $t=!1;if("undefined"!=typeof window){var Pt={get passive(){$t=!0}};window.addEventListener("testPassive",null,Pt),window.removeEventListener("testPassive",null,Pt)}var Ct="undefined"!=typeof window&&window.navigator&&window.navigator.platform&&(/iP(ad|hone|od)/.test(window.navigator.platform)||"MacIntel"===window.navigator.platform&&window.navigator.maxTouchPoints>1),Nt=[],Mt=!1,Tt=-1,Et=void 0,kt=void 0,At=void 0,Ot=function(t){return Nt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Vt=function(t){var e=t||window.event;return!!Ot(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Dt=function(t,e){if(t){if(!Nt.some((function(e){return e.targetElement===t}))){var n={targetElement:t,options:e||{}};Nt=[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e=r&&(document.body.style.top=-(e+t))}))}),300)}})):function(t){if(void 0===At){var e=!!t&&!0===t.reserveScrollBarGap,n=window.innerWidth-document.documentElement.clientWidth;if(e&&n>0){var r=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);At=document.body.style.paddingRight,document.body.style.paddingRight=r+n+"px"}}void 0===Et&&(Et=document.body.style.overflow,document.body.style.overflow="hidden")}(e),Ct&&(t.ontouchstart=function(t){1===t.targetTouches.length&&(Tt=t.targetTouches[0].clientY)},t.ontouchmove=function(e){1===e.targetTouches.length&&function(t,e){var n=t.targetTouches[0].clientY-Tt;!Ot(t.target)&&(e&&0===e.scrollTop&&n>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&n<0?Vt(t):t.stopPropagation())}(e,t)},Mt||(document.addEventListener("touchmove",Vt,$t?{passive:!1}:void 0),Mt=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Rt=function(t){t?(Nt=Nt.filter((function(e){return e.targetElement!==t})),Ct&&(t.ontouchstart=null,t.ontouchmove=null,Mt&&0===Nt.length&&(document.removeEventListener("touchmove",Vt,$t?{passive:!1}:void 0),Mt=!1)),Ct?function(){if(void 0!==kt){var t=-parseInt(document.body.style.top,10),e=-parseInt(document.body.style.left,10);document.body.style.position=kt.position,document.body.style.top=kt.top,document.body.style.left=kt.left,window.scrollTo(e,t),kt=void 0}}():(void 0!==At&&(document.body.style.paddingRight=At,At=void 0),void 0!==Et&&(document.body.style.overflow=Et,Et=void 0))):console.error("enableBodyScroll unsuccessful - targetElement must be provided when calling enableBodyScroll on IOS devices.")};var Yt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Ht={common:Yt},Ut={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Bt={common:Ut};const It={en:Object.freeze({__proto__:null,common:Yt,default:Ht}),nb:Object.freeze({__proto__:null,common:Ut,default:Bt})};console.info(`%c ---- MY-SLIDER ---- \n%c ${function(t,e="",n=""){const r=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let i;try{i=t.split(".").reduce((t,e)=>t[e],It[r])}catch(e){i=t.split(".").reduce((t,e)=>t[e],It.en)}return void 0===i&&(i=t.split(".").reduce((t,e)=>t[e],It.en)),""!==e&&""!==n&&(i=i.replace(e,n)),i}("common.version")} 3.0.6 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green"),window.customCards=window.customCards||[],window.customCards.push({type:"my-slider",name:"Slider Card",description:"Custom Slider Card for Lovelace."});let Lt=class extends et{static getStubConfig(){return{}}static get properties(){return{hass:{},config:{},active:{}}}setConfig(t){const e=["input_number","number","light","media_player","cover","fan","switch","lock"];if(!t.entity)throw new Error("You need to define entity");if(!e.includes(t.entity.split(".")[0]))throw new Error("Entity has to be one of the following: "+e.map(t=>" "+t));this.config=Object.assign({name:"MySlider",disabled_scroll:!1},t)}shouldUpdate(t){return!!this.config&&function(t,e,n){if(e.has("config")||n)return!0;if(t.config.entity){var r=e.get("hass");return!r||r.states[t.config.entity]!==t.hass.states[t.config.entity]}return!1}(this,t,!1)}render(){var t,e=JSON.parse(JSON.stringify(this.config));const n=this.config.entity?this.config.entity:"ERROR: NO ENTITY ID",r=(null===(t=this.config.entity)||void 0===t||t.split(".")[1],this.hass.states[""+n]);var i=e.step?e.step:"1",o=e.minBar?e.minBar:0,s=e.maxBar?e.maxBar:100,a=e.minSet?e.minSet:0,l=e.maxSet?e.maxSet:100;(n.includes("input_number.")||n.includes("number."))&&(i=e.step?e.step:r.attributes.step,a=e.minSet?e.minSet:r.attributes.min,l=e.maxSet?e.maxSet:r.attributes.max);var d=e.width?e.width:"100%",c=e.height?e.height:"50px",u=e.radius?e.radius:"4px",h=e.top?e.top:"0px",p=e.bottom?e.bottom:"0px",m=e.right?e.right:"0px",g=e.left?e.left:"0px",f=e.rotate?e.rotate:"0",v=e.containerHeight?e.containerHeight:c;"0"!=f&&(f+="deg");var y=e.mainSliderColor?e.mainSliderColor:"var(--accent-color)",_=e.secondarySliderColor?e.secondarySliderColor:"#4d4d4d",b=e.mainSliderColorOff?e.mainSliderColorOff:"#636363",S=e.secondarySliderColorOff?e.secondarySliderColorOff:"#4d4d4d",w=e.border?e.border:"0",x=e.thumbWidth?e.thumbWidth:"25px",$=e.thumbHeight?e.thumbHeight:"80px",P=e.thumbColor?e.thumbColor:"#FFFFFF",C=e.thumbColorOff?e.thumbColorOff:"#969696",N=e.thumbHorizontalPadding?e.thumbHorizontalPadding:"10px",M=e.thumbVerticalPadding?e.thumbVerticalPadding:"20px",T=e.thumpTop?e.thumpTop:"calc((var(--slider-width) - var(--thumb-height)) / 2)",E=e.thumbBorderRight?e.thumbBorderRight:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",k=e.thumbBorderLeft?e.thumbBorderLeft:"var(--thumb-horizontal-padding) solid var(--slider-main-color)",A=e.thumbBorderTop?e.thumbBorderTop:"var(--thumb-vertical-padding) solid var(--slider-main-color)",O=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=!!e.lockTrack&&e.lockTrack,D=`\n\t\t\t--slider-width: ${d};\n\t\t\t--slider-width-inverse: -${d};\n\t\t\t--slider-height: ${c};\n\t\t\t--slider-main-color: ${"off"===r.state||"locked"===r.state||null==r.state?"var(--slider-main-color-off)":"var(--slider-main-color-on)"};\n\t\t\t--slider-main-color-on: ${y};\n\t\t\t--slider-main-color-off: ${b};\n\t\t\t--slider-secondary-color: ${"off"===r.state||"locked"===r.state||null==r.state?"var(--slider-secondary-color-off)":"var(--slider-secondary-color-on)"};\n\t\t\t--slider-secondary-color-on: ${_};\n\t\t\t--slider-secondary-color-off: ${S};\n\t\t\t--slider-radius: ${u};\n\t\t\t--border: ${w};\n\n\t\t\t--thumb-width: ${x};\n\t\t\t--thumb-height: ${$};\n\t\t\t--thumb-color: ${"off"===r.state||null==r.state?"var(--thumb-color-off)":"var(--thumb-color-on)"};\n\t\t\t--thumb-color-on: ${P};\n\t\t\t--thumb-color-off: ${C};\n\t\t\t--thumb-horizontal-padding: ${N};\n\t\t\t--thumb-vertical-padding: ${M};\n\n\t\t\t--rotate: ${f};\n\t\t\t--top: ${h};\n\t\t\t--bottom: ${p};\n\t\t\t--right: ${m};\n\t\t\t--left: ${g};\n\t\t\t--container-height: ${v};\n\t\t\t--thumb-top: ${T};\n\t\t\t--thumb-border-right: ${E};\n\t\t\t--thumb-border-left: ${k};\n\t\t\t--thumb-border-top: ${A};\n\t\t\t--thumb-border-bottom: ${O};\n\t\t\t\n\t\t\t--lock-track-container: ${V?"none":"auto"};\n\t\t`;const R=t=>{n.includes("light.")?"Warmth"==e.function?this._setWarmth(r,t.target,a,l):this._setBrightness(r,t.target,a,l):n.includes("input_number.")||n.includes("number.")?this._setInputNumber(r,t.target,a,l):n.includes("media_player.")?this._setMediaVolume(r,t.target,a,l):n.includes("cover.")?this._setCover(r,t.target,a,l):n.includes("fan.")?this._setFan(r,t.target,a,l):n.includes("switch.")?this._setSwitch(r,t.target,a,l,o,s):n.includes("lock.")&&this._setLock(r,t.target,a,l,o,s)},H=t=>{e.intermediate&&R(t)},U=t=>{e.intermediate||R(t)},B=()=>{this.config.disabled_scroll=!this.config.disabled_scroll,this.config.disabled_scroll?Dt(window):Rt(window)};if(n.includes("light."))return"Warmth"==e.function?Y`