diff --git a/dist/big-slider-card.js b/dist/big-slider-card.js
index cf17500..a0199f8 100644
--- a/dist/big-slider-card.js
+++ b/dist/big-slider-card.js
@@ -1,684 +1,65 @@
-/******************************************************************************
-Copyright (c) Microsoft Corporation.
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
-REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
-AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
-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.
-***************************************************************************** */
-/* global Reflect, Promise, SuppressedError, Symbol */
-
-
-function __decorate(decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
-}
-
-typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
- var e = new Error(message);
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
-};
-
-class SlideGesture {
- #el;
- #touchActions;
- #startX = 0;
- #startY = 0;
- #lastTotalX = 0;
- #lastTotalY = 0;
- #callback;
- #shouldPreventScroll = false
- #stopScrollDirection;
- #boundHandleScroll;
- #boundHandleEvt;
-
- constructor(el, callback, { touchActions, stopScrollDirection } = {}){
- this.#el = el;
- this.#touchActions = touchActions;
- this.#callback = callback;
- this.#stopScrollDirection = stopScrollDirection;
- this.#boundHandleScroll = this.#handleScroll.bind(this);
- this.#boundHandleEvt = this.#handleEvt.bind(this);
- this.addListeners();
- }
-
- addListeners() {
- this.#el.addEventListener("pointerdown", this.#boundHandleEvt);
- this.#el.addEventListener("pointermove", this.#boundHandleEvt);
- this.#el.addEventListener("pointerup", this.#boundHandleEvt);
- this.#el.addEventListener("pointercancel", this.#boundHandleEvt);
- window.addEventListener("touchmove", this.#boundHandleScroll, {passive:false});
- if(this.#touchActions) this.#el.style.touchAction = this.#touchActions;
- }
-
- removeListeners() {
- this.#el.removeEventListener("pointerdown", this.#boundHandleEvt);
- this.#el.removeEventListener("pointermove", this.#boundHandleEvt);
- this.#el.removeEventListener("pointerup", this.#boundHandleEvt);
- this.#el.removeEventListener("pointercancel", this.#boundHandleEvt);
- window.removeEventListener("touchmove", this.#boundHandleScroll);
- if(this.#touchActions) this.#el.style.touchAction = null;
- }
-
- #preventTouchScroll() {
- this.#shouldPreventScroll = true;
- }
-
- #allowTouchScroll() {
- this.#shouldPreventScroll = false;
- }
-
- #handleScroll(evt) {
- if(this.#shouldPreventScroll){
- evt.preventDefault();
- }
- }
-
- #handleEvt(evt) {
- if (evt.type === 'pointerdown') {
- this.#el.setPointerCapture(evt.pointerId);
- this.#startX = evt.pageX;
- this.#startY = evt.pageY;
- }
-
- if (this.#el.hasPointerCapture(evt.pointerId) && evt.type !== 'pointercancel' && (typeof this.#callback) === 'function') {
- const relativeX = evt.pageX - this.#startX;
- const relativeY = evt.pageY - this.#startY;
-
- if ( this.#stopScrollDirection === 'horizontal' && Math.abs(relativeX / relativeY) > 1 ) {
- this.#preventTouchScroll();
- }
- if ( this.#stopScrollDirection === 'vertical' && Math.abs(relativeX / relativeY) < 1 ) {
- this.#preventTouchScroll();
- }
-
- this.#callback(evt, {
- startX: this.#startX,
- startY: this.#startY,
- relativeX,
- relativeY,
- totalX: relativeX + this.#lastTotalX,
- totalY: relativeY + this.#lastTotalY,
- });
- }
-
- if (evt.type === 'pointerup') {
- this.#lastTotalX = + this.#lastTotalX + evt.pageX - this.#startX;
- this.#lastTotalY = + this.#lastTotalY + evt.pageY - this.#startY;
- this.#el.releasePointerCapture(evt.pointerId);
- this.#allowTouchScroll();
- }
-
- if (evt.type === 'pointercancel') {
- this.#callback(evt, {
- startX: this.#startX,
- startY: this.#startY,
- relativeX: 0,
- relativeY: 0,
- totalX: this.#lastTotalX,
- totalY: this.#lastTotalY,
- });
- this.#el.releasePointerCapture(evt.pointerId);
- this.#allowTouchScroll();
- }
- }
-}
-
-const CARD_VERSION = '1.1.3';
-const DEFAULT_ATTRIBUTE = 'brightness';
-const SETTLE_TIME = 3000;
-const HOLD_TIME = 600;
-const MIN_SLIDE_TIME = 0;
-const TAP_THRESHOLD = 5;
-const MIN = 0;
-const MAX = 100;
-const DEFAULT_CONFIG = {
- type: 'custom:big-slider-card',
- attribute: DEFAULT_ATTRIBUTE,
- tap_action: {
- action: 'toggle',
- haptic: 'light',
- },
- hold_action: {
- action: 'more-info',
- },
- hold_time: HOLD_TIME,
- settle_time: SETTLE_TIME,
- min_slide_time: MIN_SLIDE_TIME,
- min: MIN,
- max: MAX,
-};
-
-var common$1 = {
- version: "Version",
- invalid_configuration: "Invalid configuration",
- show_warning: "Show Warning",
- no_entity_set: "Entity not set",
- no_entity: "Entity not available",
- on: "On",
- off: "Off"
-};
-var en = {
- common: common$1
-};
-
-var en$1 = /*#__PURE__*/Object.freeze({
- __proto__: null,
- common: common$1,
- default: en
-});
-
-var common = {
- version: "Versiunea",
- invalid_configuration: "Configurație invalidă",
- show_warning: "Show Warning",
- no_entity_set: "Entitatea nu e setată",
- no_entity: "Entitatea nu e disponibilă",
- on: "Pornit",
- off: "Oprit"
-};
-var ro = {
- common: common
-};
-
-var ro$1 = /*#__PURE__*/Object.freeze({
- __proto__: null,
- common: common,
- default: ro
-});
-
-// eslint-disable-next-line @typescript-eslint/no-explicit-any
-const languages = {
- en: en$1,
- ro: ro$1,
-};
-function localize(string, search = '', replace = '') {
- const lang = (localStorage.getItem('selectedLanguage') || 'en').replace(/['"]+/g, '').replace('-', '_');
- let translated;
- try {
- translated = string.split('.').reduce((o, i) => o[i], languages[lang]);
- }
- catch (e) {
- translated = string.split('.').reduce((o, i) => o[i], languages['en']);
- }
- if (translated === undefined)
- translated = string.split('.').reduce((o, i) => o[i], languages['en']);
- if (search !== '' && replace !== '') {
- translated = translated.replace(search, replace);
- }
- return translated;
-}
-
+function t(t,e,i,s){var o,r=arguments.length,n=r<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,s);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(n=(r<3?o(n):r>3?o(e,i,n):o(e,i))||n);return r>3&&n&&Object.defineProperty(e,i,n),n}"function"==typeof SuppressedError&&SuppressedError;class e{#t;#e;#i=0;#s=0;#o=0;#r=0;#n;#l=!1;#a;#h;#c;constructor(t,e,{touchActions:i,stopScrollDirection:s}={}){this.#t=t,this.#e=i,this.#n=e,this.#a=s,this.#h=this.#d.bind(this),this.#c=this.#u.bind(this),this.addListeners()}addListeners(){this.#t.addEventListener("pointerdown",this.#c),this.#t.addEventListener("pointermove",this.#c),this.#t.addEventListener("pointerup",this.#c),this.#t.addEventListener("pointercancel",this.#c),window.addEventListener("touchmove",this.#h,{passive:!1}),this.#e&&(this.#t.style.touchAction=this.#e)}removeListeners(){this.#t.removeEventListener("pointerdown",this.#c),this.#t.removeEventListener("pointermove",this.#c),this.#t.removeEventListener("pointerup",this.#c),this.#t.removeEventListener("pointercancel",this.#c),window.removeEventListener("touchmove",this.#h),this.#e&&(this.#t.style.touchAction=null)}#p(){this.#l=!0}#v(){this.#l=!1}#d(t){this.#l&&t.preventDefault()}#u(t){if("pointerdown"===t.type&&(this.#t.setPointerCapture(t.pointerId),this.#i=t.pageX,this.#s=t.pageY),this.#t.hasPointerCapture(t.pointerId)&&"pointercancel"!==t.type&&"function"==typeof this.#n){const e=t.pageX-this.#i,i=t.pageY-this.#s;"horizontal"===this.#a&&Math.abs(e/i)>1&&this.#p(),"vertical"===this.#a&&Math.abs(e/i)<1&&this.#p(),this.#n(t,{startX:this.#i,startY:this.#s,relativeX:e,relativeY:i,totalX:e+this.#o,totalY:i+this.#r})}"pointerup"===t.type&&(this.#o=+this.#o+t.pageX-this.#i,this.#r=+this.#r+t.pageY-this.#s,this.#t.releasePointerCapture(t.pointerId),this.#v()),"pointercancel"===t.type&&(this.#n(t,{startX:this.#i,startY:this.#s,relativeX:0,relativeY:0,totalX:this.#o,totalY:this.#r}),this.#t.releasePointerCapture(t.pointerId),this.#v())}}const i={type:"custom:big-slider-card",attribute:"brightness",tap_action:{action:"toggle",haptic:"light"},hold_action:{action:"more-info"},hold_time:600,settle_time:3e3,min_slide_time:0,min:0,max:100};var s={version:"Version",invalid_configuration:"Invalid configuration",show_warning:"Show Warning",no_entity_set:"Entity not set",no_entity:"Entity not available",on:"On",off:"Off"},o={common:s},r={version:"Versiunea",invalid_configuration:"Configurație invalidă",show_warning:"Show Warning",no_entity_set:"Entitatea nu e setată",no_entity:"Entitatea nu e disponibilă",on:"Pornit",off:"Oprit"},n={common:r};const l={en:Object.freeze({__proto__:null,common:s,default:o}),ro:Object.freeze({__proto__:null,common:r,default:n})};function a(t,e="",i=""){const s=(localStorage.getItem("selectedLanguage")||"en").replace(/['"]+/g,"").replace("-","_");let o;try{o=t.split(".").reduce(((t,e)=>t[e]),l[s])}catch(e){o=t.split(".").reduce(((t,e)=>t[e]),l.en)}return void 0===o&&(o=t.split(".").reduce(((t,e)=>t[e]),l.en)),""!==e&&""!==i&&(o=o.replace(e,i)),o}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
- */
-const i$2=(i,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(n){n.createProperty(e.key,i);}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this));},finisher(n){n.createProperty(e.key,i);}},e$3=(i,e,n)=>{e.constructor.createProperty(n,i);};function n$5(n){return (t,o)=>void 0!==o?e$3(n,t,o):i$2(n,t)}
-
+ */const h=(t,e)=>"method"===e.kind&&e.descriptor&&!("value"in e.descriptor)?{...e,finisher(i){i.createProperty(e.key,t)}}:{kind:"field",key:Symbol(),placement:"own",descriptor:{},originalKey:e.key,initializer(){"function"==typeof e.initializer&&(this[e.key]=e.initializer.call(this))},finisher(i){i.createProperty(e.key,t)}},c=(t,e,i)=>{e.constructor.createProperty(i,t)};
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
- */function t$2(t){return n$5({...t,state:!0})}
-
+ */
+function d(t){return function(t){return(e,i)=>void 0!==i?c(t,e,i):h(t,e)}({...t,state:!0})}
/**
* @license
* Copyright 2021 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
- */var n$4;null!=(null===(n$4=window.HTMLSlotElement)||void 0===n$4?void 0:n$4.prototype.assignedElements)?(o,n)=>o.assignedElements(n):(o,n)=>o.assignedNodes(n).filter((o=>o.nodeType===Node.ELEMENT_NODE));
-
-/**
- * @license
- * Copyright 2017 Google LLC
- * SPDX-License-Identifier: BSD-3-Clause
- */
-var t$1;const i$1=window,s$3=i$1.trustedTypes,e$2=s$3?s$3.createPolicy("lit-html",{createHTML:t=>t}):void 0,o$3="$lit$",n$3=`lit$${(Math.random()+"").slice(9)}$`,l$3="?"+n$3,h$1=`<${l$3}>`,r$2=document,u$1=()=>r$2.createComment(""),d$1=t=>null===t||"object"!=typeof t&&"function"!=typeof t,c$1=Array.isArray,v=t=>c$1(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]),a$1="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,_=/-->/g,m=/>/g,p=RegExp(`>|${a$1}(?:([^\\s"'>=/]+)(${a$1}*=${a$1}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),g=/'/g,$=/"/g,y=/^(?:script|style|textarea|title)$/i,w=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=w(1),T=Symbol.for("lit-noChange"),A=Symbol.for("lit-nothing"),E=new WeakMap,C=r$2.createTreeWalker(r$2,129,null,!1);function P(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==e$2?e$2.createHTML(i):i}const V=(t,i)=>{const s=t.length-1,e=[];let l,r=2===i?"":"")),e]};class N{constructor({strings:t,_$litType$:i},e){let h;this.parts=[];let r=0,d=0;const c=t.length-1,v=this.parts,[a,f]=V(t,i);if(this.el=N.createElement(a,e),C.currentNode=this.el.content,2===i){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes);}for(;null!==(h=C.nextNode())&&v.length0){h.textContent=s$3?s$3.emptyScript:"";for(let s=0;s2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=A;}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const o=this.strings;let n=!1;if(void 0===o)t=S$1(this,t,i,0),n=!d$1(t)||t!==this._$AH&&t!==T,n&&(this._$AH=t);else {const e=t;let l,h;for(t=o[0],l=0;l{var e,o;const n=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:i;let l=n._$litPart$;if(void 0===l){const t=null!==(o=null==s?void 0:s.renderBefore)&&void 0!==o?o:null;n._$litPart$=l=new R(i.insertBefore(u$1(),t),t,void 0,null!=s?s:{});}return l._$AI(t),l};
-
+ */var u,p;null===(u=window.HTMLSlotElement)||void 0===u||u.prototype.assignedElements;const v=window,_=v.trustedTypes,g=_?_.createPolicy("lit-html",{createHTML:t=>t}):void 0,f="$lit$",b=`lit$${(Math.random()+"").slice(9)}$`,m="?"+b,y=`<${m}>`,$=document,A=()=>$.createComment(""),E=t=>null===t||"object"!=typeof t&&"function"!=typeof t,S=Array.isArray,w="[ \t\n\f\r]",T=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,x=/-->/g,P=/>/g,C=RegExp(`>|${w}(?:([^\\s"'>=/]+)(${w}*=${w}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),k=/'/g,H=/"/g,U=/^(?:script|style|textarea|title)$/i,M=(t=>(e,...i)=>({_$litType$:t,strings:e,values:i}))(1),O=Symbol.for("lit-noChange"),R=Symbol.for("lit-nothing"),L=new WeakMap,N=$.createTreeWalker($,129,null,!1);function V(t,e){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==g?g.createHTML(e):e}const D=(t,e)=>{const i=t.length-1,s=[];let o,r=2===e?"":"")),s]};class I{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,r=0;const n=t.length-1,l=this.parts,[a,h]=D(t,e);if(this.el=I.createElement(a,i),N.currentNode=this.el.content,2===e){const t=this.el.content,e=t.firstChild;e.remove(),t.append(...e.childNodes)}for(;null!==(s=N.nextNode())&&l.length0){s.textContent=_?_.emptyScript:"";for(let i=0;iS(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]))(t)?this.T(t):this._(t)}k(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}$(t){this._$AH!==t&&(this._$AR(),this._$AH=this.k(t))}_(t){this._$AH!==R&&E(this._$AH)?this._$AA.nextSibling.data=t:this.$($.createTextNode(t)),this._$AH=t}g(t){var e;const{values:i,_$litType$:s}=t,o="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=I.createElement(V(s.h,s.h[0]),this.options)),s);if((null===(e=this._$AH)||void 0===e?void 0:e._$AD)===o)this._$AH.v(i);else{const t=new z(o,this),e=t.u(this.options);t.v(i),this.$(e),this._$AH=t}}_$AC(t){let e=L.get(t.strings);return void 0===e&&L.set(t.strings,e=new I(t)),e}T(t){S(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new B(this.k(A()),this.k(A()),this,this.options)):i=e[s],i._$AI(o),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=R}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,e=this,i,s){const o=this.strings;let r=!1;if(void 0===o)t=j(this,t,e,0),r=!E(t)||t!==this._$AH&&t!==O,r&&(this._$AH=t);else{const s=t;let n,l;for(t=o[0],n=0;nnull!=l?l:A;
-
-/**
- * @license
- * Copyright 2019 Google LLC
- * SPDX-License-Identifier: BSD-3-Clause
- */
-const t=window,e$1=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),n$2=new WeakMap;let o$2 = class o{constructor(t,e,n){if(this._$cssResult$=!0,n!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$1&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=n$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&n$2.set(s,t));}return t}toString(){return this.cssText}};const r$1=t=>new o$2("string"==typeof t?t:t+"",void 0,s$2),i=(t,...e)=>{const n=1===t.length?t[0]:e.reduce(((e,s,n)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[n+1]),t[0]);return new o$2(n,t,s$2)},S=(s,n)=>{e$1?s.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((e=>{const n=document.createElement("style"),o=t.litNonce;void 0!==o&&n.setAttribute("nonce",o),n.textContent=e.cssText,s.appendChild(n);}));},c=e$1?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$1(e)})(t):t;
-
+ */let et=class{constructor(t,e,i){if(this._$cssResult$=!0,i!==Q)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(F&&void 0===t){const i=void 0!==e&&1===e.length;i&&(t=tt.get(e)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),i&&tt.set(e,t))}return t}toString(){return this.cssText}};const it=(t,...e)=>{const i=1===t.length?t[0]:e.reduce(((e,i,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+t[s+1]),t[0]);return new et(i,t,Q)},st=(t,e)=>{F?t.adoptedStyleSheets=e.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):e.forEach((e=>{const i=document.createElement("style"),s=Z.litNonce;void 0!==s&&i.setAttribute("nonce",s),i.textContent=e.cssText,t.appendChild(i)}))},ot=F?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const i of t.cssRules)e+=i.cssText;return(t=>new et("string"==typeof t?t:t+"",void 0,Q))(e)})(t):t
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
- */var s$1;const e=window,r=e.trustedTypes,h=r?r.emptyScript:"",o$1=e.reactiveElementPolyfillSupport,n$1={toAttribute(t,i){switch(i){case Boolean:t=t?h:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t);}catch(t){s=null;}}return s}},a=(t,i)=>i!==t&&(i==i||t==t),l$1={attribute:!0,type:String,converter:n$1,reflect:!1,hasChanged:a},d="finalized";class u extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu();}static addInitializer(t){var i;this.finalize(),(null!==(i=this.h)&&void 0!==i?i:this.h=[]).push(t);}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Ep(s,i);void 0!==e&&(this._$Ev.set(e,s),t.push(e));})),t}static createProperty(t,i=l$1){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e);}}static getPropertyDescriptor(t,i,s){return {get(){return this[i]},set(e){const r=this[t];this[i]=e,this.requestUpdate(t,r,s);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||l$1}static finalize(){if(this.hasOwnProperty(d))return !1;this[d]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s]);}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(i){const s=[];if(Array.isArray(i)){const e=new Set(i.flat(1/0).reverse());for(const i of e)s.unshift(c(i));}else void 0!==i&&s.push(c(i));return s}static _$Ep(t,i){const s=i.attribute;return !1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)));}addController(t){var i,s;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t));}removeController(t){var i;null===(i=this._$ES)||void 0===i||i.splice(this._$ES.indexOf(t)>>>0,1);}_$Eg(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i]);}));}createRenderRoot(){var t;const s=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return S(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}));}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}));}attributeChangedCallback(t,i,s){this._$AK(t,s);}_$EO(t,i,s=l$1){var e;const r=this.constructor._$Ep(t,s);if(void 0!==r&&!0===s.reflect){const h=(void 0!==(null===(e=s.converter)||void 0===e?void 0:e.toAttribute)?s.converter:n$1).toAttribute(i,s.type);this._$El=t,null==h?this.removeAttribute(r):this.setAttribute(r,h),this._$El=null;}}_$AK(t,i){var s;const e=this.constructor,r=e._$Ev.get(t);if(void 0!==r&&this._$El!==r){const t=e.getPropertyOptions(r),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(s=t.converter)||void 0===s?void 0:s.fromAttribute)?t.converter:n$1;this._$El=r,this[r]=h.fromAttribute(i,t.type),this._$El=null;}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||a)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$E_=this._$Ej());}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,i)=>this[i]=t)),this._$Ei=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$Ek();}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(s);}willUpdate(t){}_$AE(t){var i;null===(i=this._$ES)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return !0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$EO(i,this[i],t))),this._$EC=void 0),this._$Ek();}updated(t){}firstUpdated(t){}}u[d]=!0,u.elementProperties=new Map,u.elementStyles=[],u.shadowRootOptions={mode:"open"},null==o$1||o$1({ReactiveElement:u}),(null!==(s$1=e.reactiveElementVersions)&&void 0!==s$1?s$1:e.reactiveElementVersions=[]).push("1.6.3");
-
+ */;var rt;const nt=window,lt=nt.trustedTypes,at=lt?lt.emptyScript:"",ht=nt.reactiveElementPolyfillSupport,ct={toAttribute(t,e){switch(e){case Boolean:t=t?at:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t)}return t},fromAttribute(t,e){let i=t;switch(e){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t)}catch(t){i=null}}return i}},dt=(t,e)=>e!==t&&(e==e||t==t),ut={attribute:!0,type:String,converter:ct,reflect:!1,hasChanged:dt},pt="finalized";class vt extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(t){var e;this.finalize(),(null!==(e=this.h)&&void 0!==e?e:this.h=[]).push(t)}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((e,i)=>{const s=this._$Ep(i,e);void 0!==s&&(this._$Ev.set(s,i),t.push(s))})),t}static createProperty(t,e=ut){if(e.state&&(e.attribute=!1),this.finalize(),this.elementProperties.set(t,e),!e.noAccessor&&!this.prototype.hasOwnProperty(t)){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.requestUpdate(t,o,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||ut}static finalize(){if(this.hasOwnProperty(pt))return!1;this[pt]=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),void 0!==t.h&&(this.h=[...t.h]),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,e=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const i of e)this.createProperty(i,t[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const t of i)e.unshift(ot(t))}else void 0!==t&&e.push(ot(t));return e}static _$Ep(t,e){const i=e.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}_$Eu(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)))}addController(t){var e,i;(null!==(e=this._$ES)&&void 0!==e?e:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(i=t.hostConnected)||void 0===i||i.call(t))}removeController(t){var e;null===(e=this._$ES)||void 0===e||e.splice(this._$ES.indexOf(t)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((t,e)=>{this.hasOwnProperty(e)&&(this._$Ei.set(e,this[e]),delete this[e])}))}createRenderRoot(){var t;const e=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return st(e,this.constructor.elementStyles),e}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostConnected)||void 0===e?void 0:e.call(t)}))}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostDisconnected)||void 0===e?void 0:e.call(t)}))}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EO(t,e,i=ut){var s;const o=this.constructor._$Ep(t,i);if(void 0!==o&&!0===i.reflect){const r=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:ct).toAttribute(e,i.type);this._$El=t,null==r?this.removeAttribute(o):this.setAttribute(o,r),this._$El=null}}_$AK(t,e){var i;const s=this.constructor,o=s._$Ev.get(t);if(void 0!==o&&this._$El!==o){const t=s.getPropertyOptions(o),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==(null===(i=t.converter)||void 0===i?void 0:i.fromAttribute)?t.converter:ct;this._$El=o,this[o]=r.fromAttribute(e,t.type),this._$El=null}}requestUpdate(t,e,i){let s=!0;void 0!==t&&(((i=i||this.constructor.getPropertyOptions(t)).hasChanged||dt)(this[t],e)?(this._$AL.has(t)||this._$AL.set(t,e),!0===i.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(t){Promise.reject(t)}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,e)=>this[e]=t)),this._$Ei=void 0);let e=!1;const i=this._$AL;try{e=this.shouldUpdate(i),e?(this.willUpdate(i),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var e;return null===(e=t.hostUpdate)||void 0===e?void 0:e.call(t)})),this.update(i)):this._$Ek()}catch(t){throw e=!1,this._$Ek(),t}e&&this._$AE(i)}willUpdate(t){}_$AE(t){var e;null===(e=this._$ES)||void 0===e||e.forEach((t=>{var e;return null===(e=t.hostUpdated)||void 0===e?void 0:e.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return!0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,e)=>this._$EO(e,this[e],t))),this._$EC=void 0),this._$Ek()}updated(t){}firstUpdated(t){}}
/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
- */var l,o;class s extends u{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=D(i,this.renderRoot,this.renderOptions);}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0);}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1);}render(){return T}}s.finalized=!0,s._$litElement$=!0,null===(l=globalThis.litElementHydrateSupport)||void 0===l||l.call(globalThis,{LitElement:s});const n=globalThis.litElementPolyfillSupport;null==n||n({LitElement:s});(null!==(o=globalThis.litElementVersions)&&void 0!==o?o:globalThis.litElementVersions=[]).push("3.3.3");
-
-class BigSliderCard extends s {
- constructor() {
- super(...arguments);
- // @property({ attribute: false }) public hass!: HomeAssistant;
- this._config = DEFAULT_CONFIG;
- this._name = '';
- this.mouseStartPos = { x: 0, y: 0 };
- this.mousePos = { x: 0, y: 0 };
- this.containerWidth = 0;
- this.oldValue = 0;
- this.currentValue = 0;
- this.holdTimer = 0;
- this.isHold = false;
- this._shouldUpdate = true;
- this.updateTimeout = 0;
- this.pressTimeout = 0;
- this.trackingStartTime = 0;
- this.isTap = false;
- this._handleContextMenu = (e) => {
- if (e.preventDefault) {
- e.preventDefault();
- }
- if (e.stopPropagation) {
- e.stopPropagation();
- }
- return false;
- };
- this._handlePointer = (evt, extra) => {
- this.mousePos = { x: evt.pageX, y: evt.pageY };
- const minSlideTime = this._config.min_slide_time;
- if (evt.type === 'pointerdown') {
- this._press();
- this.isTap = true;
- this.isHold = false;
- this.holdTimer = window.setTimeout(this._setHold, this._config.hold_time);
- this.trackingStartTime = Date.now();
- this._resetTrack();
- }
- if (['pointerdown', 'pointermove', 'pointerup'].includes(evt.type)) {
- this._updateValue();
- }
- if (evt.type === 'pointermove') {
- if (this.isTap && (Math.abs(extra.relativeX) < TAP_THRESHOLD && Math.abs(extra.relativeY) < TAP_THRESHOLD))
- return;
- this.isTap = false;
- clearTimeout(this.holdTimer);
- this._stopUpdates();
- }
- if (evt.type === 'pointercancel') {
- clearTimeout(this.holdTimer);
- this._unpress();
- this._startUpdates();
- }
- if (evt.type === 'pointerup') {
- clearTimeout(this.holdTimer);
- this._unpress();
- this._startUpdates();
- if (this.isTap) {
- this._handleTap();
- return;
- }
- if ((Date.now() - this.trackingStartTime) > minSlideTime) {
- this._setValue();
- this._startUpdates(true);
- }
- }
- };
- this._setHold = () => {
- this.isTap = false;
- this.isHold = true;
- this._handleAction('hold');
- };
- this._handleTap = () => {
- var _a;
- clearTimeout(this.holdTimer);
- if ((_a = this._config) === null || _a === void 0 ? void 0 : _a.tap_action) {
- if (!this.isHold) {
- this._handleAction('tap');
- }
- }
- };
- }
- static getStubConfig(_hass, entities) {
- const lights = entities.filter(entity => entity.split('.')[0] === 'light').sort();
- const randomLight = lights[Math.floor(Math.random() * lights.length)];
- return { type: 'custom:big-slider-card', entity: randomLight };
- }
- // life cycle
- setConfig(config) {
- if (!config) {
- throw new Error(localize('common.invalid_configuration'));
- }
- if (!config.entity) {
- throw new Error(localize('common.no_entity_set'));
- }
- if (!config.entity || config.entity.split(".")[0] !== "light") {
- throw new Error("Specify an entity from within the light domain");
- }
- this._config = Object.assign(Object.assign({}, DEFAULT_CONFIG), config);
- this._entity = this._config.entity;
- this._config.original_min = this._config.min;
- this._config.original_max = this._config.max;
- }
- set hass(hass) {
- var _a, _b, _c, _d, _e, _f;
- if (!this._entity)
- return;
- this._hass = hass;
- this._state = hass.states[this._entity];
- this._status = (_a = this._state) === null || _a === void 0 ? void 0 : _a.state;
- this._name =
- (_f = (_e = (_b = this._config.name) !== null && _b !== void 0 ? _b : (_d = (_c = this._state) === null || _c === void 0 ? void 0 : _c.attributes) === null || _d === void 0 ? void 0 : _d.friendly_name) !== null && _e !== void 0 ? _e : this._entity.split('.')[1]) !== null && _f !== void 0 ? _f : '';
- }
- _log(text) {
- console.log(`%c BIG-SLIDER-CARD ${this._name} %c ${text} `, 'color: orange; font-weight: bold; background: black', '');
- }
- connectedCallback() {
- super.connectedCallback();
- this.addEventListener('contextmenu', this._handleContextMenu);
- this.slideGesture = new SlideGesture(this, this._handlePointer.bind(this), {
- touchActions: 'pan-y',
- stopScrollDirection: 'horizontal'
- });
- }
- disconnectedCallback() {
- this.removeEventListener('contextmenu', this._handleContextMenu);
- this.slideGesture.removeListeners();
- super.disconnectedCallback();
- }
- _updateValue() {
- const width = this.containerWidth;
- const dx = this.mousePos.x - this.mouseStartPos.x;
- const percentage = Math.round(100 * dx / width);
- this.currentValue = this.oldValue + percentage;
- this._checklimits();
- this._updateSlider();
- }
- _handleAction(action) {
- const event = new Event('hass-action', {
- bubbles: true,
- cancelable: false,
- composed: true,
- });
- event.detail = {
- config: this._config,
- action: action,
- };
- this.dispatchEvent(event);
- }
- _resetTrack() {
- this.mouseStartPos = { x: this.mousePos.x, y: this.mousePos.y };
- this.oldValue = this.currentValue;
- }
- _press() {
- if (this.pressTimeout)
- clearTimeout(this.pressTimeout);
- this.pressTimeout = window.setTimeout(() => this.setAttribute('pressed', ''), this._config.min_slide_time);
- this.setAttribute('half-pressed', '');
- }
- _unpress() {
- if (this.pressTimeout)
- clearTimeout(this.pressTimeout);
- this.removeAttribute('pressed');
- this.removeAttribute('half-pressed');
- }
- _checklimits() {
- var _a, _b;
- const min = (_a = this._config.min) !== null && _a !== void 0 ? _a : 0;
- const max = (_b = this._config.max) !== null && _b !== void 0 ? _b : 100;
- if (this.currentValue < min) {
- this.currentValue = min;
- this._resetTrack();
- }
- if (this.currentValue > max) {
- this.currentValue = max;
- this._resetTrack();
- }
- }
- _updateSlider() {
- var _a;
- this.style.setProperty('--bsc-percent', this.currentValue + '%');
- const percentage = (_a = this === null || this === void 0 ? void 0 : this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('percentage');
- percentage && (percentage.innerText = Math.round(this.currentValue) + '%');
- }
- _updateColors() {
- var _a, _b, _c, _d, _e;
- let color = 'var(--bsc-color)';
- let brightness = '0%';
- let brightnessUI = '50%';
- let isOn = false;
- if (this._state) {
- if (this._status == 'on') {
- const stateColor = (_b = (_a = this._state.attributes) === null || _a === void 0 ? void 0 : _a.rgb_color) !== null && _b !== void 0 ? _b : [255, 255, 255];
- const stateBrightness = (_d = (_c = this._state.attributes) === null || _c === void 0 ? void 0 : _c.brightness) !== null && _d !== void 0 ? _d : 255;
- isOn = true;
- if (stateColor) {
- color = `rgb(${stateColor.join(',')})`;
- }
- if (stateBrightness) {
- brightness = `${Math.ceil(100 * stateBrightness / 255)}%`;
- brightnessUI = `${Math.ceil(100 * stateBrightness / 510 + 50)}%`;
- }
- }
- else {
- color = 'var(--bsc-off-color)';
- }
- }
- const percentage = (_e = this === null || this === void 0 ? void 0 : this.shadowRoot) === null || _e === void 0 ? void 0 : _e.getElementById('percentage');
- if (!isOn) {
- percentage && (percentage.innerText = localize('common.off'));
- }
- this.style.setProperty('--bsc-entity-color', color);
- this.style.setProperty('--bsc-brightness', brightness);
- this.style.setProperty('--bsc-brightness-ui', brightnessUI);
- if (this._config.icon_color && isOn) {
- this.style.setProperty('--bsc-icon-color', this._config.icon_color);
- }
- if (this._config.icon_color && !isOn) {
- this.style.removeProperty('--bsc-icon-color');
- }
- }
- _getValue() {
- var _a, _b, _c, _d, _e;
- if (!this._shouldUpdate)
- return;
- if (!this._state)
- return;
- const attr = (_a = this._config) === null || _a === void 0 ? void 0 : _a.attribute;
- let _value = 0;
- if (this._status == 'unavailable') {
- this._config.min = 0;
- this._config.max = 0;
- this.style.setProperty('--bsc-opacity', '0.5');
- }
- else {
- this._config.min = this._config.original_min;
- this._config.max = this._config.original_max;
- this.style.removeProperty('--bsc-opacity');
- }
- if (this._status != 'on') {
- _value = (_b = this._config.min) !== null && _b !== void 0 ? _b : 0;
- }
- else {
- switch (attr) {
- case 'brightness':
- _value = Math.round(100 * ((_c = this._state.attributes.brightness) !== null && _c !== void 0 ? _c : 255) / 255);
- break;
- case 'red':
- case 'green':
- case 'blue':
- const rgb = (_d = this._state.attributes.rgb_color) !== null && _d !== void 0 ? _d : [255, 255, 255];
- if (attr === 'red')
- _value = rgb[0];
- if (attr === 'green')
- _value = rgb[1];
- if (attr === 'blue')
- _value = rgb[2];
- _value = Math.ceil(100 * _value / 255);
- break;
- case 'hue':
- case 'saturation':
- const hs = (_e = this._state.attributes.hs_color) !== null && _e !== void 0 ? _e : [100, 100];
- if (attr === 'hue')
- _value = hs[0];
- if (attr === 'saturation')
- _value = hs[1];
- break;
- }
- }
- this.currentValue = _value;
- this._updateSlider();
- }
- _setValue() {
- var _a, _b;
- if (!this._state)
- return;
- let value = this.currentValue;
- let attr = this._config.attribute;
- let on = true;
- let _value;
- switch (attr) {
- case 'brightness':
- value = Math.ceil(value / 100.0 * 255);
- if (!value)
- on = false;
- break;
- case 'red':
- case 'green':
- case 'blue':
- _value = (_a = this._state.attributes.rgb_color) !== null && _a !== void 0 ? _a : [255, 255, 255];
- if (attr === 'red')
- _value[0] = value;
- if (attr === 'green')
- _value[1] = value;
- if (attr === 'blue')
- _value[2] = value;
- value = _value;
- attr = 'rgb_color';
- break;
- case 'hue':
- case 'saturation':
- _value = (_b = this._state.attributes.hs_color) !== null && _b !== void 0 ? _b : [100, 100];
- if (attr === 'hue')
- _value[0] = value;
- if (attr === 'saturation')
- _value[1] = value;
- value = _value;
- attr = 'hs_color';
- break;
- }
- const params = {
- entity_id: this._state.entity_id,
- };
- if (on) {
- params[attr] = value;
- if (this._config.transition) {
- params.transition = this._config.transition;
- }
- this._hass.callService('light', 'turn_on', params);
- }
- else {
- this._hass.callService('light', 'turn_off', params);
- }
- }
- _stopUpdates() {
- var _a, _b, _c;
- if (this.updateTimeout)
- clearTimeout(this.updateTimeout);
- if (!this._shouldUpdate)
- return;
- (_c = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('slider')) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.remove('animate');
- this._shouldUpdate = false;
- }
- _startUpdates(settle = false) {
- if (this.updateTimeout)
- clearTimeout(this.updateTimeout);
- this.updateTimeout = window.setTimeout(() => {
- var _a, _b, _c;
- this._shouldUpdate = true;
- (_c = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('slider')) === null || _b === void 0 ? void 0 : _b.classList) === null || _c === void 0 ? void 0 : _c.add('animate');
- this.requestUpdate();
- }, settle ? this._config.settle_time : 0);
- }
- updated() {
- var _a, _b, _c;
- this.containerWidth = (_c = (_b = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('container')) === null || _b === void 0 ? void 0 : _b.clientWidth) !== null && _c !== void 0 ? _c : 0;
- this._getValue();
- this._updateColors();
- }
- render() {
- var _a, _b, _c, _d, _e;
- if (!(this._entity && (this._entity in ((_b = (_a = this._hass) === null || _a === void 0 ? void 0 : _a.states) !== null && _b !== void 0 ? _b : {})))) {
- return this._showError(`${localize('common.no_entity')}: ${this._entity}`);
- }
- const colorize = (_c = (this._config.colorize && true)) !== null && _c !== void 0 ? _c : false;
- const showPercentage = (_d = (this._config.show_percentage && true)) !== null && _d !== void 0 ? _d : false;
- const boldText = (_e = (this._config.bold_text && true)) !== null && _e !== void 0 ? _e : false;
- this._setStyleProperty('--bsc-background', this._config.background_color);
- this._setStyleProperty('--bsc-primary-text-color', this._config.text_color);
- this._setStyleProperty('--bsc-slider-color', this._config.color);
- this._setStyleProperty('--bsc-border-color', this._config.border_color);
- this._setStyleProperty('--bsc-border-radius', this._config.border_radius);
- this._setStyleProperty('--bsc-border-style', this._config.border_style);
- this._setStyleProperty('--bsc-border-width', this._config.border_width);
- this._setStyleProperty('--bsc-height', this._config.height, (height) => `${height}px`);
- return x `
+ */
+var _t,gt;vt[pt]=!0,vt.elementProperties=new Map,vt.elementStyles=[],vt.shadowRootOptions={mode:"open"},null==ht||ht({ReactiveElement:vt}),(null!==(rt=nt.reactiveElementVersions)&&void 0!==rt?rt:nt.reactiveElementVersions=[]).push("1.6.3");class ft extends vt{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var t,e;const i=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=i.firstChild),i}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=((t,e,i)=>{var s,o;const r=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:e;let n=r._$litPart$;if(void 0===n){const t=null!==(o=null==i?void 0:i.renderBefore)&&void 0!==o?o:null;r._$litPart$=n=new B(e.insertBefore(A(),t),t,void 0,null!=i?i:{})}return n._$AI(t),n})(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),null===(t=this._$Do)||void 0===t||t.setConnected(!1)}render(){return O}}ft.finalized=!0,ft._$litElement$=!0,null===(_t=globalThis.litElementHydrateSupport)||void 0===_t||_t.call(globalThis,{LitElement:ft});const bt=globalThis.litElementPolyfillSupport;null==bt||bt({LitElement:ft}),(null!==(gt=globalThis.litElementVersions)&&void 0!==gt?gt:globalThis.litElementVersions=[]).push("3.3.3");class mt extends ft{constructor(){super(...arguments),this._config=i,this._name="",this.mouseStartPos={x:0,y:0},this.mousePos={x:0,y:0},this.containerWidth=0,this.oldValue=0,this.currentValue=0,this.holdTimer=0,this.isHold=!1,this._shouldUpdate=!0,this.updateTimeout=0,this.pressTimeout=0,this.trackingStartTime=0,this.isTap=!1,this._handleContextMenu=t=>(t.preventDefault&&t.preventDefault(),t.stopPropagation&&t.stopPropagation(),!1),this._handlePointer=(t,e)=>{this.mousePos={x:t.pageX,y:t.pageY};const i=this._config.min_slide_time;if("pointerdown"===t.type&&(this._press(),this.isTap=!0,this.isHold=!1,this.holdTimer=window.setTimeout(this._setHold,this._config.hold_time),this.trackingStartTime=Date.now(),this._resetTrack()),["pointerdown","pointermove","pointerup"].includes(t.type)&&this._updateValue(),"pointermove"===t.type){if(this.isTap&&Math.abs(e.relativeX)<5&&Math.abs(e.relativeY)<5)return;this.isTap=!1,clearTimeout(this.holdTimer),this._stopUpdates()}if("pointercancel"===t.type&&(clearTimeout(this.holdTimer),this._unpress(),this._startUpdates()),"pointerup"===t.type){if(clearTimeout(this.holdTimer),this._unpress(),this._startUpdates(),this.isTap)return void this._handleTap();Date.now()-this.trackingStartTime>i&&(this._setValue(),this._startUpdates(!0))}},this._setHold=()=>{this.isTap=!1,this.isHold=!0,this._handleAction("hold")},this._handleTap=()=>{var t;clearTimeout(this.holdTimer),(null===(t=this._config)||void 0===t?void 0:t.tap_action)&&(this.isHold||this._handleAction("tap"))}}static getStubConfig(t,e){const i=e.filter((t=>"light"===t.split(".")[0])).sort();return{type:"custom:big-slider-card",entity:i[Math.floor(Math.random()*i.length)]}}setConfig(t){if(!t)throw new Error(a("common.invalid_configuration"));if(!t.entity)throw new Error(a("common.no_entity_set"));if(!t.entity||"light"!==t.entity.split(".")[0])throw new Error("Specify an entity from within the light domain");this._config=Object.assign(Object.assign({},i),t),this._entity=this._config.entity,this._config.original_min=this._config.min,this._config.original_max=this._config.max}set hass(t){var e,i,s,o,r,n;this._entity&&(this._hass=t,this._state=t.states[this._entity],this._status=null===(e=this._state)||void 0===e?void 0:e.state,this._name=null!==(n=null!==(r=null!==(i=this._config.name)&&void 0!==i?i:null===(o=null===(s=this._state)||void 0===s?void 0:s.attributes)||void 0===o?void 0:o.friendly_name)&&void 0!==r?r:this._entity.split(".")[1])&&void 0!==n?n:"")}_log(t){console.log(`%c BIG-SLIDER-CARD ${this._name} %c ${t} `,"color: orange; font-weight: bold; background: black","")}connectedCallback(){super.connectedCallback(),this.addEventListener("contextmenu",this._handleContextMenu),this.slideGesture=new e(this,this._handlePointer.bind(this),{touchActions:"pan-y",stopScrollDirection:"horizontal"})}disconnectedCallback(){this.removeEventListener("contextmenu",this._handleContextMenu),this.slideGesture.removeListeners(),super.disconnectedCallback()}_updateValue(){const t=this.containerWidth,e=this.mousePos.x-this.mouseStartPos.x,i=Math.round(100*e/t);this.currentValue=this.oldValue+i,this._checklimits(),this._updateSlider()}_handleAction(t){const e=new Event("hass-action",{bubbles:!0,cancelable:!1,composed:!0});e.detail={config:this._config,action:t},this.dispatchEvent(e)}_resetTrack(){this.mouseStartPos={x:this.mousePos.x,y:this.mousePos.y},this.oldValue=this.currentValue}_press(){this.pressTimeout&&clearTimeout(this.pressTimeout),this.pressTimeout=window.setTimeout((()=>this.setAttribute("pressed","")),this._config.min_slide_time),this.setAttribute("half-pressed","")}_unpress(){this.pressTimeout&&clearTimeout(this.pressTimeout),this.removeAttribute("pressed"),this.removeAttribute("half-pressed")}_checklimits(){var t,e;const i=null!==(t=this._config.min)&&void 0!==t?t:0,s=null!==(e=this._config.max)&&void 0!==e?e:100;this.currentValues&&(this.currentValue=s,this._resetTrack())}_updateSlider(){var t;this.style.setProperty("--bsc-percent",this.currentValue+"%");const e=null===(t=null==this?void 0:this.shadowRoot)||void 0===t?void 0:t.getElementById("percentage");e&&(e.innerText=Math.round(this.currentValue)+"%")}_updateColors(){var t,e,i,s,o;let r="var(--bsc-color)",n="0%",l="50%",h=!1;if(this._state)if("on"==this._status){const o=null!==(e=null===(t=this._state.attributes)||void 0===t?void 0:t.rgb_color)&&void 0!==e?e:[255,255,255],a=null!==(s=null===(i=this._state.attributes)||void 0===i?void 0:i.brightness)&&void 0!==s?s:255;h=!0,o&&(r=`rgb(${o.join(",")})`),a&&(n=`${Math.ceil(100*a/255)}%`,l=`${Math.ceil(100*a/510+50)}%`)}else r="var(--bsc-off-color)";const c=null===(o=null==this?void 0:this.shadowRoot)||void 0===o?void 0:o.getElementById("percentage");h||c&&(c.innerText=a("common.off")),this.style.setProperty("--bsc-entity-color",r),this.style.setProperty("--bsc-brightness",n),this.style.setProperty("--bsc-brightness-ui",l),this._config.icon_color&&h&&this.style.setProperty("--bsc-icon-color",this._config.icon_color),this._config.icon_color&&!h&&this.style.removeProperty("--bsc-icon-color")}_getValue(){var t,e,i,s,o;if(!this._shouldUpdate)return;if(!this._state)return;const r=null===(t=this._config)||void 0===t?void 0:t.attribute;let n=0;if("unavailable"==this._status?(this._config.min=0,this._config.max=0,this.style.setProperty("--bsc-opacity","0.5")):(this._config.min=this._config.original_min,this._config.max=this._config.original_max,this.style.removeProperty("--bsc-opacity")),"on"!=this._status)n=null!==(e=this._config.min)&&void 0!==e?e:0;else switch(r){case"brightness":n=Math.round(100*(null!==(i=this._state.attributes.brightness)&&void 0!==i?i:255)/255);break;case"red":case"green":case"blue":const t=null!==(s=this._state.attributes.rgb_color)&&void 0!==s?s:[255,255,255];"red"===r&&(n=t[0]),"green"===r&&(n=t[1]),"blue"===r&&(n=t[2]),n=Math.ceil(100*n/255);break;case"hue":case"saturation":const e=null!==(o=this._state.attributes.hs_color)&&void 0!==o?o:[100,100];"hue"===r&&(n=e[0]),"saturation"===r&&(n=e[1])}this.currentValue=n,this._updateSlider()}_setValue(){var t,e;if(!this._state)return;let i,s=this.currentValue,o=this._config.attribute,r=!0;switch(o){case"brightness":s=Math.ceil(s/100*255),s||(r=!1);break;case"red":case"green":case"blue":i=null!==(t=this._state.attributes.rgb_color)&&void 0!==t?t:[255,255,255],"red"===o&&(i[0]=s),"green"===o&&(i[1]=s),"blue"===o&&(i[2]=s),s=i,o="rgb_color";break;case"hue":case"saturation":i=null!==(e=this._state.attributes.hs_color)&&void 0!==e?e:[100,100],"hue"===o&&(i[0]=s),"saturation"===o&&(i[1]=s),s=i,o="hs_color"}const n={entity_id:this._state.entity_id};r?(n[o]=s,this._config.transition&&(n.transition=this._config.transition),this._hass.callService("light","turn_on",n)):this._hass.callService("light","turn_off",n)}_stopUpdates(){var t,e,i;this.updateTimeout&&clearTimeout(this.updateTimeout),this._shouldUpdate&&(null===(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("slider"))||void 0===e?void 0:e.classList)||void 0===i||i.remove("animate"),this._shouldUpdate=!1)}_startUpdates(t=!1){this.updateTimeout&&clearTimeout(this.updateTimeout),this.updateTimeout=window.setTimeout((()=>{var t,e,i;this._shouldUpdate=!0,null===(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("slider"))||void 0===e?void 0:e.classList)||void 0===i||i.add("animate"),this.requestUpdate()}),t?this._config.settle_time:0)}updated(){var t,e,i;this.containerWidth=null!==(i=null===(e=null===(t=this.shadowRoot)||void 0===t?void 0:t.getElementById("container"))||void 0===e?void 0:e.clientWidth)&&void 0!==i?i:0,this._getValue(),this._updateColors()}render(){var t,e,i,s,o;if(!this._entity||!(this._entity in(null!==(e=null===(t=this._hass)||void 0===t?void 0:t.states)&&void 0!==e?e:{})))return this._showError(`${a("common.no_entity")}: ${this._entity}`);const r=null!==(i=this._config.colorize&&!0)&&void 0!==i&&i,n=null!==(s=this._config.show_percentage&&!0)&&void 0!==s&&s,l=null!==(o=this._config.bold_text&&!0)&&void 0!==o&&o;return this._setStyleProperty("--bsc-background",this._config.background_color),this._setStyleProperty("--bsc-primary-text-color",this._config.text_color),this._setStyleProperty("--bsc-slider-color",this._config.color),this._setStyleProperty("--bsc-border-color",this._config.border_color),this._setStyleProperty("--bsc-border-radius",this._config.border_radius),this._setStyleProperty("--bsc-border-style",this._config.border_style),this._setStyleProperty("--bsc-border-width",this._config.border_width),this._setStyleProperty("--bsc-height",this._config.height,(t=>`${t}px`)),M`
-
+
null!=t?t:R)
+/**
+ * @license
+ * Copyright 2019 Google LLC
+ * SPDX-License-Identifier: BSD-3-Clause
+ */(this._status)}
>
- `;
- }
- _setStyleProperty(name, value, transform = (value) => value) {
- if (value !== undefined && value !== null && value !== '') {
- this.style.setProperty(name, transform(value));
- }
- }
- _showWarning(warning) {
- return x `
- ${warning}
- `;
- }
- _showError(error) {
- const errorCard = document.createElement('hui-error-card');
- errorCard.setConfig({
- type: 'error',
- error,
- // origConfig: this._config,
- });
- return x `
- ${errorCard}
- `;
- }
- // https://lit-element.polymer-project.org/guide/styles
- static get styles() {
- return i `
+ `}_setStyleProperty(t,e,i=(t=>t)){null!=e&&""!==e&&this.style.setProperty(t,i(e))}_showWarning(t){return M`
+ ${t}
+ `}_showError(t){const e=document.createElement("hui-error-card");return e.setConfig({type:"error",error:t}),M`
+ ${e}
+ `}static get styles(){return it`
:host {
--bsc-background: var(--card-background-color, #aaaaaa);
--bsc-slider-color: var(--paper-slider-active-color, #f9d2b0);
@@ -793,32 +174,4 @@ class BigSliderCard extends s {
#percentage {
color: var(--bsc-secondary-text-color)
}
- `;
- }
-}
-__decorate([
- t$2()
-], BigSliderCard.prototype, "_config", void 0);
-__decorate([
- t$2()
-], BigSliderCard.prototype, "_entity", void 0);
-__decorate([
- t$2()
-], BigSliderCard.prototype, "_state", void 0);
-__decorate([
- t$2()
-], BigSliderCard.prototype, "_status", void 0);
-__decorate([
- t$2()
-], BigSliderCard.prototype, "_name", void 0);
-
-var _a;
-/* eslint no-console: 0 */
-console.info(`%c BIG-SLIDER-CARD \n%c ${localize('common.version')} ${CARD_VERSION} `, 'color: orange; font-weight: bold; background: black', 'color: white; font-weight: bold; background: dimgray');
-customElements.define("big-slider-card", BigSliderCard);
-window.customCards = (_a = window.customCards) !== null && _a !== void 0 ? _a : [];
-window.customCards.push({
- type: 'big-slider-card',
- name: 'Big Slider Card',
- description: 'Big slider card for light entities.',
-});
+ `}}var yt;t([d()],mt.prototype,"_config",void 0),t([d()],mt.prototype,"_entity",void 0),t([d()],mt.prototype,"_state",void 0),t([d()],mt.prototype,"_status",void 0),t([d()],mt.prototype,"_name",void 0),console.info(`%c BIG-SLIDER-CARD \n%c ${a("common.version")} 1.1.4 `,"color: orange; font-weight: bold; background: black","color: white; font-weight: bold; background: dimgray"),customElements.define("big-slider-card",mt),window.customCards=null!==(yt=window.customCards)&&void 0!==yt?yt:[],window.customCards.push({type:"big-slider-card",name:"Big Slider Card",description:"Big slider card for light entities."});
diff --git a/package.json b/package.json
index 93ba4fb..619418f 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "big-slider-card",
- "version": "1.1.3",
+ "version": "1.1.4",
"description": "Lovelace big-slider-card",
"keywords": [
"home-assistant",
diff --git a/src/const.ts b/src/const.ts
index 4788356..9977ad8 100644
--- a/src/const.ts
+++ b/src/const.ts
@@ -1,6 +1,6 @@
import { BigSliderCardConfig } from "./types";
-export const CARD_VERSION = '1.1.3';
+export const CARD_VERSION = '1.1.4';
export const DEFAULT_ATTRIBUTE = 'brightness';
export const SETTLE_TIME = 3000;
export const HOLD_TIME = 600;