diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 29c0a60..73167cb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -19,4 +19,4 @@ jobs: with: draft: true generate_release_notes: true - files: dist/*.js + files: dist/*.js \ No newline at end of file diff --git a/dist/dev/my-cards.js b/dist/dev/my-cards.js index 3fe5b05..f06e3dd 100644 --- a/dist/dev/my-cards.js +++ b/dist/dev/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 n={en:Object.freeze({__proto__:null,common:t,default:e}),nb:Object.freeze({__proto__:null,common:i,default:s})};function o(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=t.split(".").reduce((t,e)=>t[e],n[s])}catch(e){o=t.split(".").reduce((t,e)=>t[e],n.en)}return void 0===o&&(o=t.split(".").reduce((t,e)=>t[e],n.en)),""!==e&&""!==i&&(o=o.replace(e,i)),o} +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} /*! ***************************************************************************** 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 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 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 /** * @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=[],n=document.createTreeWalker(e.content,133,null,!1);let o=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$",n=t.getAttribute(s);t.removeAttribute(s);const o=n.split(d);this.parts.push({type:"attribute",index:r,name:i,strings:o}),a+=o.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const s=t.parentNode,n=e.split(d),o=n.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,n=document.createTreeWalker(i,133,null,!1);let o=_(s),r=s[o],a=-1,l=0;const c=[];let h=null;for(;n.nextNode();){a++;const t=n.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=_(s,o),r=s[o]}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}},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(...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 n,o=0,r=0,l=s.nextNode();for(;ot}),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",n+1);const o=f.exec(t);e+=null===o?t+(i?k:h):t.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[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 T=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),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}} /** * @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 N{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 H=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class L{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&&(H?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */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) /** * @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 I(t){let e=R.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},R.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 R=new Map,U=new WeakMap; + */;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; /** * @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 z=new + */const I=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 n=e[0];if("."===n){return new j(t,e.slice(1),i).parts}if("@"===n)return[new L(t,e.slice(1),s.eventContext)];if("?"===n)return[new V(t,e.slice(1),i)];return new N(t,e,i).parts}handleTextExpression(t){return new A(t)}}; +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)}}; /** * @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 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 F=(t,...e)=>new M(t,e,"html",z) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new M(t,e,"html",I) /** * @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 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=R.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},R.set(i,s));let n=s.stringsArray.get(e.strings);if(void 0!==n)return n;const o=e.strings.join(c);if(n=s.keyString.get(o),void 0===n){const i=e.getTemplateElement();W&&window.ShadyCSS.prepareTemplateDom(i,t),n=new u(e,i),s.keyString.set(o,n)}return s.stringsArray.set(e.strings,n),n},J=["html","svg"],Z=new Set,X=(t,e,i)=>{Z.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{J.forEach(e=>{const i=R.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:n}=t;if(null==i)return void s.appendChild(e);const o=document.createTreeWalker(s,133,null,!1);let r=_(n),a=0,l=-1;for(;o.nextNode();){l++;for(o.currentNode===i&&(a=y(e),i.parentNode.insertBefore(e,i));-1!==r&&n[r].index===l;){if(a>0){for(;-1!==r;)n[r].index+=a,r=_(n,r);return}r=_(n,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 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)||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,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||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,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){}}tt.finalized=!0; + */,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; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -159,7 +159,7 @@ class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){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 nt(t){return st({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}const ot=t=>nt(t) +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) /** @license Copyright (c) 2019 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,n=U.has(e),o=W&&11===e.nodeType&&!!e.host,r=o&&!Z.has(s),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let s=U.get(e);void 0===s&&(l(e,e.firstChild),U.set(e,s=new A(Object.assign({templateFactory:I},i))),s.appendInto(e)),s.setValue(t),s.commit()})(t,a,Object.assign({templateFactory:q(s)},i)),r){const t=U.get(a);U.delete(a);const i=t.value instanceof $?t.value.template:void 0;X(s,a,i),l(e,e.firstChild),e.appendChild(a),U.set(e,t)}!n&&o&&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,n=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 Nt,Ot,At=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 n=vt(vt({},St),i);return(e=e.replace(ut,(function(e){return Ct[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}}();function Vt(){return(Vt=Object.assign||function(t){for(var e=1;e1),zt=[],Ft=!1,Bt=-1,Wt=void 0,qt=void 0,Jt=void 0,Zt=function(t){return zt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Xt=function(t){var e=t||window.event;return!!Zt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Gt=function(t,e){if(t){if(!zt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};zt=[].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),Ut&&(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;!Zt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Xt(t):t.stopPropagation())}(e,t)},Ft||(document.addEventListener("touchmove",Xt,It?{passive:!1}:void 0),Ft=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Kt=function(t){t?(zt=zt.filter((function(e){return e.targetElement!==t})),Ut&&(t.ontouchstart=null,t.ontouchmove=null,Ft&&0===zt.length&&(document.removeEventListener("touchmove",Xt,It?{passive:!1}:void 0),Ft=!1)),Ut?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 ${o("common.version")} 3.0.3 `,"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 n=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."))&&(n=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)",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)",A=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=!!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: ${N};\n\t\t\t--thumb-border-top: ${O};\n\t\t\t--thumb-border-bottom: ${A};\n\t\t\t\n\t\t\t--lock-track-container: ${V?"none":"auto"};\n\t\t`;const D=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,o,r):i.includes("lock.")&&this._setLock(s,t.target,a,l,o,r)},H=t=>{e.intermediate&&D(t)},L=t=>{e.intermediate||D(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?F` +(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`
- `:F` + `:U`
- `;if(i.includes("input_number.")||i.includes("number."))return F` + `;if(i.includes("input_number.")||i.includes("number."))return U`
- `;if(i.includes("media_player.")){var I=0;if(null!=s.attributes.volume_level)I=Number(100*s.attributes.volume_level);return F` + `;if(i.includes("media_player.")){var R=0;if(null!=s.attributes.volume_level)R=Number(100*s.attributes.volume_level);return U`
- `}return i.includes("cover.")?F` + `}return i.includes("cover.")?U`
- `:i.includes("fan.")?F` + `:i.includes("fan.")?U`
- `:i.includes("switch.")||i.includes("lock.")?F` + `:i.includes("switch.")||i.includes("lock.")?U`
- `:void 0}_setBrightness(t,e,i,s){var n=e.value;n>s?n=s:ns?n=s:ns?n=s:ns?n=s:ns?n=s:ns?n=s:ns?o=s:os?o=s:os?o=s:os?o=s:os?o=s:os?o=s:oe=>{if(!(e instanceof O)||e instanceof D||"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=te.get(e);void 0===n&&(s.cssText=i.strings.join(" "),te.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])}),ie=(t,e={})=>{switch(t){case"card":return se(e);case"container":return ne(e);case"track":return oe(e);case"progress":return re(e);case"thumb":return ae(e);default:return void console.log("Getting default styles")}},se=t=>Object.assign({height:"30px"},t),ne=t=>Object.assign({width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},t),oe=t=>Object.assign({width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},t),re=t=>Object.assign({height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},t),ae=t=>Object.assign({height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"},t),le=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=le(n,e,i):i[e[e.length-1]]=n,e.pop());return i},ce=(t,e=100,i=0)=>t/(e-i)*100,he=t=>Math.round(100*(t+Number.EPSILON))/100;console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${o("common.version")} 3.0.3 `,"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 de=class extends dt{constructor(){super(...arguments),this.colorMode="brightness",this.coverMode="position",this.sliderId="",this.touchInput=!1,this.disableScroll=!0,this.allowTapping=!0,this.thumbTapped=!1,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.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,n,o,r,a,l,c;const h=this.initializeConfig();if(null!==h)return h;const d=le(null===(t=this._config.styles)||void 0===t?void 0:t.card)?le(null===(e=this._config.styles)||void 0===e?void 0:e.card):{},u=le(null===(i=this._config.styles)||void 0===i?void 0:i.container)?le(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=le(null===(n=this._config.styles)||void 0===n?void 0:n.track)?le(null===(o=this._config.styles)||void 0===o?void 0:o.track):{},m=le(null===(r=this._config.styles)||void 0===r?void 0:r.progress)?le(null===(a=this._config.styles)||void 0===a?void 0:a.progress):{},g=le(null===(l=this._config.styles)||void 0===l?void 0:l.thumb)?le(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=>{this.actionTaken||(w(t),this.allowTapping?(this.actionTaken=!0,this.calcProgress(t)):t.path[0].classList.contains("my-slider-custom-thumb")&&(this.thumbTapped=!0,this.actionTaken=!0,this.calcProgress(t)))},C=t=>{this.actionTaken&&((this.allowTapping||this.thumbTapped)&&this.calcProgress(t),this.thumbTapped=!1,this.actionTaken=!1,this.touchInput=!1)},$=t=>{this.actionTaken&&this.calcProgress(t)};return this.createAndCleanupEventListeners(S),F` +const te=new WeakMap,ee=w(t=>e=>{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 O)||e instanceof D||"style"!=
- `}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.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)"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.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,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,t=parseFloat(this.entity.attributes.hs_color[1]),this.showMin||(this.max=this.max-this.min,t-=this.min)}this.setSliderValues(t,he(ce(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,t=parseFloat(this.entity.state),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,he(ce(t,this.max)));break;case"media_player":t=0,null!=this.entity.attributes.volume_level&&(t=Number(100*this.entity.attributes.volume_level)),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,he(ce(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.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,he(ce(t,this.max)));break;case"fan":t=0,null!=this.entity.attributes.percentage&&(t=Number(this.entity.attributes.percentage)),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,he(ce(t,this.max)));break;case"switch":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.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?he(e.y/s*100):he(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:rthis.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,brightness:2.56*e})}_setColorTemp(t,e){let i=parseFloat(t.attributes.color_temp);("off"===t.state||isNaN(i)||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,color_temp:e})}_setHue(t,e){let i=0,s=0;t.attributes.hs_color&&(i=parseFloat(t.attributes.hs_color[0]),s=parseFloat(t.attributes.hs_color[1])),("off"===t.state||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,hs_color:[e,s]})}_setSaturation(t,e){let i=0,s=0;t.attributes.hs_color&&(i=parseFloat(t.attributes.hs_color[1]),s=parseFloat(t.attributes.hs_color[0])),("off"===t.state||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,hs_color:[s,e]})}_setInputNumber(t,e){let i=parseFloat(t.state);this.showMin||(i-=this.min),Math.abs(e-i)>this.step&&this.hass.callService(t.entity_id.split(".")[0],"set_value",{entity_id:t.entity_id,value:e})}_setMediaVolume(t,e){let i=Number(100*this.entity.attributes.volume_level);this.showMin||(i-=this.min),Math.abs(e-i)>this.step&&this.hass.callService("media_player","volume_set",{entity_id:t.entity_id,volume_level:e/100})}_setCover(t,e){this.hass.callService("cover","set_cover_position",{entity_id:t.entity_id,position:e})}_setCoverTilt(t,e){this.hass.callService("cover","set_cover_tilt_position",{entity_id:t.entity_id,tilt_position:e})}_setFan(t,e){this.hass.callService("fan","set_percentage",{entity_id:t.entity_id,percentage:e})}_setSwitch(t,e){var i=Math.min(this.max,this.maxThreshold);Number(i)<=e&&this.hass.callService("homeassistant","toggle",{entity_id:t.entity_id});const s=Number(Math.max(this.zero,this.minThreshold)),n=he(ce(s,this.max));this.setSliderValues(s,n);const o=this.sliderEl.querySelector(".my-slider-custom-progress");o.style.transition="width 0.2s ease 0s",o.style.width=n.toString()+"%",setTimeout(()=>{o.style.transition="initial"},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=he(ce(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,F)}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()],de.prototype,"_config",void 0),r([st({attribute:!1})],de.prototype,"hass",void 0),r([ot()],de.prototype,"config",void 0),de=r([et("my-slider-v2")],de);const ue="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class pe extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:ue?"100px":"50px",height:ue?"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?Dt(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Dt(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Dt(t,"action",{action:"double_tap"})):Dt(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",pe);const me=(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)},ge=w((t={})=>e=>{me(e.committer.element,t)}),fe=(t,e={})=>{switch(t){case"card":return ve(e);case"icon":return ye(e);case"label-wrapper":return _e(e);case"label":return be(e);case"container":return we(e);case"container-column":return $e(e);case"row1":return Se(e);case"row2":return xe(e);case"row3":return Ce(e);case"column1":return Te(e);case"column2":return ke(e);default:return void console.log("Getting default styles")}},ve=t=>Object.assign({height:"125px",width:"100%","min-width":"fit-content",background:"var(--card-background-color)"},t),ye=t=>Object.assign({"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",padding:"10px 10px 10px 10px",cursor:"pointer",color:"var(--paper-item-active-icon-color)"},t),_e=t=>Object.assign({width:"100%",height:"100%",display:"flex"},t),be=t=>Object.assign({padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold"},t),we=t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"column",height:"100%"},t),Se=t=>Object.assign({flex:"0 1 auto"},t),xe=t=>Object.assign({flex:"1 1 auto"},t),Ce=t=>Object.assign({flex:"0 1 auto",margin:"0 2px 2px 2px"},t),$e=t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"row",height:"100%"},t),Te=t=>Object.assign({flex:"1"},t),ke=t=>Object.assign({flex:"0",padding:"3px 3px 3px 0"},t);console.info(`%c ---- MY-BUTTON ---- \n%c ${o("common.version")} 1.0.0 `,"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 Me=class extends dt{constructor(){super(...arguments),this.lastAction=0,this.layout="vertical",this.iconConfig={},this.labelConfig={},this.sliderConfig={},this.cardStl={},this.containerStl={},this.containerColumnStl={},this.iconStl={},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"];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():F``}verticalLayoutCard(){var t,e,i,s,n,o,r,a;return F` + `}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=${ge({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)})}> + .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.statsElement()}
this._handleAction(t,this.config)} - .actionHandler=${ge({hasDoubleClick:"none"!==(null===(o=null===(n=this.config)||void 0===n?void 0:n.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)})}> + .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()}
@@ -390,19 +392,19 @@ const te=new WeakMap,ee=w(t=>e=>{if(!(e instanceof O)||e instanceof D||"style"!=
- `}horizontalLayoutCard(){var t,e,i,s,n,o,r,a;return F` + `}horizontalLayoutCard(){var t,e,i,s,o,n,r,a;return U`
this._handleAction(t,this.config)} - .actionHandler=${ge({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)})}> + .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=${ge({hasDoubleClick:"none"!==(null===(o=null===(n=this.config)||void 0===n?void 0:n.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)})}> + .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()}
@@ -414,23 +416,35 @@ const te=new WeakMap,ee=w(t=>e=>{if(!(e instanceof O)||e instanceof D||"style"!=
- `}iconElement(){var t,e;return this.iconConfig.show?this.iconConfig.tap_action||this.iconConfig.double_tap_action||this.iconConfig.hold_action?F` + `}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=${ge({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)})} /> - `:F` + .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` - `:F``}labelElement(){var t,e;return this.labelConfig.show?this.labelConfig.tap_action||this.labelConfig.double_tap_action||this.labelConfig.hold_action?F` + `: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`
- `:F` + `:U`
- `:F``}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"),F` + `: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` - `):F``}initializeConfig(){var t,e,i,s,n,o,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 F`Error with this._config...`;const x={show:!0,icon:"mdi:lightbulb-outline"};"cover"===this._config.entity.split(".")[0]&&(x.icon=(null===(t=this.entity.attributes)||void 0===t?void 0:t.current_position)>=50?"mdi:blinds-open":"mdi:blinds");const C={show:!0,text:this.entity.attributes.friendly_name},$={show:!0,entity:this.entity.entity_id};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?Object.assign(Object.assign({},x),this._config.icon):x,this.labelConfig="string"==typeof this._config.label?Object.assign(Object.assign({},C),{text:this._config.label}):"object"==typeof this._config.label?Object.assign(Object.assign({},C),this._config.label):C,this.sliderConfig=this._config.slider?Object.assign(Object.assign({},$),this._config.slider):$;const T=le(null===(e=this._config.styles)||void 0===e?void 0:e.card)?le(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},k=le(null===(s=this._config.styles)||void 0===s?void 0:s.container)?le(null===(n=this._config.styles)||void 0===n?void 0:n.container):{},M=le(null===(o=this._config.styles)||void 0===o?void 0:o.containerColumn)?le(null===(r=this._config.styles)||void 0===r?void 0:r.containerColumn):{},E=le(null===(a=this._config.styles)||void 0===a?void 0:a.icon)?le(null===(l=this._config.styles)||void 0===l?void 0:l.icon):{},P=le(null===(c=this._config.styles)||void 0===c?void 0:c.labelWrapper)?le(null===(h=this._config.styles)||void 0===h?void 0:h.labelWrapper):{},N=le(null===(d=this._config.styles)||void 0===d?void 0:d.label)?le(null===(u=this._config.styles)||void 0===u?void 0:u.label):{},O=le(null===(p=this._config.styles)||void 0===p?void 0:p.row1)?le(null===(m=this._config.styles)||void 0===m?void 0:m.row1):{},A=le(null===(g=this._config.styles)||void 0===g?void 0:g.row2)?le(null===(f=this._config.styles)||void 0===f?void 0:f.row2):{},V=le(null===(v=this._config.styles)||void 0===v?void 0:v.row3)?le(null===(y=this._config.styles)||void 0===y?void 0:y.row3):{},j=le(null===(_=this._config.styles)||void 0===_?void 0:_.column1)?le(null===(b=this._config.styles)||void 0===b?void 0:b.column1):{},D=le(null===(w=this._config.styles)||void 0===w?void 0:w.column2)?le(null===(S=this._config.styles)||void 0===S?void 0:S.column2):{};return this.cardStl=fe("card",T),this.containerStl=fe("container",k),this.containerColumnStl=fe("container-column",M),this.iconStl=fe("icon",E),this.labelWrapperStl=fe("label-wrapper",P),this.labelStl=fe("label",N),this.row1Stl=fe("row1",O),this.row2Stl=fe("row2",A),this.row3Stl=fe("row3",V),this.column1Stl=fe("column1",j),this.column2Stl=fe("column2",D),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){Lt(this,this.hass,this._evalActions(this._config,"tap_action"),!1,!1)}_handleHold(t){Lt(this,this.hass,this._evalActions(this._config,"hold_action"),!0,!1)}_handleDblTap(t){Lt(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,F)}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()],Me.prototype,"_config",void 0),r([st({attribute:!1})],Me.prototype,"hass",void 0),r([ot()],Me.prototype,"config",void 0),Me=r([et("my-button")],Me),console.info(`%c ---- MY-CARDS ---- \n%c ${o("common.version")} 2.0.1 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green");export{Me as MyButton,Qt as MySlider,de as MySliderV2}; + `):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}; diff --git a/dist/my-button.js b/dist/my-button.js index 68d81fe..d2c393d 100644 --- a/dist/my-button.js +++ b/dist/my-button.js @@ -39,7 +39,7 @@ function t(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPro * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const f=new WeakMap,m=t=>(...e)=>{const i=t(...e);return f.set(i,!0),i},g=t=>"function"==typeof t&&f.has(t),y={},v={}; +const f=new WeakMap,g=t=>(...e)=>{const i=t(...e);return f.set(i,!0),i},m=t=>"function"==typeof t&&f.has(t),y={},v={}; /** * @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 k=!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(;g(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&&(k?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */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) /** * @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,V=new WeakMap; + */;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; /** * @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 H=new + */const V=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,n){const s=e[0];if("."===s){return new O(t,e.slice(1),i).parts}if("@"===s)return[new A(t,e.slice(1),n.eventContext)];if("?"===s)return[new N(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 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)}}; /** * @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 O( * 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",H) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new w(t,e,"html",V) /** * @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=V.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=V.get(e);void 0===s&&(i(e,e.firstChild),V.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=V.get(l);V.delete(l);const n=t.value instanceof _?t.value.template:void 0;F(s,l,n),i(e,e.firstChild),e.appendChild(l),V.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=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"}; /** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. @@ -197,13 +197,15 @@ 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=m(t=>e=>{if(!(e instanceof T)||e instanceof M||"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]}},mt=ht({},ft),gt=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+gt(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+gt(Math.floor(Math.abs(e)/60),2)+":"+gt(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({},mt),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?Ot(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Ot(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Ot(t,"action",{action:"double_tap"})):Ot(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=m((t={})=>e=>{jt(e.committer.element,t)});var Vt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Ht={common:Vt},Ut={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Yt={common:Ut};const Lt={en:Object.freeze({__proto__:null,common:Vt,default:Ht}),nb:Object.freeze({__proto__:null,common:Ut,default:Yt})};const Rt=(t,e={})=>{switch(t){case"card":return zt(e);case"icon":return It(e);case"label-wrapper":return Ft(e);case"label":return qt(e);case"container":return Wt(e);case"container-column":return Xt(e);case"row1":return Bt(e);case"row2":return Jt(e);case"row3":return Zt(e);case"column1":return Gt(e);case"column2":return Kt(e);default:return void console.log("Getting default styles")}},zt=t=>Object.assign({height:"125px",width:"100%","min-width":"fit-content",background:"var(--card-background-color)"},t),It=t=>Object.assign({"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",padding:"10px 10px 10px 10px",cursor:"pointer",color:"var(--paper-item-active-icon-color)"},t),Ft=t=>Object.assign({width:"100%",height:"100%",display:"flex"},t),qt=t=>Object.assign({padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold"},t),Wt=t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"column",height:"100%"},t),Bt=t=>Object.assign({flex:"0 1 auto"},t),Jt=t=>Object.assign({flex:"1 1 auto"},t),Zt=t=>Object.assign({flex:"0 1 auto",margin:"0 2px 2px 2px"},t),Xt=t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"row",height:"100%"},t),Gt=t=>Object.assign({flex:"1"},t),Kt=t=>Object.assign({flex:"0",padding:"3px 3px 3px 0"},t),Qt=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=Qt(s,e,i):i[e[e.length-1]]=s,e.pop());return i};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.0 `,"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 te=class extends it{constructor(){super(...arguments),this.lastAction=0,this.layout="vertical",this.iconConfig={},this.labelConfig={},this.sliderConfig={},this.cardStl={},this.containerStl={},this.containerColumnStl={},this.iconStl={},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"];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` +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()} + + ${this.statsElement()}
this._handleAction(t,this.config)} @@ -245,6 +247,18 @@ const nt=new WeakMap,st=m(t=>e=>{if(!(e instanceof T)||e instanceof M||"style"!= .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``}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,m,g,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={show:!0,icon:"mdi:lightbulb-outline"};"cover"===this._config.entity.split(".")[0]&&(C.icon=(null===(t=this.entity.attributes)||void 0===t?void 0:t.current_position)>=50?"mdi:blinds-open":"mdi:blinds");const x={show:!0,text:this.entity.attributes.friendly_name},P={show:!0,entity:this.entity.entity_id};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?Object.assign(Object.assign({},C),this._config.icon):C,this.labelConfig="string"==typeof this._config.label?Object.assign(Object.assign({},x),{text:this._config.label}):"object"==typeof this._config.label?Object.assign(Object.assign({},x),this._config.label):x,this.sliderConfig=this._config.slider?Object.assign(Object.assign({},P),this._config.slider):P;const T=Qt(null===(e=this._config.styles)||void 0===e?void 0:e.card)?Qt(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},E=Qt(null===(n=this._config.styles)||void 0===n?void 0:n.container)?Qt(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},N=Qt(null===(o=this._config.styles)||void 0===o?void 0:o.containerColumn)?Qt(null===(r=this._config.styles)||void 0===r?void 0:r.containerColumn):{},O=Qt(null===(a=this._config.styles)||void 0===a?void 0:a.icon)?Qt(null===(l=this._config.styles)||void 0===l?void 0:l.icon):{},M=Qt(null===(c=this._config.styles)||void 0===c?void 0:c.labelWrapper)?Qt(null===(h=this._config.styles)||void 0===h?void 0:h.labelWrapper):{},k=Qt(null===(d=this._config.styles)||void 0===d?void 0:d.label)?Qt(null===(u=this._config.styles)||void 0===u?void 0:u.label):{},A=Qt(null===(p=this._config.styles)||void 0===p?void 0:p.row1)?Qt(null===(f=this._config.styles)||void 0===f?void 0:f.row1):{},$=Qt(null===(m=this._config.styles)||void 0===m?void 0:m.row2)?Qt(null===(g=this._config.styles)||void 0===g?void 0:g.row2):{},j=Qt(null===(y=this._config.styles)||void 0===y?void 0:y.row3)?Qt(null===(v=this._config.styles)||void 0===v?void 0:v.row3):{},D=Qt(null===(_=this._config.styles)||void 0===_?void 0:_.column1)?Qt(null===(b=this._config.styles)||void 0===b?void 0:b.column1):{},V=Qt(null===(S=this._config.styles)||void 0===S?void 0:S.column2)?Qt(null===(w=this._config.styles)||void 0===w?void 0:w.column2):{};return this.cardStl=Rt("card",T),this.containerStl=Rt("container",E),this.containerColumnStl=Rt("container-column",N),this.iconStl=Rt("icon",O),this.labelWrapperStl=Rt("label-wrapper",M),this.labelStl=Rt("label",k),this.row1Stl=Rt("row1",A),this.row2Stl=Rt("row2",$),this.row3Stl=Rt("row3",j),this.column1Stl=Rt("column1",D),this.column2Stl=Rt("column2",V),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){kt(this,this.hass,this._evalActions(this._config,"tap_action"),!1,!1)}_handleHold(t){kt(this,this.hass,this._evalActions(this._config,"hold_action"),!0,!1)}_handleDblTap(t){kt(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 ee,ie;t([X()],te.prototype,"_config",void 0),t([X({attribute:!1})],te.prototype,"hass",void 0),t([function(t){return X({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(ee)],te.prototype,"config",void 0),te=t([(ie="my-button",t=>"function"==typeof t?((t,e)=>(window.customElements.define(t,e),e))(ie,t):((t,e)=>{const{kind:i,elements:n}=e;return{kind:i,elements:n,finisher(e){window.customElements.define(t,e)}}})(ie,t))],te);export{te as MyButton}; + `):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}; diff --git a/dist/my-cards.js b/dist/my-cards.js index a12668c..f06e3dd 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 n={en:Object.freeze({__proto__:null,common:t,default:e}),nb:Object.freeze({__proto__:null,common:i,default:s})};function o(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=t.split(".").reduce((t,e)=>t[e],n[s])}catch(e){o=t.split(".").reduce((t,e)=>t[e],n.en)}return void 0===o&&(o=t.split(".").reduce((t,e)=>t[e],n.en)),""!==e&&""!==i&&(o=o.replace(e,i)),o} +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} /*! ***************************************************************************** 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 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 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 /** * @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=[],n=document.createTreeWalker(e.content,133,null,!1);let o=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$",n=t.getAttribute(s);t.removeAttribute(s);const o=n.split(d);this.parts.push({type:"attribute",index:r,name:i,strings:o}),a+=o.length-1}}"TEMPLATE"===t.tagName&&(s.push(t),n.currentNode=t.content)}else if(3===t.nodeType){const e=t.data;if(e.indexOf(c)>=0){const s=t.parentNode,n=e.split(d),o=n.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,n=document.createTreeWalker(i,133,null,!1);let o=_(s),r=s[o],a=-1,l=0;const c=[];let h=null;for(;n.nextNode();){a++;const t=n.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=_(s,o),r=s[o]}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}},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(...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 n,o=0,r=0,l=s.nextNode();for(;ot}),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",n+1);const o=f.exec(t);e+=null===o?t+(i?k:h):t.substr(0,o.index)+o[1]+o[2]+"$lit$"+o[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 T=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),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}} /** * @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 N{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 H=!0,!1}};window.addEventListener("test",t,t),window.removeEventListener("test",t,t)}catch(t){}})();class L{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&&(H?{capture:t.capture,passive:t.passive,once:t.once}:t.capture) + */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) /** * @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 I(t){let e=R.get(t.type);void 0===e&&(e={stringsArray:new WeakMap,keyString:new Map},R.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 R=new Map,U=new WeakMap; + */;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; /** * @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 z=new + */const I=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 n=e[0];if("."===n){return new j(t,e.slice(1),i).parts}if("@"===n)return[new L(t,e.slice(1),s.eventContext)];if("?"===n)return[new V(t,e.slice(1),i)];return new N(t,e,i).parts}handleTextExpression(t){return new A(t)}}; +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)}}; /** * @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 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 F=(t,...e)=>new M(t,e,"html",z) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new M(t,e,"html",I) /** * @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 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=R.get(i);void 0===s&&(s={stringsArray:new WeakMap,keyString:new Map},R.set(i,s));let n=s.stringsArray.get(e.strings);if(void 0!==n)return n;const o=e.strings.join(c);if(n=s.keyString.get(o),void 0===n){const i=e.getTemplateElement();W&&window.ShadyCSS.prepareTemplateDom(i,t),n=new u(e,i),s.keyString.set(o,n)}return s.stringsArray.set(e.strings,n),n},J=["html","svg"],Z=new Set,X=(t,e,i)=>{Z.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{J.forEach(e=>{const i=R.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:n}=t;if(null==i)return void s.appendChild(e);const o=document.createTreeWalker(s,133,null,!1);let r=_(n),a=0,l=-1;for(;o.nextNode();){l++;for(o.currentNode===i&&(a=y(e),i.parentNode.insertBefore(e,i));-1!==r&&n[r].index===l;){if(a>0){for(;-1!==r;)n[r].index+=a,r=_(n,r);return}r=_(n,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 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)||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,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||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,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){}}tt.finalized=!0; + */,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; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -159,7 +159,7 @@ class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){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 nt(t){return st({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}const ot=t=>nt(t) +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) /** @license Copyright (c) 2019 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,n=U.has(e),o=W&&11===e.nodeType&&!!e.host,r=o&&!Z.has(s),a=r?document.createDocumentFragment():e;if(((t,e,i)=>{let s=U.get(e);void 0===s&&(l(e,e.firstChild),U.set(e,s=new A(Object.assign({templateFactory:I},i))),s.appendInto(e)),s.setValue(t),s.commit()})(t,a,Object.assign({templateFactory:q(s)},i)),r){const t=U.get(a);U.delete(a);const i=t.value instanceof $?t.value.template:void 0;X(s,a,i),l(e,e.firstChild),e.appendChild(a),U.set(e,t)}!n&&o&&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,n=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 Nt,Ot,At=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 n=vt(vt({},St),i);return(e=e.replace(ut,(function(e){return Ct[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}}();function Vt(){return(Vt=Object.assign||function(t){for(var e=1;e1),zt=[],Ft=!1,Bt=-1,Wt=void 0,qt=void 0,Jt=void 0,Zt=function(t){return zt.some((function(e){return!(!e.options.allowTouchMove||!e.options.allowTouchMove(t))}))},Xt=function(t){var e=t||window.event;return!!Zt(e.target)||(e.touches.length>1||(e.preventDefault&&e.preventDefault(),!1))},Gt=function(t,e){if(t){if(!zt.some((function(e){return e.targetElement===t}))){var i={targetElement:t,options:e||{}};zt=[].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),Ut&&(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;!Zt(t.target)&&(e&&0===e.scrollTop&&i>0||function(t){return!!t&&t.scrollHeight-t.scrollTop<=t.clientHeight}(e)&&i<0?Xt(t):t.stopPropagation())}(e,t)},Ft||(document.addEventListener("touchmove",Xt,It?{passive:!1}:void 0),Ft=!0))}}else console.error("disableBodyScroll unsuccessful - targetElement must be provided when calling disableBodyScroll on IOS devices.")},Kt=function(t){t?(zt=zt.filter((function(e){return e.targetElement!==t})),Ut&&(t.ontouchstart=null,t.ontouchmove=null,Ft&&0===zt.length&&(document.removeEventListener("touchmove",Xt,It?{passive:!1}:void 0),Ft=!1)),Ut?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 ${o("common.version")} 3.0.4 `,"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 n=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."))&&(n=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)",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)",A=e.thumbBorderBotton?e.thumbBorderBotton:"var(--thumb-vertical-padding) solid var(--slider-main-color)",V=!!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: ${N};\n\t\t\t--thumb-border-top: ${O};\n\t\t\t--thumb-border-bottom: ${A};\n\t\t\t\n\t\t\t--lock-track-container: ${V?"none":"auto"};\n\t\t`;const D=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,o,r):i.includes("lock.")&&this._setLock(s,t.target,a,l,o,r)},H=t=>{e.intermediate&&D(t)},L=t=>{e.intermediate||D(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?F` +(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`
- `:F` + `:U`
- `;if(i.includes("input_number.")||i.includes("number."))return F` + `;if(i.includes("input_number.")||i.includes("number."))return U`
- `;if(i.includes("media_player.")){var I=0;if(null!=s.attributes.volume_level)I=Number(100*s.attributes.volume_level);return F` + `;if(i.includes("media_player.")){var R=0;if(null!=s.attributes.volume_level)R=Number(100*s.attributes.volume_level);return U`
- `}return i.includes("cover.")?F` + `}return i.includes("cover.")?U`
- `:i.includes("fan.")?F` + `:i.includes("fan.")?U`
- `:i.includes("switch.")||i.includes("lock.")?F` + `:i.includes("switch.")||i.includes("lock.")?U`
- `:void 0}_setBrightness(t,e,i,s){var n=e.value;n>s?n=s:ns?n=s:ns?n=s:ns?n=s:ns?n=s:ns?n=s:ns?o=s:os?o=s:os?o=s:os?o=s:os?o=s:os?o=s:oe=>{if(!(e instanceof O)||e instanceof D||"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=te.get(e);void 0===n&&(s.cssText=i.strings.join(" "),te.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])}),ie=(t,e={})=>{switch(t){case"card":return se(e);case"container":return ne(e);case"track":return oe(e);case"progress":return re(e);case"thumb":return ae(e);default:return void console.log("Getting default styles")}},se=t=>Object.assign({height:"30px"},t),ne=t=>Object.assign({width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},t),oe=t=>Object.assign({width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},t),re=t=>Object.assign({height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},t),ae=t=>Object.assign({height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"},t),le=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=le(n,e,i):i[e[e.length-1]]=n,e.pop());return i},ce=(t,e=100,i=0)=>t/(e-i)*100,he=t=>Math.round(100*(t+Number.EPSILON))/100;console.info(`%c ---- MY-SLIDER-V2 ---- \n%c ${o("common.version")} 3.0.4 `,"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 de=class extends dt{constructor(){super(...arguments),this.colorMode="brightness",this.coverMode="position",this.sliderId="",this.touchInput=!1,this.disableScroll=!0,this.allowTapping=!0,this.thumbTapped=!1,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.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,n,o,r,a,l,c;const h=this.initializeConfig();if(null!==h)return h;const d=le(null===(t=this._config.styles)||void 0===t?void 0:t.card)?le(null===(e=this._config.styles)||void 0===e?void 0:e.card):{},u=le(null===(i=this._config.styles)||void 0===i?void 0:i.container)?le(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=le(null===(n=this._config.styles)||void 0===n?void 0:n.track)?le(null===(o=this._config.styles)||void 0===o?void 0:o.track):{},m=le(null===(r=this._config.styles)||void 0===r?void 0:r.progress)?le(null===(a=this._config.styles)||void 0===a?void 0:a.progress):{},g=le(null===(l=this._config.styles)||void 0===l?void 0:l.thumb)?le(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=>{this.actionTaken||(w(t),this.allowTapping?(this.actionTaken=!0,this.calcProgress(t)):t.path[0].classList.contains("my-slider-custom-thumb")&&(this.thumbTapped=!0,this.actionTaken=!0,this.calcProgress(t)))},C=t=>{this.actionTaken&&((this.allowTapping||this.thumbTapped)&&this.calcProgress(t),this.thumbTapped=!1,this.actionTaken=!1,this.touchInput=!1)},$=t=>{this.actionTaken&&this.calcProgress(t)};return this.createAndCleanupEventListeners(S),F` +const te=new WeakMap,ee=w(t=>e=>{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 O)||e instanceof D||"style"!=
- `}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.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)"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.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,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,t=parseFloat(this.entity.attributes.hs_color[1]),this.showMin||(this.max=this.max-this.min,t-=this.min)}this.setSliderValues(t,he(ce(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,t=parseFloat(this.entity.state),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,he(ce(t,this.max)));break;case"media_player":t=0,null!=this.entity.attributes.volume_level&&(t=Number(100*this.entity.attributes.volume_level)),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,he(ce(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.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,he(ce(t,this.max)));break;case"fan":t=0,null!=this.entity.attributes.percentage&&(t=Number(this.entity.attributes.percentage)),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,he(ce(t,this.max)));break;case"switch":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.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?he(e.y/s*100):he(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:rthis.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,brightness:2.56*e})}_setColorTemp(t,e){let i=parseFloat(t.attributes.color_temp);("off"===t.state||isNaN(i)||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,color_temp:e})}_setHue(t,e){let i=0,s=0;t.attributes.hs_color&&(i=parseFloat(t.attributes.hs_color[0]),s=parseFloat(t.attributes.hs_color[1])),("off"===t.state||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,hs_color:[e,s]})}_setSaturation(t,e){let i=0,s=0;t.attributes.hs_color&&(i=parseFloat(t.attributes.hs_color[1]),s=parseFloat(t.attributes.hs_color[0])),("off"===t.state||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,hs_color:[s,e]})}_setInputNumber(t,e){let i=parseFloat(t.state);this.showMin||(i-=this.min),Math.abs(e-i)>this.step&&this.hass.callService(t.entity_id.split(".")[0],"set_value",{entity_id:t.entity_id,value:e})}_setMediaVolume(t,e){let i=Number(100*this.entity.attributes.volume_level);this.showMin||(i-=this.min),Math.abs(e-i)>this.step&&this.hass.callService("media_player","volume_set",{entity_id:t.entity_id,volume_level:e/100})}_setCover(t,e){this.hass.callService("cover","set_cover_position",{entity_id:t.entity_id,position:e})}_setCoverTilt(t,e){this.hass.callService("cover","set_cover_tilt_position",{entity_id:t.entity_id,tilt_position:e})}_setFan(t,e){this.hass.callService("fan","set_percentage",{entity_id:t.entity_id,percentage:e})}_setSwitch(t,e){var i=Math.min(this.max,this.maxThreshold);Number(i)<=e&&this.hass.callService("homeassistant","toggle",{entity_id:t.entity_id});const s=Number(Math.max(this.zero,this.minThreshold)),n=he(ce(s,this.max));this.setSliderValues(s,n);const o=this.sliderEl.querySelector(".my-slider-custom-progress");o.style.transition="width 0.2s ease 0s",o.style.width=n.toString()+"%",setTimeout(()=>{o.style.transition="initial"},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=he(ce(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,F)}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()],de.prototype,"_config",void 0),r([st({attribute:!1})],de.prototype,"hass",void 0),r([ot()],de.prototype,"config",void 0),de=r([et("my-slider-v2")],de);const ue="ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0;class pe extends HTMLElement{constructor(){super(),this.holdTime=500,this.held=!1,this.ripple=document.createElement("mwc-ripple")}connectedCallback(){Object.assign(this.style,{position:"absolute",width:ue?"100px":"50px",height:ue?"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?Dt(t,"action",{action:"hold"}):e.hasDoubleClick?"click"===i.type&&i.detail<2||!this.dblClickTimeout?this.dblClickTimeout=window.setTimeout(()=>{this.dblClickTimeout=void 0,Dt(t,"action",{action:"tap"})},250):(clearTimeout(this.dblClickTimeout),this.dblClickTimeout=void 0,Dt(t,"action",{action:"double_tap"})):Dt(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",pe);const me=(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)},ge=w((t={})=>e=>{me(e.committer.element,t)}),fe=(t,e={})=>{switch(t){case"card":return ve(e);case"icon":return ye(e);case"label-wrapper":return _e(e);case"label":return be(e);case"container":return we(e);case"container-column":return $e(e);case"row1":return Se(e);case"row2":return xe(e);case"row3":return Ce(e);case"column1":return Te(e);case"column2":return ke(e);default:return void console.log("Getting default styles")}},ve=t=>Object.assign({height:"125px",width:"100%","min-width":"fit-content",background:"var(--card-background-color)"},t),ye=t=>Object.assign({"--mdc-icon-size":"100%",height:"35px",width:"35px",display:"inline-block",padding:"10px 10px 10px 10px",cursor:"pointer",color:"var(--paper-item-active-icon-color)"},t),_e=t=>Object.assign({width:"100%",height:"100%",display:"flex"},t),be=t=>Object.assign({padding:"0",margin:"0 10px",color:"var(--primary-text-color)","font-weight":"bold"},t),we=t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"column",height:"100%"},t),Se=t=>Object.assign({flex:"0 1 auto"},t),xe=t=>Object.assign({flex:"1 1 auto"},t),Ce=t=>Object.assign({flex:"0 1 auto",margin:"0 2px 2px 2px"},t),$e=t=>Object.assign({padding:"0",margin:"0",display:"flex","flex-flow":"row",height:"100%"},t),Te=t=>Object.assign({flex:"1"},t),ke=t=>Object.assign({flex:"0",padding:"3px 3px 3px 0"},t);console.info(`%c ---- MY-BUTTON ---- \n%c ${o("common.version")} 1.0.0 `,"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 Me=class extends dt{constructor(){super(...arguments),this.lastAction=0,this.layout="vertical",this.iconConfig={},this.labelConfig={},this.sliderConfig={},this.cardStl={},this.containerStl={},this.containerColumnStl={},this.iconStl={},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"];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():F``}verticalLayoutCard(){var t,e,i,s,n,o,r,a;return F` + `}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=${ge({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)})}> + .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.statsElement()}
this._handleAction(t,this.config)} - .actionHandler=${ge({hasDoubleClick:"none"!==(null===(o=null===(n=this.config)||void 0===n?void 0:n.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)})}> + .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()}
@@ -390,19 +392,19 @@ const te=new WeakMap,ee=w(t=>e=>{if(!(e instanceof O)||e instanceof D||"style"!=
- `}horizontalLayoutCard(){var t,e,i,s,n,o,r,a;return F` + `}horizontalLayoutCard(){var t,e,i,s,o,n,r,a;return U`
this._handleAction(t,this.config)} - .actionHandler=${ge({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)})}> + .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=${ge({hasDoubleClick:"none"!==(null===(o=null===(n=this.config)||void 0===n?void 0:n.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)})}> + .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()}
@@ -414,23 +416,35 @@ const te=new WeakMap,ee=w(t=>e=>{if(!(e instanceof O)||e instanceof D||"style"!=
- `}iconElement(){var t,e;return this.iconConfig.show?this.iconConfig.tap_action||this.iconConfig.double_tap_action||this.iconConfig.hold_action?F` + `}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=${ge({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)})} /> - `:F` + .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` - `:F``}labelElement(){var t,e;return this.labelConfig.show?this.labelConfig.tap_action||this.labelConfig.double_tap_action||this.labelConfig.hold_action?F` + `: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`
- `:F` + `:U`
- `:F``}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"),F` + `: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` - `):F``}initializeConfig(){var t,e,i,s,n,o,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 F`Error with this._config...`;const x={show:!0,icon:"mdi:lightbulb-outline"};"cover"===this._config.entity.split(".")[0]&&(x.icon=(null===(t=this.entity.attributes)||void 0===t?void 0:t.current_position)>=50?"mdi:blinds-open":"mdi:blinds");const C={show:!0,text:this.entity.attributes.friendly_name},$={show:!0,entity:this.entity.entity_id};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?Object.assign(Object.assign({},x),this._config.icon):x,this.labelConfig="string"==typeof this._config.label?Object.assign(Object.assign({},C),{text:this._config.label}):"object"==typeof this._config.label?Object.assign(Object.assign({},C),this._config.label):C,this.sliderConfig=this._config.slider?Object.assign(Object.assign({},$),this._config.slider):$;const T=le(null===(e=this._config.styles)||void 0===e?void 0:e.card)?le(null===(i=this._config.styles)||void 0===i?void 0:i.card):{},k=le(null===(s=this._config.styles)||void 0===s?void 0:s.container)?le(null===(n=this._config.styles)||void 0===n?void 0:n.container):{},M=le(null===(o=this._config.styles)||void 0===o?void 0:o.containerColumn)?le(null===(r=this._config.styles)||void 0===r?void 0:r.containerColumn):{},E=le(null===(a=this._config.styles)||void 0===a?void 0:a.icon)?le(null===(l=this._config.styles)||void 0===l?void 0:l.icon):{},P=le(null===(c=this._config.styles)||void 0===c?void 0:c.labelWrapper)?le(null===(h=this._config.styles)||void 0===h?void 0:h.labelWrapper):{},N=le(null===(d=this._config.styles)||void 0===d?void 0:d.label)?le(null===(u=this._config.styles)||void 0===u?void 0:u.label):{},O=le(null===(p=this._config.styles)||void 0===p?void 0:p.row1)?le(null===(m=this._config.styles)||void 0===m?void 0:m.row1):{},A=le(null===(g=this._config.styles)||void 0===g?void 0:g.row2)?le(null===(f=this._config.styles)||void 0===f?void 0:f.row2):{},V=le(null===(v=this._config.styles)||void 0===v?void 0:v.row3)?le(null===(y=this._config.styles)||void 0===y?void 0:y.row3):{},j=le(null===(_=this._config.styles)||void 0===_?void 0:_.column1)?le(null===(b=this._config.styles)||void 0===b?void 0:b.column1):{},D=le(null===(w=this._config.styles)||void 0===w?void 0:w.column2)?le(null===(S=this._config.styles)||void 0===S?void 0:S.column2):{};return this.cardStl=fe("card",T),this.containerStl=fe("container",k),this.containerColumnStl=fe("container-column",M),this.iconStl=fe("icon",E),this.labelWrapperStl=fe("label-wrapper",P),this.labelStl=fe("label",N),this.row1Stl=fe("row1",O),this.row2Stl=fe("row2",A),this.row3Stl=fe("row3",V),this.column1Stl=fe("column1",j),this.column2Stl=fe("column2",D),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){Lt(this,this.hass,this._evalActions(this._config,"tap_action"),!1,!1)}_handleHold(t){Lt(this,this.hass,this._evalActions(this._config,"hold_action"),!0,!1)}_handleDblTap(t){Lt(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,F)}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()],Me.prototype,"_config",void 0),r([st({attribute:!1})],Me.prototype,"hass",void 0),r([ot()],Me.prototype,"config",void 0),Me=r([et("my-button")],Me),console.info(`%c ---- MY-CARDS ---- \n%c ${o("common.version")} 2.0.2 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: green");export{Me as MyButton,Qt as MySlider,de as MySliderV2}; + `):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}; diff --git a/dist/my-slider-v2.js b/dist/my-slider-v2.js index 920d731..532e731 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,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 +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 /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -25,7 +25,7 @@ function t(t,e,i,s){var n,r=arguments.length,o=r<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`,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 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 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},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 r=p(s),o=s[r],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!==o&&o.index===a;)o.index=null!==c?-1:o.index-h,r=p(s,r),o=s[r]}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`,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"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 r,o=0,a=0,l=n.nextNode();for(;ot}),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}} + */const v=window.trustedTypes&&trustedTypes.createPolicy("lit-html",{createHTML:t=>t}),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}} /** * @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 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 E=!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&&(E?{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 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) /** * @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 o(t,t.getTemplateElement()),e.keyString.set(n,i)),e.stringsArray.set(t.strings,i),i}const D=new Map,U=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 r(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. @@ -105,7 +105,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 Y=new + */const L=new /** * @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 V(t,e.slice(1),s.eventContext)];if("?"===n)return[new N(t,e.slice(1),i)];return new M(t,e,i).parts}handleTextExpression(t){return new P(t)}}; +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)}}; /** * @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 $=(t,...e)=>new S(t,e,"html",Y) + */"undefined"!=typeof window&&(window.litHtmlVersions||(window.litHtmlVersions=[])).push("1.4.1");const U=(t,...e)=>new b(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 - */,j=(t,e)=>`${t}--${e}`;let H=!0;void 0===window.ShadyCSS?H=!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."),H=!1);const L=t=>e=>{const i=j(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();H&&window.ShadyCSS.prepareTemplateDom(i,t),r=new o(e,i),n.keyString.set(a,r)}return n.stringsArray.set(e.strings,r),r},R=["html","svg"],I=new Set,F=(t,e,i)=>{I.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{R.forEach(e=>{const i=D.get(j(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,h=-1;for(;r.nextNode();){h++;for(r.currentNode===i&&(a=u(e),i.parentNode.insertBefore(e,i));-1!==o&&n[o].index===h;){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 h=a.querySelector("style");if(window.ShadyCSS.nativeShadow&&null!==h)e.insertBefore(h.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; + */,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; /** * @license * Copyright (c) 2017 The Polymer Project Authors. All rights reserved. @@ -159,7 +159,7 @@ class{handleAttributeExpressions(t,e,i,s){const n=e[0];if("."===n){return new C( * subject to an additional IP rights grant found at * http://polymer.github.io/PATENTS.txt */ -const J=(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 Z(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):J(t,e)}const X=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,G=Symbol(); +const X=(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 J(t){return(e,i)=>void 0!==i?((t,e,i)=>{e.constructor.createProperty(i,t)})(t,e,i):X(t,e)}const Z=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,G=Symbol(); /** @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 -*/class K{constructor(t,e){if(e!==G)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(X?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Q=(t,...e)=>{const i=e.reduce((e,i,s)=>e+(t=>{if(t instanceof K)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 K(i,G)}; +*/class K{constructor(t,e){if(e!==G)throw new Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t}get styleSheet(){return void 0===this._styleSheet&&(Z?(this._styleSheet=new CSSStyleSheet,this._styleSheet.replaceSync(this.cssText)):this._styleSheet=null),this._styleSheet}toString(){return this.cssText}}const Q=(t,...e)=>{const i=e.reduce((e,i,s)=>e+(t=>{if(t instanceof K)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 K(i,G)}; /** * @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&&!X){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?X?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=U.has(e),o=H&&11===e.nodeType&&!!e.host,a=o&&!I.has(n),h=a?document.createDocumentFragment():e;if(((t,e,s)=>{let n=U.get(e);void 0===n&&(i(e,e.firstChild),U.set(e,n=new P(Object.assign({templateFactory:A},s))),n.appendInto(e)),n.setValue(t),n.commit()})(t,h,Object.assign({templateFactory:L(n)},s)),a){const t=U.get(h);U.delete(h);const s=t.value instanceof y?t.value.template:void 0;F(n,h,s),i(e,e.firstChild),e.appendChild(h),U.set(e,t)}!r&&o&&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,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"}; /** * @license * Copyright (c) 2018 The Polymer Project Authors. All rights reserved. @@ -197,7 +197,7 @@ 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 T)||e instanceof k||"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 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?"],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=(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 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 Nt={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",show_error:"Show Error"},Ct={common:Nt},kt={version:"Versjon",invalid_configuration:"Ikke gyldig konfiguration",show_warning:"Vis advarsel"},Et={common:kt};const Vt={en:Object.freeze({__proto__:null,common:Nt,default:Ct}),nb:Object.freeze({__proto__:null,common:kt,default:Et})};const Ot=(t,e={})=>{switch(t){case"card":return At(e);case"container":return Dt(e);case"track":return Ut(e);case"progress":return Yt(e);case"thumb":return $t(e);default:return void console.log("Getting default styles")}},At=t=>Object.assign({height:"30px"},t),Dt=t=>Object.assign({width:"100%",height:"100%",position:"relative",overflow:"hidden","border-radius":"5px"},t),Ut=t=>Object.assign({width:"100%",height:"100%",position:"relative",background:"var(--card-background-color)"},t),Yt=t=>Object.assign({height:"100%",background:"var(--paper-item-icon-active-color)",position:"absolute",width:"0.00%"},t),$t=t=>Object.assign({height:"100%",background:"black",position:"absolute",right:"-5px",width:"10px"},t),jt=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=jt(n,e,i):i[e[e.length-1]]=n,e.pop());return i},Ht=(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],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.4 `,"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 Rt=class extends et{constructor(){super(...arguments),this.colorMode="brightness",this.coverMode="position",this.sliderId="",this.touchInput=!1,this.disableScroll=!0,this.allowTapping=!0,this.thumbTapped=!1,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.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,r,o,a,h,l;const c=this.initializeConfig();if(null!==c)return c;const d=jt(null===(t=this._config.styles)||void 0===t?void 0:t.card)?jt(null===(e=this._config.styles)||void 0===e?void 0:e.card):{},u=jt(null===(i=this._config.styles)||void 0===i?void 0:i.container)?jt(null===(s=this._config.styles)||void 0===s?void 0:s.container):{},p=jt(null===(n=this._config.styles)||void 0===n?void 0:n.track)?jt(null===(r=this._config.styles)||void 0===r?void 0:r.track):{},m=jt(null===(o=this._config.styles)||void 0===o?void 0:o.progress)?jt(null===(a=this._config.styles)||void 0===a?void 0:a.progress):{},g=jt(null===(h=this._config.styles)||void 0===h?void 0:h.thumb)?jt(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),b=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",b.right=g.right?g:"auto",b.width=g.width?g.width:"100%",b.height=g.height?g.height:"10px",this.flipped?(v.top=m.top?m.top:"0",b.bottom=g.bottom?g.bottom:"-5px"):(v.bottom=m.bottom?m.bottom:"0",b.top=g.top?g.top:"-5px")):(v.width=this.sliderValPercent.toString()+"%",this.flipped&&(v.right=m.right?m.right:"0",b.right=g.right?g.right:"auto",b.left=g.left?g.left:"-5px"));const S=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;T(t);break;case"touchmove":this.disableScroll&&t.preventDefault(),T(t);break;case"mouseup":case"touchend":case"touchcancel":M(t)}},x=t=>{this.actionTaken||(S(t),this.allowTapping?(this.actionTaken=!0,this.calcProgress(t)):t.path[0].classList.contains("my-slider-custom-thumb")&&(this.thumbTapped=!0,this.actionTaken=!0,this.calcProgress(t)))},M=t=>{this.actionTaken&&((this.allowTapping||this.thumbTapped)&&this.calcProgress(t),this.thumbTapped=!1,this.actionTaken=!1,this.touchInput=!1)},T=t=>{this.actionTaken&&this.calcProgress(t)};return this.createAndCleanupEventListeners(w),$` +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 k||"style" >
-
+
- `}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.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)"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.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,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,t=parseFloat(this.entity.attributes.hs_color[1]),this.showMin||(this.max=this.max-this.min,t-=this.min)}this.setSliderValues(t,Lt(Ht(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,t=parseFloat(this.entity.state),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,Lt(Ht(t,this.max)));break;case"media_player":t=0,null!=this.entity.attributes.volume_level&&(t=Number(100*this.entity.attributes.volume_level)),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,Lt(Ht(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.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(Ht(t,this.max)));break;case"fan":t=0,null!=this.entity.attributes.percentage&&(t=Number(this.entity.attributes.percentage)),this.showMin||(this.max=this.max-this.min,t-=this.min),this.setSliderValues(t,Lt(Ht(t,this.max)));break;case"switch":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.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,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.vertical?Lt(e.y/s*100):Lt(e.x/i*100))/100*(this.max-0),r=this.max-n;let o=this.flipped?Math.round(r):Math.round(n);o=othis.max?this.max:othis.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,brightness:2.56*e})}_setColorTemp(t,e){let i=parseFloat(t.attributes.color_temp);("off"===t.state||isNaN(i)||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,color_temp:e})}_setHue(t,e){let i=0,s=0;t.attributes.hs_color&&(i=parseFloat(t.attributes.hs_color[0]),s=parseFloat(t.attributes.hs_color[1])),("off"===t.state||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,hs_color:[e,s]})}_setSaturation(t,e){let i=0,s=0;t.attributes.hs_color&&(i=parseFloat(t.attributes.hs_color[1]),s=parseFloat(t.attributes.hs_color[0])),("off"===t.state||Math.abs(e-i)>this.step)&&this.hass.callService("light","turn_on",{entity_id:t.entity_id,hs_color:[s,e]})}_setInputNumber(t,e){let i=parseFloat(t.state);this.showMin||(i-=this.min),Math.abs(e-i)>this.step&&this.hass.callService(t.entity_id.split(".")[0],"set_value",{entity_id:t.entity_id,value:e})}_setMediaVolume(t,e){let i=Number(100*this.entity.attributes.volume_level);this.showMin||(i-=this.min),Math.abs(e-i)>this.step&&this.hass.callService("media_player","volume_set",{entity_id:t.entity_id,volume_level:e/100})}_setCover(t,e){this.hass.callService("cover","set_cover_position",{entity_id:t.entity_id,position:e})}_setCoverTilt(t,e){this.hass.callService("cover","set_cover_tilt_position",{entity_id:t.entity_id,tilt_position:e})}_setFan(t,e){this.hass.callService("fan","set_percentage",{entity_id:t.entity_id,percentage:e})}_setSwitch(t,e){var i=Math.min(this.max,this.maxThreshold);Number(i)<=e&&this.hass.callService("homeassistant","toggle",{entity_id:t.entity_id});const s=Number(Math.max(this.zero,this.minThreshold)),n=Lt(Ht(s,this.max));this.setSliderValues(s,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)}_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)),r=Lt(Ht(n,this.max));this.setSliderValues(n,r);const o=this.sliderEl.querySelector(".my-slider-custom-progress");o.style.transition="width 0.2s ease 0s",o.style.width=r.toString()+"%",setTimeout(()=>{o.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,$)}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 It,Ft;t([Z()],Rt.prototype,"_config",void 0),t([Z({attribute:!1})],Rt.prototype,"hass",void 0),t([function(t){return Z({attribute:!1,hasChanged:null==t?void 0:t.hasChanged})}(It)],Rt.prototype,"config",void 0),Rt=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))],Rt);export{Rt as MySliderV2}; + `}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}; diff --git a/dist/my-slider.js b/dist/my-slider.js index 16f44cd..e1f9dd2 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.4 `,"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.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`
this._handleAction(e, this.config)} .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> + hasDoubleClick: this.config?.double_tap_action?.action !== 'none', + hasHold: this.config?.hold_action?.action !== 'none', + })}> ${this.iconElement()} + + ${this.statsElement()}
this._handleAction(e, this.config)} .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> + hasDoubleClick: this.config?.double_tap_action?.action !== 'none', + hasHold: this.config?.hold_action?.action !== 'none', + })}> ${this.labelElement()}
@@ -160,17 +166,17 @@ export class MyButton extends LitElement {
this._handleAction(e, this.config)} .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> + hasDoubleClick: this.config?.double_tap_action?.action !== 'none', + hasHold: this.config?.hold_action?.action !== 'none', + })}> ${this.iconElement()}
this._handleAction(e, this.config)} .actionHandler=${actionHandler({ - hasDoubleClick: this.config?.double_tap_action?.action !== 'none', - hasHold: this.config?.hold_action?.action !== 'none', - })}> + hasDoubleClick: this.config?.double_tap_action?.action !== 'none', + hasHold: this.config?.hold_action?.action !== 'none', + })}> ${this.labelElement()}
@@ -204,7 +210,32 @@ export class MyButton extends LitElement { ` } } - + private statsElement(): TemplateResult { + if (!this.statsConfig.show) return html`` + + if (this.statsConfig.tap_action || this.statsConfig.double_tap_action || this.statsConfig.hold_action) { + return html` +
this._handleAction(e, this.statsConfig)} + .actionHandler=${actionHandler({ + hasDoubleClick: this.statsConfig.double_tap_action?.action !== 'none', + hasHold: this.statsConfig.hold_action?.action !== 'none', + })}> + + ${this.statsConfig.text} + +
+ ` + } + else { + return html` +
+ ${this.statsConfig.text} +
+ ` + } + } + private labelElement(): TemplateResult { if (!this.labelConfig.show) return html`` @@ -215,9 +246,9 @@ export class MyButton extends LitElement {
` @@ -241,7 +272,6 @@ export class MyButton extends LitElement { this.sliderConfig.styles.card.width = this.sliderConfig.styles.card.width ? this.sliderConfig.styles.card.width : '35px' } - //
Slider Goes here...
return html` ` @@ -273,62 +303,129 @@ export class MyButton extends LitElement { } } if (!this._config) return html`Error with this._config...` - + const entityType = this._config.entity.split('.')[0] // ---- Default Icon Config ---- // const defaultIconAttr = { show: true, icon: 'mdi:lightbulb-outline' } - if (this._config.entity.split('.')[0] === 'cover') { + if (entityType === 'cover') { defaultIconAttr.icon = this.entity.attributes?.current_position >= 50 ? 'mdi:blinds-open' : 'mdi:blinds' } + else if (entityType === 'switch') { + defaultIconAttr.icon = this.entity.state === 'on' ? 'mdi:power-plug' : 'mdi:power-plug-off' + } + // ---- Default Label Config ---- // const defaultLabelAttr = { show: true, text: this.entity.attributes.friendly_name } - // ---- Default Slider Config ---- // - const defaultSliderConfig = { - show: true, - entity: this.entity.entity_id, - } - + this.layout = this._config.layout ? this._config.layout : 'vertical' if (this._config.entity.split('.')[0] === 'cover') { this.layout = this._config.layout ? this._config.layout : 'horizontal' } // If icon is just a string, then save that under iconConfig. If it's an object, then combine default with custom configs. If nothing then just use default config - this.iconConfig = typeof this._config.icon === 'string' ? { ...defaultIconAttr, icon: this._config.icon } : typeof this._config.icon === 'object' ? { ...defaultIconAttr, ...this._config.icon } : defaultIconAttr - this.labelConfig = typeof this._config.label === 'string' ? { ...defaultLabelAttr, text: this._config.label } : typeof this._config.label === 'object' ? { ...defaultLabelAttr, ...this._config.label } : defaultLabelAttr - this.sliderConfig = this._config.slider ? { ...defaultSliderConfig, ...this._config.slider } : defaultSliderConfig - - - const deflatedCardStl = deflate(this._config.styles?.card) ? deflate(this._config.styles?.card) : {} - const deflatedContainerStl = deflate(this._config.styles?.container) ? deflate(this._config.styles?.container) : {} - const deflatedContainerColumnStl = deflate(this._config.styles?.containerColumn) ? deflate(this._config.styles?.containerColumn) : {} - const deflatedIconStl = deflate(this._config.styles?.icon) ? deflate(this._config.styles?.icon) : {} - const deflatedLabelWrapperStl = deflate(this._config.styles?.labelWrapper) ? deflate(this._config.styles?.labelWrapper) : {} - const deflatedLabelStl = deflate(this._config.styles?.label) ? deflate(this._config.styles?.label) : {} - const deflatedRow1Stl = deflate(this._config.styles?.row1) ? deflate(this._config.styles?.row1) : {} - const deflatedRow2Stl = deflate(this._config.styles?.row2) ? deflate(this._config.styles?.row2) : {} - const deflatedRow3Stl = deflate(this._config.styles?.row3) ? deflate(this._config.styles?.row3) : {} - const deflatedColumn1Stl = deflate(this._config.styles?.column1) ? deflate(this._config.styles?.column1) : {} - const deflatedColumn2Stl = deflate(this._config.styles?.column2) ? deflate(this._config.styles?.column2) : {} - - - // ---------- Styles ---------- // - this.cardStl = getStyle('card', deflatedCardStl) - this.containerStl = getStyle('container', deflatedContainerStl) - this.containerColumnStl = getStyle('container-column', deflatedContainerColumnStl) - this.iconStl = getStyle('icon', deflatedIconStl) - this.labelWrapperStl = getStyle('label-wrapper', deflatedLabelWrapperStl) - this.labelStl = getStyle('label', deflatedLabelStl) - this.row1Stl = getStyle('row1', deflatedRow1Stl) - this.row2Stl = getStyle('row2', deflatedRow2Stl) - this.row3Stl = getStyle('row3', deflatedRow3Stl) - this.column1Stl = getStyle('column1', deflatedColumn1Stl) - this.column2Stl = getStyle('column2', deflatedColumn2Stl) + this.iconConfig = typeof this._config.icon === 'string' ? { ...defaultIconAttr, icon: this._config.icon } : typeof this._config.icon === 'object' ? deepMerge(defaultIconAttr, this._config.icon) : defaultIconAttr + this.labelConfig = typeof this._config.label === 'string' ? { ...defaultLabelAttr, text: this._config.label } : typeof this._config.label === 'object' ? deepMerge(defaultLabelAttr, this._config.label) : defaultLabelAttr + + const defaultStatsAttr = { + show: this.entity.attributes.brightness ? true : false, + text: this.entity.attributes.brightness && Math.ceil(percentage(this.entity.attributes.brightness, 256)) + } + this.statsConfig = typeof this._config.stats === 'string' ? { ...defaultStatsAttr, text: this._config.stats } : typeof this._config.stats === 'object' ? deepMerge(defaultStatsAttr, this._config.stats) : defaultStatsAttr + + + + const defaultSliderConfig = { + show: true, + entity: this.entity.entity_id, + styles: { + card: [{ + 'border-radius': '0px', + background: 'transparent', + 'box-shadow': 'none', + cursor: 'default', + }], + container: [{ + 'border-radius': '0px', + // 'box-shadow': this.entity.state === 'on' ? '0 0 3px rgba(0,0,0,0.6)' : '0 0 3px rgba(0,0,0,0.3)' + }], + thumb: this.layout === 'vertical' ? [{ + 'height': '20px', + 'width': '3px', + 'top': '6px', + 'right': '2px', + 'border-radius': '50px', + // 'cursor': 'ew-resize' + }] : [{ + 'width': '20px', + 'height': '3px', + 'bottom': '2px', + 'left': '7px', + 'border-radius': '50px', + // 'cursor': 'ns-resize' + }], + track: [{ + background: 'transparent', + }], + progress: this.layout === 'vertical' ? [{ + 'background': 'linear-gradient(to top, var(--paper-item-icon-active-color), transparent)', + }] : [{ + 'background': 'linear-gradient(to left, var(--paper-item-icon-active-color), transparent)', + }] + }, + } + if (entityType === 'switch') { + defaultSliderConfig.show = false + } + this.sliderConfig = this._config.slider ? deepMerge(defaultSliderConfig, this._config.slider) : defaultSliderConfig + + let defaultCardStyle: any[] = [] + if (entityType === 'light') { + if (this.entity.attributes.brightness) { + let divisor = 1 + (this.entity.attributes.brightness / 256); + const cardBg = `radial-gradient(circle at top left, rgba(230, 230, 230, 0.7), var(--card-background-color) ${Math.ceil(percentage(this.entity.attributes.brightness, 256)) / divisor + '%'})` + defaultCardStyle = [ + { 'background': cardBg }, + ] + } + else { + defaultCardStyle = [ + { 'background': `radial-gradient(circle at top left, rgba(230, 230, 230, 0.5), var(--card-background-color) 40%)` }, + ] + } + } + else if (entityType === 'switch') { + const cardBg = this.entity.state === 'on' ? + `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%)` + defaultCardStyle = [ + { 'background': cardBg }, + ] + } + const cardStyle = this._config.styles?.card ? { ...defaultCardStyle, ...this._config.styles.card } : defaultCardStyle; + const defaultIconStyle = [ + { 'color': this.entity.state === 'on' ? 'var(--paper-item-icon-active-color)' : 'var(--paper-item-icon-color)' }, + { 'filter': this.entity.state === 'on' ? 'drop-shadow(2px 2px 2px rgba(0,0,0,0.6)' : 'drop-shadow(3px 3px 2px rgba(0,0,0,0.3)' }, + ] + const iconStyle = this._config.styles?.icon ? { ...defaultIconStyle, ...this._config.styles.icon } : defaultIconStyle; + + // ---------- Styles ---------- // deflate the array of objects to a single object + this.cardStl = getStyle('card', deflate(cardStyle) ? deflate(cardStyle) : {}) + this.containerStl = getStyle('container', deflate(this._config.styles?.container) ? deflate(this._config.styles?.container) : {}) + this.containerColumnStl = getStyle('container-column', deflate(this._config.styles?.containerColumn) ? deflate(this._config.styles?.containerColumn) : {}) + this.iconStl = getStyle('icon', deflate(iconStyle) ? deflate(iconStyle) : {}) + this.statsStl = getStyle('stats', deflate(this._config.styles?.stats) ? deflate(this._config.styles?.stats) : {}) + this.labelWrapperStl = getStyle('label-wrapper', deflate(this._config.styles?.labelWrapper) ? deflate(this._config.styles?.labelWrapper) : {}) + this.labelStl = getStyle('label', deflate(this._config.styles?.label) ? deflate(this._config.styles?.label) : {}) + this.row1Stl = getStyle('row1', deflate(this._config.styles?.row1) ? deflate(this._config.styles?.row1) : {}) + this.row2Stl = getStyle('row2', deflate(this._config.styles?.row2) ? deflate(this._config.styles?.row2) : {}) + this.row3Stl = getStyle('row3', deflate(this._config.styles?.row3) ? deflate(this._config.styles?.row3) : {}) + this.column1Stl = getStyle('column1', deflate(this._config.styles?.column1) ? deflate(this._config.styles?.column1) : {}) + this.column2Stl = getStyle('column2', deflate(this._config.styles?.column2) ? deflate(this._config.styles?.column2) : {}) return null // Success in this case } diff --git a/src/cards/my-slider.ts b/src/cards/my-slider.ts index b6ecaf8..5cc2931 100644 --- a/src/cards/my-slider.ts +++ b/src/cards/my-slider.ts @@ -17,7 +17,6 @@ import { hasConfigOrEntityChanged, LovelaceCard } from 'custom-card-helpers'; // This is a community maintained npm module with common helper functions/types -import { disableBodyScroll, enableBodyScroll } from 'body-scroll-lock' import type { MySliderCardConfig } from './extras/types' import { SLIDER_VERSION } from './extras/const' @@ -42,7 +41,6 @@ console.info( description: 'Custom Slider Card V2 for Lovelace.', }); -// TODONE Name your custom element @customElement('my-slider-v2') export class MySliderV2 extends LitElement { @property() private _config?: MySliderCardConfig @@ -54,7 +52,13 @@ export class MySliderV2 extends LitElement { private touchInput: Boolean = false private disableScroll: Boolean = true private allowTapping: Boolean = true + private allowSliding: Boolean = false + private slideDistance: number = 10 + private marginOfError: number = 10 private thumbTapped: Boolean = false + private isSliding: Boolean = false + private clientXLast: number = 0 + private clientYLast: number = 0 private actionTaken: Boolean = false private vertical: Boolean = false private flipped: Boolean = false @@ -67,6 +71,7 @@ export class MySliderV2 extends LitElement { private minThreshold: number = 0 private maxThreshold: number = 100 private step: number = 1 + private oldVal: number = 0 private sliderVal: number = 0 private sliderValPercent: number = 0.00 private setSliderValues(val, valPercent): void { @@ -188,34 +193,21 @@ export class MySliderV2 extends LitElement { switch (event.type) { case 'mousedown': if (this.touchInput) return - // console.log('MOUSE DOWN:', event) startInput(event) - break - case 'touchstart': this.touchInput = true - // console.log('TOUCH START:', event) startInput(event) break - case 'mousemove': if (this.touchInput) return - // if (this.actionTaken) - // console.log('MOUSE MOVE:', event) - moveInput(event) break - case 'touchmove': if (this.disableScroll) event.preventDefault() - // if (this.actionTaken) - // console.log('TOUCH MOVE:', event) - moveInput(event) break - case 'mouseup': case 'touchend': case 'touchcancel': @@ -227,18 +219,49 @@ export class MySliderV2 extends LitElement { const startInput = (event) => { if (this.actionTaken) return setElements(event) + const clickX = event.clientX || event.touches[0].clientX + const clickY = event.clientY || event.touches[0].clientY + if (this.clientXLast === 0) { + this.clientXLast = clickX + } + if (this.clientYLast === 0) { + this.clientYLast = clickY + } if (this.allowTapping) { this.actionTaken = true this.calcProgress(event) + return } else { - if (event.path[0].classList.contains('my-slider-custom-thumb')) { + const actualTarget = event.composedPath()[0] + const thumbElement = this.shadowRoot?.querySelector('.my-slider-custom-thumb') + if (actualTarget.classList.contains('my-slider-custom-thumb')) { this.thumbTapped = true this.actionTaken = true this.calcProgress(event) - } // else: tapping not allowed + return + } + else if (thumbElement) { + const thumbRect = thumbElement.getBoundingClientRect() + + if (clickX >= thumbRect.left - this.marginOfError && + clickX <= thumbRect.right + this.marginOfError && + clickY >= thumbRect.top - this.marginOfError && + clickY <= thumbRect.bottom + this.marginOfError) { + this.thumbTapped = true + this.actionTaken = true + this.calcProgress(event) + return + } + } + } + if (this.allowSliding) { + this.actionTaken = true } + + this.clientYLast = clickY + this.clientXLast = clickX } const stopInput = (event) => { @@ -249,14 +272,41 @@ export class MySliderV2 extends LitElement { else if (this.thumbTapped) { this.calcProgress(event) } + else if (this.isSliding) { + this.calcProgress(event) + } this.thumbTapped = false this.actionTaken = false this.touchInput = false + this.isSliding = false } const moveInput = event => { if (this.actionTaken) { - this.calcProgress(event) + const clickX = event.clientX || event.touches[0].clientX + const clickY = event.clientY || event.touches[0].clientY + if (this.allowTapping || this.isSliding || + (!this.allowTapping && this.thumbTapped)) { + this.calcProgress(event) + this.clientXLast = clickX + this.clientYLast = clickY + } + else if (this.allowSliding) { + if (!this.vertical) { + if (Math.abs(clickX - this.clientXLast) >= this.slideDistance) { + this.isSliding = true + this.clientXLast = clickX + this.clientYLast = clickY + } + } + else { + if (Math.abs(clickY - this.clientYLast) >= this.slideDistance) { + this.isSliding = true + this.clientXLast = clickX + this.clientYLast = clickY + } + } + } } } @@ -288,15 +338,15 @@ export class MySliderV2 extends LitElement { this._config = this._objectEvalTemplate(this.entity, this.config) } catch (e) { if (e instanceof Error) { - if (e.stack) console.error(e.stack) - else console.error(e) - const errorCard = document.createElement('hui-error-card') as LovelaceCard - errorCard.setConfig({ - type: 'error', - error: e.toString(), - origConfig: this.config, - }) - return errorCard + if (e.stack) console.error(e.stack) + else console.error(e) + const errorCard = document.createElement('hui-error-card') as LovelaceCard + errorCard.setConfig({ + type: 'error', + error: e.toString(), + origConfig: this.config, + }) + return errorCard } else { console.log('Unexpected error evaluating config on init:', e) @@ -311,6 +361,9 @@ export class MySliderV2 extends LitElement { this.inverse = this._config!.inverse !== undefined ? this._config!.inverse : false this.disableScroll = this._config!.disableScroll !== undefined ? this._config!.disableScroll : true this.allowTapping = this._config!.allowTapping !== undefined ? this._config!.allowTapping : true + this.allowSliding = this._config!.allowSliding !== undefined ? this._config!.allowSliding : false + this.marginOfError = this._config!.marginOfError !== undefined ? this._config!.marginOfError : 10 + this.slideDistance = this._config!.slideDistance !== undefined ? this._config!.slideDistance : 10 this.showMin = this._config!.showMin !== undefined ? this._config!.showMin : false this.min = this._config!.min ? this._config!.min : 0 this.max = this._config!.max ? this._config!.max : 100 @@ -323,6 +376,7 @@ export class MySliderV2 extends LitElement { case 'light': /* ------------ LIGHT ------------ */ if (this.colorMode === 'brightness') { + this.oldVal = Math.ceil(percentage(this.entity.attributes.brightness, 256)) if (this.entity.state === 'on') { tmpVal = Math.round(this.entity.attributes.brightness / 2.56) if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left @@ -338,6 +392,7 @@ export class MySliderV2 extends LitElement { 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 tmpVal = parseFloat(this.entity.attributes.color_temp) + this.oldVal = parseFloat(this.entity.attributes.color_temp) if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left this.max = this.max - this.min tmpVal = tmpVal - this.min @@ -348,6 +403,7 @@ export class MySliderV2 extends LitElement { 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]) tmpVal = parseFloat(this.entity.attributes.hs_color[0]) if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left @@ -362,6 +418,7 @@ export class MySliderV2 extends LitElement { // const currentSaturation = parseFloat(entity.attributes.hs_color[1]) 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]) tmpVal = parseFloat(this.entity.attributes.hs_color[1]) if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left @@ -378,6 +435,7 @@ export class MySliderV2 extends LitElement { 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) tmpVal = parseFloat(this.entity.state) if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left this.max = this.max - this.min @@ -393,6 +451,7 @@ export class MySliderV2 extends LitElement { if (this.entity.attributes.volume_level != undefined) { tmpVal = Number(this.entity.attributes.volume_level * 100) } + this.oldVal = tmpVal if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left this.max = this.max - this.min @@ -414,6 +473,7 @@ export class MySliderV2 extends LitElement { tmpVal = Number(this.entity.attributes.current_tilt_position) } } + this.oldVal = tmpVal if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left this.max = this.max - this.min @@ -434,6 +494,7 @@ export class MySliderV2 extends LitElement { if (this.entity.attributes.percentage != undefined) { tmpVal = Number(this.entity.attributes.percentage) } + this.oldVal = tmpVal if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left (sometimes needed, sometimes not. I dont have a fan to test this. Sorry) this.max = this.max - this.min @@ -441,8 +502,6 @@ export class MySliderV2 extends LitElement { } this.setSliderValues(tmpVal, roundPercentage(percentage(tmpVal, this.max))) - - break case 'switch': /* ------------ SWITCH ------------ */ this.minThreshold = this._config!.minThreshold ? this._config!.minThreshold : 15 @@ -456,7 +515,8 @@ export class MySliderV2 extends LitElement { this.minThreshold = this._config!.minThreshold ? this._config!.minThreshold : 15 this.maxThreshold = this._config!.maxThreshold ? this._config!.maxThreshold : 75 tmpVal = Number(Math.max(this.zero, this.minThreshold))// Set slider to larger of 2 minimums - this.setSliderValues(tmpVal,tmpVal) + this.oldVal = tmpVal + this.setSliderValues(tmpVal, tmpVal) break default: @@ -473,7 +533,7 @@ export class MySliderV2 extends LitElement { const sliderWidth = this.sliderEl.offsetWidth const sliderHeight = this.sliderEl.offsetHeight // Calculate what the percentage is of the clickPos.x between 0 and sliderWidth / clickPos.y between 0 and sliderHeight - const clickPercent = this.vertical ? roundPercentage(clickPos.y/sliderHeight * 100) : roundPercentage(clickPos.x/sliderWidth * 100) + const clickPercent = this.vertical ? roundPercentage(clickPos.y / sliderHeight * 100) : roundPercentage(clickPos.x / sliderWidth * 100) const newValue = clickPercent / 100 * (this.max - 0) const flippedValue = this.max - newValue let val = this.flipped ? Math.round(flippedValue) : Math.round(newValue) @@ -484,6 +544,10 @@ export class MySliderV2 extends LitElement { private setProgress(slider, val, action) { const progressEl = slider.querySelector('.my-slider-custom-progress') + + // Round val to nearest step + val = Math.round(val / this.step) * this.step + const valuePercentage = roundPercentage(percentage(val, this.max)) if (this.vertical) { // Set progessHeight to match value @@ -497,10 +561,8 @@ export class MySliderV2 extends LitElement { // Check if value has changed if (this.sliderVal !== val) { // Check if we should update entity on mousemove or mouseup - if (this._config!.intermediate && (action === 'mousemove' || action === 'touchmove')) { - this.setValue(val, valuePercentage) - } - else if (!this._config!.intermediate && (action === 'mouseup' || action === 'touchend' || action === 'touchcancel')) { + if ((this._config!.intermediate && (action === 'mousemove' || action === 'mousedown' || action === 'touchmove' || action === 'touchstart')) || + (!this._config!.intermediate && (action === 'mouseup' || action === 'touchend' || action === 'touchcancel'))) { this.setValue(val, valuePercentage) } } @@ -563,27 +625,21 @@ export class MySliderV2 extends LitElement { } private _setBrightness(entity, value): void { - if (entity.state === 'off' || (Math.abs((value - Math.round(entity.attributes.brightness / 2.56))) > this.step)) { - this.hass.callService("light", "turn_on", { - entity_id: entity.entity_id, - brightness: value * 2.56 - }) - } + this.hass.callService("light", "turn_on", { + entity_id: entity.entity_id, + brightness: value * 2.56 + }) + this.oldVal = value } - private _setColorTemp(entity, value): void { + private _setColorTemp(entity, value): void { let oldVal = parseFloat(entity.attributes.color_temp) - // // Do not ask me why this is not needed here. In my mind it should be required, but it's off by that much when subtracting. (Should not code with corona) - // if (!this.showMin) { - // oldVal = oldVal - this.min // Subtracting savedMin to make slider 0 be far left - // } - - if (entity.state === 'off' || isNaN(oldVal) || Math.abs((value - oldVal)) > this.step) { - this.hass.callService("light", "turn_on", { - entity_id: entity.entity_id, - color_temp: value - }) - } - } + this.hass.callService("light", "turn_on", { + entity_id: entity.entity_id, + color_temp: value + }) + this.oldVal = value + + } private _setHue(entity, value): void { let oldVal = 0 let currentSaturation = 0 @@ -591,12 +647,11 @@ export class MySliderV2 extends LitElement { oldVal = parseFloat(entity.attributes.hs_color[0]) currentSaturation = parseFloat(entity.attributes.hs_color[1]) } - if (entity.state === 'off' || Math.abs((value - oldVal)) > this.step) { - this.hass.callService("light", "turn_on", { - entity_id: entity.entity_id, - hs_color: [value, currentSaturation] - }) - } + this.hass.callService("light", "turn_on", { + entity_id: entity.entity_id, + hs_color: [value, currentSaturation] + }) + this.oldVal = value } private _setSaturation(entity, value): void { let oldVal = 0 @@ -605,88 +660,90 @@ export class MySliderV2 extends LitElement { oldVal = parseFloat(entity.attributes.hs_color[1]) currentHue = parseFloat(entity.attributes.hs_color[0]) } - if (entity.state === 'off' || Math.abs((value - oldVal)) > this.step) { - this.hass.callService("light", "turn_on", { - entity_id: entity.entity_id, - hs_color: [currentHue, value] - }) - } + this.hass.callService("light", "turn_on", { + entity_id: entity.entity_id, + hs_color: [currentHue, value] + }) + this.oldVal = value } - private _setInputNumber(entity, value): void { + private _setInputNumber(entity, value): void { let oldVal = parseFloat(entity.state) if (!this.showMin) { oldVal = oldVal - this.min // Subtracting savedMin to make slider 0 be far left } - if (Math.abs((value - oldVal)) > this.step) { - this.hass.callService(entity.entity_id.split('.')[0], "set_value", { // either "input_number" or "number" - entity_id: entity.entity_id, - value: value - }) - } - } - private _setMediaVolume(entity, value): void { + this.hass.callService(entity.entity_id.split('.')[0], "set_value", { // either "input_number" or "number" + entity_id: entity.entity_id, + value: value + }) + this.oldVal = value + } + private _setMediaVolume(entity, value): void { let oldVal = Number(this.entity!.attributes.volume_level * 100) if (!this.showMin) { // Subtracting savedMin to make slider 0 be far left oldVal = oldVal - this.min } - // TODO: This will be false if entity is off. Set volume even when off/not playing/idle? (whatever states to check for?) - if (Math.abs((value - oldVal)) > this.step) { - this.hass.callService("media_player", "volume_set", { - entity_id: entity.entity_id, - volume_level: value / 100 - }) - } - } - private _setCover(entity, value): void { - this.hass.callService("cover", "set_cover_position", { - entity_id: entity.entity_id, - position: value - }); - } + this.hass.callService("media_player", "volume_set", { + entity_id: entity.entity_id, + volume_level: value / 100 + }) + this.oldVal = value + } + private _setCover(entity, value): void { + this.hass.callService("cover", "set_cover_position", { + entity_id: entity.entity_id, + position: value + }) + this.oldVal = value + } private _setCoverTilt(entity, value): void { this.hass.callService("cover", "set_cover_tilt_position", { entity_id: entity.entity_id, tilt_position: value - }); + }) + this.oldVal = value } - private _setFan(entity, value): void { - this.hass.callService("fan", "set_percentage", { - entity_id: entity.entity_id, - percentage: value - }) - } - - private _setSwitch(entity, value): void { - var threshold = Math.min(this.max, this.maxThreshold) //pick lesser of the two - if (Number(threshold) <= value) { - this.hass.callService('homeassistant', 'toggle', { - entity_id: entity.entity_id - }) - } + private _setFan(entity, value): void { + this.hass.callService("fan", "set_percentage", { + entity_id: entity.entity_id, + percentage: value + }) + this.oldVal = value + } + + private _setSwitch(entity, value): void { + var threshold = Math.min(this.max, this.maxThreshold) //pick lesser of the two + if (Number(threshold) <= value) { + this.hass.callService('homeassistant', 'toggle', { + entity_id: entity.entity_id + }) + this.oldVal = value + } const val = Number(Math.max(this.zero, this.minThreshold)) const valPercent = roundPercentage(percentage(val, this.max)) this.setSliderValues(val, valPercent) // Set slider to larger of 2 minimums const progressEl: HTMLElement | null = this.sliderEl!.querySelector('.my-slider-custom-progress') - progressEl!.style.transition = 'width 0.2s ease 0s' // Make it sprong back nicely + + const currentTransition = progressEl!.style.transition + progressEl!.style.transition = !this.vertical ? 'width 0.2s ease 0s' : 'height 0.2s ease 0s' // Make it spring back nicely progressEl!.style.width = valPercent.toString() + '%' setTimeout(() => { // Remove transition when done - progressEl!.style.transition = 'initial' + progressEl!.style.transition = currentTransition }, 200) - } - private _setLock(entity, value): void { - var threshold = Math.min(this.max, this.maxThreshold) //pick lesser of the two - if (Number(threshold) <= value) { - var newLockState = entity.state === "locked" ? 'unlock' : 'lock' - this.hass.callService("lock", newLockState, { - entity_id: entity.entity_id - }) - } + } + private _setLock(entity, value): void { + var threshold = Math.min(this.max, this.maxThreshold) //pick lesser of the two + if (Number(threshold) <= value) { + var newLockState = entity.state === "locked" ? 'unlock' : 'lock' + this.hass.callService("lock", newLockState, { + entity_id: entity.entity_id + }) + } const val = Number(Math.max(this.zero, this.minThreshold)) const valPercent = roundPercentage(percentage(val, this.max)) @@ -697,7 +754,7 @@ export class MySliderV2 extends LitElement { setTimeout(() => { // Remove transition when done progressEl!.style.transition = 'initial' }, 200) - } + } private createAndCleanupEventListeners(func): void { document.removeEventListener("mouseup", func) @@ -777,10 +834,10 @@ export class MySliderV2 extends LitElement { e.message = `${e.name}: ${e.message} in '${funcTrimmed}'`; e.name = 'MyCardJSTemplateError'; throw e; - } - else { - console.log('Unexpected error (_evalTemplate)', e); - } + } + else { + console.log('Unexpected error (_evalTemplate)', e); + } } } @@ -798,7 +855,7 @@ entity: light.sofa_spots colorMode: 'brightness' (Can be 'brightness', 'temperature', 'hue', 'saturation') coverMode: 'position' (Accept: 'position', 'tilt') // warmth: false (Will be removed now!) -vertical: false (This will set the vertical to be vertical and handled from bottom to top. Automatically used on covers) +vertical: false (This will set the slider to be vertical and handled from bottom to top. Automatically used on covers) flipped: false (This will just flip the slider to go from right to left or top to bottom. Automatically used on covers) inverse: false (Will inverse how far the slider has progressed compared to value. so if brightness is 75%, then it will only be 25% progressed. This is useful for cover, where it is automatically used.) min: 0 diff --git a/src/cards/styles/my-button.styles.ts b/src/cards/styles/my-button.styles.ts index 471c947..801214c 100644 --- a/src/cards/styles/my-button.styles.ts +++ b/src/cards/styles/my-button.styles.ts @@ -1,133 +1,128 @@ -export const getStyle = (e:string, style:any = {}) => { - switch (e) { - case 'card': - return cardStyle(style) - case 'icon': - return iconStyle(style) - case 'label-wrapper': - return labelWrapperStyle(style) - case 'label': - return labelStyle(style) - case 'container': - return containerStyle(style) - case 'container-column': - return containerColumnStyle(style) - case 'row1': - return row1Style(style) - case 'row2': - return row2Style(style) - case 'row3': - return row3Style(style) - case 'column1': - return column1Style(style) - case 'column2': - return column2Style(style) - default: - console.log('Getting default styles') - return +export const getStyle = (e: string, styleToMerge: any = {}) => { + const style = styles[e] + if (style) { + return style(styleToMerge) + } else { + console.log(`${e}: Not found in styles`) + return } } -const cardStyle = (style:any) => { - return { - height: '125px', - width: '100%', - 'min-width': 'fit-content', - background: 'var(--card-background-color)', - ...style - } -} - -const iconStyle = (style:any) => { - return { - '--mdc-icon-size': '100%', - height: '35px', - width: '35px', - display: 'inline-block', - padding: '10px 10px 10px 10px', - cursor: 'pointer', - color: 'var(--paper-item-active-icon-color)', - ...style - } -} - -const labelWrapperStyle = (style:any) => { - return { - width: '100%', - height: '100%', - display: 'flex', - // // 'flex-direction': 'column', /* align children vertically (column format) */ - // 'justify-content': 'center', /* center children vertically */ - // 'align-items': 'center', /* center column horizontally */ - // // 'padding-left': '10px', - ...style - } -} - -const labelStyle = (style:any) => { - return { - padding: '0', - margin: '0 10px', - color: 'var(--primary-text-color)', - 'font-weight': 'bold', - ...style - } -} - -// Vertical Layout -const containerStyle = (style:any) => { - return { - padding: '0', - margin: '0', - display: 'flex', - 'flex-flow': 'column', - height: '100%', - ...style - } -} - -const row1Style = (style:any) => { - return { - flex: '0 1 auto', - ...style - } -} - -const row2Style = (style:any) => { - return { - flex: '1 1 auto', - ...style - } -} -const row3Style = (style:any) => { - return { - flex: '0 1 auto', - margin: '0 2px 2px 2px', - ...style - } -} - -// Horizontal Style -const containerColumnStyle = (style:any) => { - return { - padding: '0', - margin: '0', - display: 'flex', - 'flex-flow': 'row', - height: '100%', - ...style - } -} -const column1Style = (style:any) => { - return { - flex: '1', - ...style - } -} -const column2Style = (style:any) => { - return { - flex: '0', - padding: '3px 3px 3px 0', - ...style +const styles = { + card: (style: any) => { + return { + height: '125px', + width: '100%', + 'min-width': 'fit-content', + background: 'var(--card-background-color)', + overflow: 'hidden', + cursor: 'pointer', + ...style + } + }, + icon: (style: any) => { + return { + '--mdc-icon-size': '100%', + height: '35px', + width: '35px', + display: 'inline-block', + padding: '10px 0 0 10px', + color: 'var(--paper-item-icon-color)', + ...style + } + }, + stats: (style: any) => { + return { + 'margin-left': 'auto', + 'margin-right': '5px', + 'margin-top': '5px', + 'margin-bottom': '5px', + 'color': 'var(--primary-text-color)', + // 'border-radius': '50%', + 'display': 'grid', + 'place-items': 'center', + 'aspect-ratio': '1 / 1', + // 'box-shadow': '0px 0px 10px 0px rgba(0,0,0,0.75)', + 'font-family': '"Arial", sans-serif', + 'font-size': '11px', + 'text-align': 'center', + 'text-shadow': '2px 2px 4px rgba(0, 0, 0, 0.5)', + // 'transform': 'scale(0.9)', + ...style + } + }, + 'label-wrapper': (style: any) => { + return { + width: '100%', + height: '100%', + display: 'flex', + // // 'flex-direction': 'column', /* align children vertically (column format) */ + // 'justify-content': 'center', /* center children vertically */ + // 'align-items': 'center', /* center column horizontally */ + // // 'padding-left': '10px', + ...style + } + }, + label: (style: any) => { + return { + padding: '0', + margin: '0 10px', + color: 'var(--primary-text-color)', + 'font-weight': 'bold', + cursor: 'pointer', + ...style + } + }, + container: (style: any) => { + return { + padding: '0', + margin: '0', + display: 'flex', + 'flex-flow': 'column', + height: '100%', + ...style + } + }, + row1: (style: any) => { + return { + flex: '0 1 auto', + display: 'flex', + 'justify-content': 'space-between', + ...style + } + }, + row2: (style: any) => { + return { + flex: '1 1 auto', + ...style + } + }, + row3: (style: any) => { + return { + flex: '0 1 auto', + ...style + } + }, + 'container-column': (style: any) => { + return { + padding: '0', + margin: '0', + display: 'flex', + 'flex-flow': 'row', + height: '100%', + ...style + } + }, + column1: (style: any) => { + return { + flex: '1', + ...style + } + }, + column2: (style: any) => { + return { + flex: '0', + ...style + } } } \ No newline at end of file diff --git a/src/cards/styles/my-slider.styles.ts b/src/cards/styles/my-slider.styles.ts index 506c535..6f83ae0 100644 --- a/src/cards/styles/my-slider.styles.ts +++ b/src/cards/styles/my-slider.styles.ts @@ -1,69 +1,59 @@ -export const getStyle = (e:string, style:any = {}) => { - switch (e) { - case 'card': - return cardStyle(style) - case 'container': - return containerStyle(style) - case 'track': - return trackStyle(style) - case 'progress': - return progressStyle(style) - case 'thumb': - return thumbStyle(style) - default: - console.log('Getting default styles') - return +export const getStyle = (e: string, styleToMerge: any = {}) => { + const style = styles[e] + if (style) { + return style(styleToMerge) + } else { + console.log(`${e}: Not found in styles`) + return } } -const cardStyle = (style:any) => { - return { - // ...(style.backgroundColor && {backgroundColor: style.backgroundColor}), - height: '30px', - ...style - } -} - -const containerStyle = (style:any) => { - return { - width: '100%', - height: '100%', - position: 'relative', - overflow: 'hidden', - 'border-radius': '5px', - ...style - } -} - -const trackStyle = (style:any) => { - return { - width: '100%', - height: '100%', - position: 'relative', - background: 'var(--card-background-color)', - ...style - } -} - -const progressStyle = (style:any) => { - return { - height: '100%', - background: 'var(--paper-item-icon-active-color)', - position: 'absolute', - width: '0.00%', - //'pointer-events': 'none', - ...style - } -} - -const thumbStyle = (style:any) => { - return { - height: '100%', - background: 'black', - position: 'absolute', - right: '-5px', - width: '10px', - //'pointer-events': 'none', - ...style +const styles = { + card: (style:any) => { + return { + // ...(style.backgroundColor && {backgroundColor: style.backgroundColor}), + height: '30px', + ...style + } + }, + container: (style:any) => { + return { + width: '100%', + height: '100%', + position: 'relative', + overflow: 'hidden', + 'border-radius': '5px', + ...style + } + }, + track: (style:any) => { + return { + width: '100%', + height: '100%', + position: 'relative', + background: 'var(--card-background-color)', + ...style + } + }, + progress: (style:any) => { + return { + height: '100%', + background: 'var(--paper-item-icon-active-color)', + position: 'absolute', + width: '0.00%', + //'pointer-events': 'none', + ...style + } + }, + thumb: (style:any) => { + return { + height: '100%', + background: 'black', + position: 'absolute', + right: '-5px', + width: '10px', + //'pointer-events': 'none', + ...style + } } } \ No newline at end of file diff --git a/src/scripts/helpers.ts b/src/scripts/helpers.ts index 084cb19..2e635e6 100644 --- a/src/scripts/helpers.ts +++ b/src/scripts/helpers.ts @@ -1,8 +1,4 @@ export const percentage = (val, max = 100, min = 0) => { - // console.log('Finding percentage of value:', val) - // console.log('Min:', min) - // console.log('Max:', max) - // console.log('Test:', (max-min)) return val / (max - min) * 100 } @@ -50,3 +46,45 @@ export const camelToKebab = str => { : letter; }).join(''); } + + +export function deepMerge(target: any, source: any) { + const output = Object.assign({}, target); + if (isObject(target) && isObject(source)) { + Object.keys(source).forEach(key => { + if (Array.isArray(source[key])) { + output[key] = source[key].map((item, index) => { + if (target[key] && isObject(target[key][index]) && isObject(item)) { + return deepMerge(target[key][index], item); + } else { + return item; + } + }); + } else if (isObject(source[key])) { + if (!(key in target)) + Object.assign(output, { [key]: source[key] }); + else + output[key] = deepMerge(target[key], source[key]); + } else { + Object.assign(output, { [key]: source[key] }); + } + }); + } + return output; +} + +export function arrayToObject(styleArray: any[]) { + return styleArray.reduce((styleObject, style) => { + const [key, value] = Object.entries(style)[0]; + styleObject[key] = value; + return styleObject; + }, {}); +} + +export function objectToArray(styleObject: any) { + return Object.entries(styleObject).map(([key, value]) => ({ [key]: value })); +} + +export function isObject(item: any) { + return (item && typeof item === 'object' && !Array.isArray(item)); +} \ No newline at end of file