UNPKG

iobroker.lovelace

Version:

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

2 lines 43 kB
(self.webpackChunkhome_assistant_frontend=self.webpackChunkhome_assistant_frontend||[]).push([[6016],{73139:function(e,t,r){"use strict";var n,i=r(50856),o=r(28426);r(16509),r(46998);function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function s(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=d(e);if(t){var i=d(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return h(this,r)}}function h(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}(h,e);var t,r,o,a=u(h);function h(){return s(this,h),a.apply(this,arguments)}return t=h,o=[{key:"template",get:function(){return(0,i.d)(n||(e=['\n <style>\n :host {\n display: block;\n }\n\n .title {\n margin: 5px 0 8px;\n color: var(--primary-text-color);\n }\n\n .slider-container {\n display: flex;\n }\n\n ha-icon {\n margin-top: 4px;\n color: var(--secondary-text-color);\n }\n\n ha-slider {\n flex-grow: 1;\n background-image: var(--ha-slider-background);\n border-radius: 4px;\n }\n </style>\n\n <div class="title">[[caption]]</div>\n <div class="extra-container"><slot name="extra"></slot></div>\n <div class="slider-container">\n <ha-icon icon="[[icon]]" hidden$="[[!icon]]"></ha-icon>\n <ha-slider\n min="[[min]]"\n max="[[max]]"\n step="[[step]]"\n pin="[[pin]]"\n disabled="[[disabled]]"\n value="{{value}}"\n ></ha-slider>\n </div>\n '],t||(t=e.slice(0)),n=Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))));var e,t}},{key:"properties",get:function(){return{caption:String,disabled:Boolean,min:Number,max:Number,pin:Boolean,step:Number,extra:{type:Boolean,value:!1},ignoreBarTouch:{type:Boolean,value:!0},icon:{type:String,value:""},value:{type:Number,notify:!0}}}}],(r=null)&&l(t.prototype,r),o&&l(t,o),h}(o.H3);customElements.define("ha-labeled-slider",f)},81303:function(e,t,r){"use strict";r(8878);function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function a(e,t,r){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=u(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=u(e);if(t){var i=u(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return c(this,r)}}function c(e,t){return!t||"object"!==n(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function u(e){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var h=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(h,e);var t,r,n,c=l(h);function h(){return i(this,h),c.apply(this,arguments)}return t=h,(r=[{key:"ready",value:function(){var e=this;a(u(h.prototype),"ready",this).call(this),setTimeout((function(){"rtl"===window.getComputedStyle(e).direction&&(e.style.textAlign="right")}),100)}}])&&o(t.prototype,r),n&&o(t,n),h}(customElements.get("paper-dropdown-menu"));customElements.define("ha-paper-dropdown-menu",h)},36016:function(e,t,r){"use strict";r.r(t);r(53973),r(51095);var n,i=r(50424),o=r(55358),a=r(40095),s=(r(31811),r(42657),r(50856)),l=r(28426),c=r(15838);function u(e){return(u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function h(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==r)return;var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(l){s=!0,i=l}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function y(e,t,r){return(y="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=g(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function b(e,t){return(b=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function v(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=g(e);if(t){var i=g(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}function m(e,t){return!t||"object"!==u(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function g(e){return(g=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var w=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&b(e,t)}(a,e);var t,r,i,o=v(a);function a(){return f(this,a),o.apply(this,arguments)}return t=a,i=[{key:"template",get:function(){return(0,s.d)(n||(e=['\n <style>\n :host {\n user-select: none;\n -webkit-user-select: none;\n }\n\n #canvas {\n position: relative;\n width: 100%;\n max-width: 330px;\n }\n #canvas > * {\n display: block;\n }\n #interactionLayer {\n color: white;\n position: absolute;\n cursor: crosshair;\n width: 100%;\n height: 100%;\n overflow: visible;\n }\n #backgroundLayer {\n width: 100%;\n overflow: visible;\n --wheel-bordercolor: var(--ha-color-picker-wheel-bordercolor, white);\n --wheel-borderwidth: var(--ha-color-picker-wheel-borderwidth, 3);\n --wheel-shadow: var(\n --ha-color-picker-wheel-shadow,\n rgb(15, 15, 15) 10px 5px 5px 0px\n );\n }\n\n #marker {\n fill: currentColor;\n stroke: var(--ha-color-picker-marker-bordercolor, white);\n stroke-width: var(--ha-color-picker-marker-borderwidth, 3);\n filter: url(#marker-shadow);\n }\n .dragging #marker {\n }\n\n #colorTooltip {\n display: none;\n fill: currentColor;\n stroke: var(--ha-color-picker-tooltip-bordercolor, white);\n stroke-width: var(--ha-color-picker-tooltip-borderwidth, 3);\n }\n\n .touch.dragging #colorTooltip {\n display: inherit;\n }\n </style>\n <div id="canvas">\n <svg id="interactionLayer">\n <defs>\n <filter\n id="marker-shadow"\n x="-50%"\n y="-50%"\n width="200%"\n height="200%"\n filterUnits="objectBoundingBox"\n >\n <feOffset\n result="offOut"\n in="SourceAlpha"\n dx="2"\n dy="2"\n ></feOffset>\n <feGaussianBlur\n result="blurOut"\n in="offOut"\n stdDeviation="2"\n ></feGaussianBlur>\n <feComponentTransfer in="blurOut" result="alphaOut">\n <feFuncA type="linear" slope="0.3"></feFuncA>\n </feComponentTransfer>\n <feBlend\n in="SourceGraphic"\n in2="alphaOut"\n mode="normal"\n ></feBlend>\n </filter>\n </defs>\n </svg>\n <canvas id="backgroundLayer"></canvas>\n </div>\n '],t||(t=e.slice(0)),n=Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))));var e,t}},{key:"properties",get:function(){return{hsColor:{type:Object},desiredHsColor:{type:Object,observer:"applyHsColor"},desiredRgbColor:{type:Object,observer:"applyRgbColor"},width:{type:Number,value:500},height:{type:Number,value:500},radius:{type:Number,value:225},hueSegments:{type:Number,value:0,observer:"segmentationChange"},saturationSegments:{type:Number,value:0,observer:"segmentationChange"},ignoreSegments:{type:Boolean,value:!1},throttle:{type:Number,value:500}}}}],(r=[{key:"ready",value:function(){var e=this;y(g(a.prototype),"ready",this).call(this),this.setupLayers(),this.drawColorWheel(),this.drawMarker(),this.desiredHsColor&&this.applyHsColor(this.desiredHsColor),this.desiredRgbColor&&this.applyRgbColor(this.desiredRgbColor),this.interactionLayer.addEventListener("mousedown",(function(t){return e.onMouseDown(t)})),this.interactionLayer.addEventListener("touchstart",(function(t){return e.onTouchStart(t)}))}},{key:"convertToCanvasCoordinates",value:function(e,t){var r=this.interactionLayer.createSVGPoint();r.x=e,r.y=t;var n=r.matrixTransform(this.interactionLayer.getScreenCTM().inverse());return{x:n.x,y:n.y}}},{key:"onMouseDown",value:function(e){var t=this.convertToCanvasCoordinates(e.clientX,e.clientY);this.isInWheel(t.x,t.y)&&(this.onMouseSelect(e),this.canvas.classList.add("mouse","dragging"),this.addEventListener("mousemove",this.onMouseSelect),this.addEventListener("mouseup",this.onMouseUp))}},{key:"onMouseUp",value:function(){this.canvas.classList.remove("mouse","dragging"),this.removeEventListener("mousemove",this.onMouseSelect)}},{key:"onMouseSelect",value:function(e){var t=this;requestAnimationFrame((function(){return t.processUserSelect(e)}))}},{key:"onTouchStart",value:function(e){var t=this,r=e.changedTouches[0],n=this.convertToCanvasCoordinates(r.clientX,r.clientY);if(this.isInWheel(n.x,n.y)){if(e.target===this.marker)return e.preventDefault(),this.canvas.classList.add("touch","dragging"),this.addEventListener("touchmove",this.onTouchSelect),void this.addEventListener("touchend",this.onTouchEnd);this.tapBecameScroll=!1,this.addEventListener("touchend",this.onTap),this.addEventListener("touchmove",(function(){t.tapBecameScroll=!0}),{passive:!0})}}},{key:"onTap",value:function(e){this.tapBecameScroll||(e.preventDefault(),this.onTouchSelect(e))}},{key:"onTouchEnd",value:function(){this.canvas.classList.remove("touch","dragging"),this.removeEventListener("touchmove",this.onTouchSelect)}},{key:"onTouchSelect",value:function(e){var t=this;requestAnimationFrame((function(){return t.processUserSelect(e.changedTouches[0])}))}},{key:"processUserSelect",value:function(e){var t,r=this.convertToCanvasCoordinates(e.clientX,e.clientY),n=this.getColor(r.x,r.y);if(this.isInWheel(r.x,r.y))t=this.getRgbColor(r.x,r.y);else{var i=h((0,c.Mc)([n.h,n.s]),3);t={r:i[0],g:i[1],b:i[2]}}this.onColorSelect(n,t)}},{key:"onColorSelect",value:function(e,t){var r=this;if(this.setMarkerOnColor(e),this.ignoreSegments||(e=this.applySegmentFilter(e)),this.applyColorToCanvas(e),this.colorSelectIsThrottled)return clearTimeout(this.ensureFinalSelect),void(this.ensureFinalSelect=setTimeout((function(){r.fireColorSelected(e,t)}),this.throttle));this.fireColorSelected(e,t),this.colorSelectIsThrottled=!0,setTimeout((function(){r.colorSelectIsThrottled=!1}),this.throttle)}},{key:"fireColorSelected",value:function(e,t){this.hsColor=e,this.fire("colorselected",{hs:e,rgb:t})}},{key:"setMarkerOnColor",value:function(e){if(this.marker&&this.tooltip){var t=e.s*this.radius,r=(e.h-180)/180*Math.PI,n=-t*Math.cos(r),i=-t*Math.sin(r),o="translate(".concat(n,",").concat(i,")");this.marker.setAttribute("transform",o),this.tooltip.setAttribute("transform",o)}}},{key:"applyColorToCanvas",value:function(e){this.interactionLayer&&(this.interactionLayer.style.color="hsl(".concat(e.h,", 100%, ").concat(100-50*e.s,"%)"))}},{key:"applyHsColor",value:function(e){this.hsColor&&this.hsColor.h===e.h&&this.hsColor.s===e.s||(this.setMarkerOnColor(e),this.ignoreSegments||(e=this.applySegmentFilter(e)),this.hsColor=e,this.applyColorToCanvas(e))}},{key:"applyRgbColor",value:function(e){var t=h((0,c.xV)(e),2),r=t[0],n=t[1];this.applyHsColor({h:r,s:n})}},{key:"getAngle",value:function(e,t){return Math.atan2(-t,-e)/Math.PI*180+180}},{key:"isInWheel",value:function(e,t){return this.getDistance(e,t)<=1}},{key:"getDistance",value:function(e,t){return Math.sqrt(e*e+t*t)/this.radius}},{key:"getColor",value:function(e,t){var r=this.getAngle(e,t),n=this.getDistance(e,t);return{h:r,s:Math.min(n,1)}}},{key:"getRgbColor",value:function(e,t){var r=this.backgroundLayer.getContext("2d").getImageData(e+250,t+250,1,1).data;return{r:r[0],g:r[1],b:r[2]}}},{key:"applySegmentFilter",value:function(e){if(this.hueSegments){var t=360/this.hueSegments,r=t/2;e.h-=r,e.h<0&&(e.h+=360);var n=e.h%t;e.h-=n-t}if(this.saturationSegments)if(1===this.saturationSegments)e.s=1;else{var i=1/this.saturationSegments,o=1/(this.saturationSegments-1),a=Math.floor(e.s/i)*o;e.s=Math.min(a,1)}return e}},{key:"setupLayers",value:function(){this.canvas=this.$.canvas,this.backgroundLayer=this.$.backgroundLayer,this.interactionLayer=this.$.interactionLayer,this.originX=this.width/2,this.originY=this.originX,this.backgroundLayer.width=this.width,this.backgroundLayer.height=this.height,this.interactionLayer.setAttribute("viewBox","".concat(-this.originX," ").concat(-this.originY," ").concat(this.width," ").concat(this.height))}},{key:"drawColorWheel",value:function(){var e,t,r,n,i=this.backgroundLayer.getContext("2d"),o=this.originX,a=this.originY,s=this.radius,l=window.getComputedStyle(this.backgroundLayer,null),c=parseInt(l.getPropertyValue("--wheel-borderwidth"),10),u=l.getPropertyValue("--wheel-bordercolor").trim(),h=l.getPropertyValue("--wheel-shadow").trim();if("none"!==h){var d=h.split("px ");e=d.pop(),t=parseInt(d[0],10),r=parseInt(d[1],10),n=parseInt(d[2],10)||0}var f=s+c/2,p=s,y=s+c;"none"!==l.shadow&&(i.save(),i.beginPath(),i.arc(o,a,y,0,2*Math.PI,!1),i.shadowColor=e,i.shadowOffsetX=t,i.shadowOffsetY=r,i.shadowBlur=n,i.fillStyle="white",i.fill(),i.restore()),function(e,t){for(var r=360/(e=e||360),n=r/2,s=0;s<=360;s+=r){var l=(s-n)*(Math.PI/180),c=(s+n+1)*(Math.PI/180);i.beginPath(),i.moveTo(o,a),i.arc(o,a,p,l,c,!1),i.closePath();var u=i.createRadialGradient(o,a,0,o,a,p),h=100;if(u.addColorStop(0,"hsl(".concat(s,", 100%, ").concat(h,"%)")),t>0){for(var d=1/t,f=0,y=1;y<t;y+=1){var b=h;h=100-50*(f=y*d),u.addColorStop(f,"hsl(".concat(s,", 100%, ").concat(b,"%)")),u.addColorStop(f,"hsl(".concat(s,", 100%, ").concat(h,"%)"))}u.addColorStop(f,"hsl(".concat(s,", 100%, 50%)"))}u.addColorStop(1,"hsl(".concat(s,", 100%, 50%)")),i.fillStyle=u,i.fill()}}(this.hueSegments,this.saturationSegments),c>0&&(i.beginPath(),i.arc(o,a,f,0,2*Math.PI,!1),i.lineWidth=c,i.strokeStyle=u,i.stroke())}},{key:"drawMarker",value:function(){var e=this.interactionLayer,t=.08*this.radius,r=.15*this.radius,n=-3*r;e.marker=document.createElementNS("http://www.w3.org/2000/svg","circle"),e.marker.setAttribute("id","marker"),e.marker.setAttribute("r",t),this.marker=e.marker,e.appendChild(e.marker),e.tooltip=document.createElementNS("http://www.w3.org/2000/svg","circle"),e.tooltip.setAttribute("id","colorTooltip"),e.tooltip.setAttribute("r",r),e.tooltip.setAttribute("cx",0),e.tooltip.setAttribute("cy",n),this.tooltip=e.tooltip,e.appendChild(e.tooltip)}},{key:"segmentationChange",value:function(){this.backgroundLayer&&this.drawColorWheel()}}])&&p(t.prototype,r),i&&p(t,i),a}((0,r(11052).I)(l.H3));customElements.define("ha-color-picker",w);r(10983),r(73139),r(81303);var _,k,S,O,C,j,x,E,P,M,B,T,R,A,L=r(21668);function V(e){return(V="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function D(e){return function(e){if(Array.isArray(e))return Q(e)}(e)||Z(e)||K(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function I(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function W(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function F(e,t){return(F=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function N(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=te(e);if(t){var i=te(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return z(this,r)}}function z(e,t){return!t||"object"!==V(t)&&"function"!=typeof t?G(e):t}function G(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function J(){J=function(){return e};var e={elementsDefinitionOrder:[["method"],["field"]],initializeInstanceElements:function(e,t){["method","field"].forEach((function(r){t.forEach((function(t){t.kind===r&&"own"===t.placement&&this.defineClassElement(e,t)}),this)}),this)},initializeClassElements:function(e,t){var r=e.prototype;["method","field"].forEach((function(n){t.forEach((function(t){var i=t.placement;if(t.kind===n&&("static"===i||"prototype"===i)){var o="static"===i?e:r;this.defineClassElement(o,t)}}),this)}),this)},defineClassElement:function(e,t){var r=t.descriptor;if("field"===t.kind){var n=t.initializer;r={enumerable:r.enumerable,writable:r.writable,configurable:r.configurable,value:void 0===n?void 0:n.call(e)}}Object.defineProperty(e,t.key,r)},decorateClass:function(e,t){var r=[],n=[],i={static:[],prototype:[],own:[]};if(e.forEach((function(e){this.addElementPlacement(e,i)}),this),e.forEach((function(e){if(!X(e))return r.push(e);var t=this.decorateElement(e,i);r.push(t.element),r.push.apply(r,t.extras),n.push.apply(n,t.finishers)}),this),!t)return{elements:r,finishers:n};var o=this.decorateConstructor(r,t);return n.push.apply(n,o.finishers),o.finishers=n,o},addElementPlacement:function(e,t,r){var n=t[e.placement];if(!r&&-1!==n.indexOf(e.key))throw new TypeError("Duplicated element ("+e.key+")");n.push(e.key)},decorateElement:function(e,t){for(var r=[],n=[],i=e.decorators,o=i.length-1;o>=0;o--){var a=t[e.placement];a.splice(a.indexOf(e.key),1);var s=this.fromElementDescriptor(e),l=this.toElementFinisherExtras((0,i[o])(s)||s);e=l.element,this.addElementPlacement(e,t),l.finisher&&n.push(l.finisher);var c=l.extras;if(c){for(var u=0;u<c.length;u++)this.addElementPlacement(c[u],t);r.push.apply(r,c)}}return{element:e,finishers:n,extras:r}},decorateConstructor:function(e,t){for(var r=[],n=t.length-1;n>=0;n--){var i=this.fromClassDescriptor(e),o=this.toClassDescriptor((0,t[n])(i)||i);if(void 0!==o.finisher&&r.push(o.finisher),void 0!==o.elements){e=o.elements;for(var a=0;a<e.length-1;a++)for(var s=a+1;s<e.length;s++)if(e[a].key===e[s].key&&e[a].placement===e[s].placement)throw new TypeError("Duplicated element ("+e[a].key+")")}}return{elements:e,finishers:r}},fromElementDescriptor:function(e){var t={kind:e.kind,key:e.key,placement:e.placement,descriptor:e.descriptor};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),"field"===e.kind&&(t.initializer=e.initializer),t},toElementDescriptors:function(e){var t;if(void 0!==e)return(t=e,function(e){if(Array.isArray(e))return e}(t)||Z(t)||K(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).map((function(e){var t=this.toElementDescriptor(e);return this.disallowProperty(e,"finisher","An element descriptor"),this.disallowProperty(e,"extras","An element descriptor"),t}),this)},toElementDescriptor:function(e){var t=String(e.kind);if("method"!==t&&"field"!==t)throw new TypeError('An element descriptor\'s .kind property must be either "method" or "field", but a decorator created an element descriptor with .kind "'+t+'"');var r=q(e.key),n=String(e.placement);if("static"!==n&&"prototype"!==n&&"own"!==n)throw new TypeError('An element descriptor\'s .placement property must be one of "static", "prototype" or "own", but a decorator created an element descriptor with .placement "'+n+'"');var i=e.descriptor;this.disallowProperty(e,"elements","An element descriptor");var o={kind:t,key:r,placement:n,descriptor:Object.assign({},i)};return"field"!==t?this.disallowProperty(e,"initializer","A method descriptor"):(this.disallowProperty(i,"get","The property descriptor of a field descriptor"),this.disallowProperty(i,"set","The property descriptor of a field descriptor"),this.disallowProperty(i,"value","The property descriptor of a field descriptor"),o.initializer=e.initializer),o},toElementFinisherExtras:function(e){return{element:this.toElementDescriptor(e),finisher:$(e,"finisher"),extras:this.toElementDescriptors(e.extras)}},fromClassDescriptor:function(e){var t={kind:"class",elements:e.map(this.fromElementDescriptor,this)};return Object.defineProperty(t,Symbol.toStringTag,{value:"Descriptor",configurable:!0}),t},toClassDescriptor:function(e){var t=String(e.kind);if("class"!==t)throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator created a class descriptor with .kind "'+t+'"');this.disallowProperty(e,"key","A class descriptor"),this.disallowProperty(e,"placement","A class descriptor"),this.disallowProperty(e,"descriptor","A class descriptor"),this.disallowProperty(e,"initializer","A class descriptor"),this.disallowProperty(e,"extras","A class descriptor");var r=$(e,"finisher");return{elements:this.toElementDescriptors(e.elements),finisher:r}},runClassFinishers:function(e,t){for(var r=0;r<t.length;r++){var n=(0,t[r])(e);if(void 0!==n){if("function"!=typeof n)throw new TypeError("Finishers must return a constructor.");e=n}}return e},disallowProperty:function(e,t,r){if(void 0!==e[t])throw new TypeError(r+" can't have a ."+t+" property.")}};return e}function U(e){var t,r=q(e.key);"method"===e.kind?t={value:e.value,writable:!0,configurable:!0,enumerable:!1}:"get"===e.kind?t={get:e.value,configurable:!0,enumerable:!1}:"set"===e.kind?t={set:e.value,configurable:!0,enumerable:!1}:"field"===e.kind&&(t={configurable:!0,writable:!0,enumerable:!0});var n={kind:"field"===e.kind?"field":"method",key:r,placement:e.static?"static":"field"===e.kind?"own":"prototype",descriptor:t};return e.decorators&&(n.decorators=e.decorators),"field"===e.kind&&(n.initializer=e.value),n}function H(e,t){void 0!==e.descriptor.get?t.descriptor.get=e.descriptor.get:t.descriptor.set=e.descriptor.set}function X(e){return e.decorators&&e.decorators.length}function Y(e){return void 0!==e&&!(void 0===e.value&&void 0===e.writable)}function $(e,t){var r=e[t];if(void 0!==r&&"function"!=typeof r)throw new TypeError("Expected '"+t+"' to be a function");return r}function q(e){var t=function(e,t){if("object"!==V(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==V(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===V(t)?t:String(t)}function K(e,t){if(e){if("string"==typeof e)return Q(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Q(e,t):void 0}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Z(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function ee(e,t,r){return(ee="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=te(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function te(e){return(te=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var re=[{label:"Color",value:"color"},{label:"Temperature",value:L.JM.COLOR_TEMP}];!function(e,t,r,n){var i=J();if(n)for(var o=0;o<n.length;o++)i=n[o](i);var a=t((function(e){i.initializeInstanceElements(e,s.elements)}),r),s=i.decorateClass(function(e){for(var t=[],r=function(e){return"method"===e.kind&&e.key===o.key&&e.placement===o.placement},n=0;n<e.length;n++){var i,o=e[n];if("method"===o.kind&&(i=t.find(r)))if(Y(o.descriptor)||Y(i.descriptor)){if(X(o)||X(i))throw new ReferenceError("Duplicated methods ("+o.key+") can't be decorated.");i.descriptor=o.descriptor}else{if(X(o)){if(X(i))throw new ReferenceError("Decorators can't be placed on different accessors with for the same property ("+o.key+").");i.decorators=o.decorators}H(o,i)}else t.push(o)}return t}(a.d.map(U)),e);i.initializeClassElements(a.F,s.elements),i.runClassFinishers(a.F,s.finishers)}([(0,o.Mo)("more-info-light")],(function(e,t){var r=function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&F(e,t)}(n,t);var r=N(n);function n(){var t;W(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return t=r.call.apply(r,[this].concat(o)),e(G(t)),t}return n}(t);return{F:r,d:[{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,o.Cb)({attribute:!1})],key:"stateObj",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_brightnessSliderValue",value:function(){return 0}},{kind:"field",decorators:[(0,o.SB)()],key:"_ctSliderValue",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_cwSliderValue",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_wwSliderValue",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_wvSliderValue",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_colorBrightnessSliderValue",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_brightnessAdjusted",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_hueSegments",value:function(){return 24}},{kind:"field",decorators:[(0,o.SB)()],key:"_saturationSegments",value:function(){return 8}},{kind:"field",decorators:[(0,o.SB)()],key:"_colorPickerColor",value:void 0},{kind:"field",decorators:[(0,o.SB)()],key:"_mode",value:void 0},{kind:"method",key:"render",value:function(){var e;if(!this.hass||!this.stateObj)return(0,i.dy)(_||(_=I([""])));var t=(0,L.Fe)(this.stateObj,L.JM.COLOR_TEMP),r=(0,L.Fe)(this.stateObj,L.JM.RGBWW),n=!r&&(0,L.Fe)(this.stateObj,L.JM.RGBW),o=r||n||(0,L.Yk)(this.stateObj);return(0,i.dy)(k||(k=I(['\n <div class="content">\n ',"\n ","\n <ha-attributes\n .hass=","\n .stateObj=",'\n extra-filters="brightness,color_temp,white_value,effect_list,effect,hs_color,rgb_color,rgbw_color,rgbww_color,xy_color,min_mireds,max_mireds,entity_id,supported_color_modes,color_mode"\n ></ha-attributes>\n </div>\n '])),(0,L.sj)(this.stateObj)?(0,i.dy)(S||(S=I(["\n <ha-labeled-slider\n caption=",'\n icon="hass:brightness-5"\n min="1"\n max="100"\n value=',"\n @change=","\n pin\n ></ha-labeled-slider>\n "])),this.hass.localize("ui.card.light.brightness"),this._brightnessSliderValue,this._brightnessSliderChanged):"","on"===this.stateObj.state?(0,i.dy)(O||(O=I(["\n ","\n ","\n ","\n ","\n ","\n "])),t||o?(0,i.dy)(C||(C=I(["<hr />"]))):"",t&&o?(0,i.dy)(j||(j=I(["<ha-button-toggle-group\n fullWidth\n .buttons=","\n .active=","\n @value-changed=","\n ></ha-button-toggle-group>"])),re,this._mode,this._modeChanged):"",!t||o&&this._mode!==L.JM.COLOR_TEMP?"":(0,i.dy)(x||(x=I(['\n <ha-labeled-slider\n class="color_temp"\n caption=','\n icon="hass:thermometer"\n .min=',"\n .max=","\n .value=","\n @change=","\n pin\n ></ha-labeled-slider>\n "])),this.hass.localize("ui.card.light.color_temperature"),this.stateObj.attributes.min_mireds,this.stateObj.attributes.max_mireds,this._ctSliderValue,this._ctSliderChanged),!o||t&&"color"!==this._mode?"":(0,i.dy)(E||(E=I(['\n <div class="segmentationContainer">\n <ha-color-picker\n class="color"\n @colorselected=',"\n .desiredRgbColor=",'\n throttle="500"\n .hueSegments=',"\n .saturationSegments=",'\n >\n </ha-color-picker>\n <ha-icon-button\n icon="hass:palette"\n @click=','\n class="segmentationButton"\n ></ha-icon-button>\n </div>\n\n ',"\n ","\n ","\n "])),this._colorPicked,this._colorPickerColor,this._hueSegments,this._saturationSegments,this._segmentClick,n||r?(0,i.dy)(P||(P=I(["<ha-labeled-slider\n .caption=",'\n icon="hass:brightness-7"\n max="100"\n .value=',"\n @change=","\n pin\n ></ha-labeled-slider>"])),this.hass.localize("ui.card.light.color_brightness"),this._colorBrightnessSliderValue,this._colorBrightnessSliderChanged):"",n?(0,i.dy)(M||(M=I(["\n <ha-labeled-slider\n .caption=",'\n icon="hass:file-word-box"\n max="100"\n .name=',"\n .value=","\n @change=","\n pin\n ></ha-labeled-slider>\n "])),this.hass.localize("ui.card.light.white_value"),"wv",this._wvSliderValue,this._wvSliderChanged):"",r?(0,i.dy)(B||(B=I(["\n <ha-labeled-slider\n .caption=",'\n icon="hass:file-word-box-outline"\n max="100"\n .name=',"\n .value=","\n @change=","\n pin\n ></ha-labeled-slider>\n <ha-labeled-slider\n .caption=",'\n icon="hass:file-word-box"\n max="100"\n .name=',"\n .value=","\n @change=","\n pin\n ></ha-labeled-slider>\n "])),this.hass.localize("ui.card.light.cold_white_value"),"cw",this._cwSliderValue,this._wvSliderChanged,this.hass.localize("ui.card.light.warm_white_value"),"ww",this._wwSliderValue,this._wvSliderChanged):""),(0,a.e)(this.stateObj,L.rs)&&null!==(e=this.stateObj.attributes.effect_list)&&void 0!==e&&e.length?(0,i.dy)(T||(T=I(["\n <hr />\n <ha-paper-dropdown-menu\n .label=",'\n >\n <paper-listbox\n slot="dropdown-content"\n .selected=',"\n @iron-select=",'\n attr-for-selected="item-name"\n >',"\n </paper-listbox>\n </ha-paper-dropdown-menu>\n "])),this.hass.localize("ui.card.light.effect"),this.stateObj.attributes.effect||"",this._effectChanged,this.stateObj.attributes.effect_list.map((function(e){return(0,i.dy)(R||(R=I(["\n <paper-item .itemName=","\n >","</paper-item\n >\n "])),e,e)}))):""):"",this.hass,this.stateObj)}},{kind:"method",key:"willUpdate",value:function(e){if(ee(te(r.prototype),"willUpdate",this).call(this,e),e.has("stateObj")){var t=this.stateObj,n=e.get("stateObj");if("on"===t.state){(null==n?void 0:n.entity_id)===t.entity_id&&(null==n?void 0:n.state)===t.state||(this._mode=(0,L.Pj)(this.stateObj)?"color":L.JM.COLOR_TEMP);var i=100;if(this._brightnessAdjusted=void 0,t.attributes.color_mode===L.JM.RGB&&!(0,L.Fe)(t,L.JM.RGBWW)&&!(0,L.Fe)(t,L.JM.RGBW)){var o=Math.max.apply(Math,D(t.attributes.rgb_color));o<255&&(this._brightnessAdjusted=o,i=this._brightnessAdjusted/255*100)}this._brightnessSliderValue=Math.round(t.attributes.brightness*i/255),this._ctSliderValue=t.attributes.color_temp,this._wvSliderValue=t.attributes.color_mode===L.JM.RGBW?Math.round(100*t.attributes.rgbw_color[3]/255):void 0,this._cwSliderValue=t.attributes.color_mode===L.JM.RGBWW?Math.round(100*t.attributes.rgbww_color[3]/255):void 0,this._wwSliderValue=t.attributes.color_mode===L.JM.RGBWW?Math.round(100*t.attributes.rgbww_color[4]/255):void 0;var a=(0,L.cE)(t);this._colorBrightnessSliderValue=a?Math.round(100*Math.max.apply(Math,D(a.slice(0,3)))/255):void 0,this._colorPickerColor=null==a?void 0:a.slice(0,3)}else this._brightnessSliderValue=0}}},{kind:"method",key:"_modeChanged",value:function(e){this._mode=e.detail.value}},{kind:"method",key:"_effectChanged",value:function(e){var t=e.detail.item.itemName;t&&this.stateObj.attributes.effect!==t&&this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,effect:t})}},{kind:"method",key:"_brightnessSliderChanged",value:function(e){var t=Number(e.target.value);if(!isNaN(t))if(this._brightnessSliderValue=t,this._brightnessAdjusted){var r=this.stateObj.attributes.rgb_color||[0,0,0];this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,brightness_pct:t,rgb_color:this._adjustColorBrightness(r,this._brightnessAdjusted,!0)})}else this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,brightness_pct:t})}},{kind:"method",key:"_ctSliderChanged",value:function(e){var t=Number(e.target.value);isNaN(t)||(this._ctSliderValue=t,this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,color_temp:t}))}},{kind:"method",key:"_wvSliderChanged",value:function(e){var t=e.target,r=Number(t.value),n=t.name;if(!isNaN(r)){"wv"===n?this._wvSliderValue=r:"cw"===n?this._cwSliderValue=r:"ww"===n&&(this._wwSliderValue=r),r=Math.min(255,Math.round(255*r/100));var i=(0,L.cE)(this.stateObj);if("wv"===n){var o=i||[0,0,0,0];return o[3]=r,void this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,rgbw_color:o})}for(var a=i||[0,0,0,0,0];a.length<5;)a.push(0);a["cw"===n?3:4]=r,this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,rgbww_color:a})}}},{kind:"method",key:"_colorBrightnessSliderChanged",value:function(e){var t,r=e.target,n=Number(r.value);if(!isNaN(n)){var i=this._colorBrightnessSliderValue;this._colorBrightnessSliderValue=n,n=255*n/100;var o=(null===(t=(0,L.cE)(this.stateObj))||void 0===t?void 0:t.slice(0,3))||[255,255,255];this._setRgbWColor(this._adjustColorBrightness(i?this._adjustColorBrightness(o,255*i/100,!0):o,n))}}},{kind:"method",key:"_segmentClick",value:function(){24===this._hueSegments&&8===this._saturationSegments?(this._hueSegments=0,this._saturationSegments=0):(this._hueSegments=24,this._saturationSegments=8)}},{kind:"method",key:"_adjustColorBrightness",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(void 0!==t&&255!==t){var n=t/255;r&&(n=1/n),e[0]=Math.min(255,Math.round(e[0]*n)),e[1]=Math.min(255,Math.round(e[1]*n)),e[2]=Math.min(255,Math.round(e[2]*n))}return e}},{kind:"method",key:"_setRgbWColor",value:function(e){if((0,L.Fe)(this.stateObj,L.JM.RGBWW)){var t=this.stateObj.attributes.rgbww_color?D(this.stateObj.attributes.rgbww_color):[0,0,0,0,0];this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,rgbww_color:e.concat(t.slice(3))})}else if((0,L.Fe)(this.stateObj,L.JM.RGBW)){var r=this.stateObj.attributes.rgbw_color?D(this.stateObj.attributes.rgbw_color):[0,0,0,0];this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,rgbw_color:e.concat(r.slice(3))})}}},{kind:"method",key:"_colorPicked",value:function(e){if(this._colorPickerColor=[e.detail.rgb.r,e.detail.rgb.g,e.detail.rgb.b],(0,L.Fe)(this.stateObj,L.JM.RGBWW)||(0,L.Fe)(this.stateObj,L.JM.RGBW))this._setRgbWColor(this._colorBrightnessSliderValue?this._adjustColorBrightness([e.detail.rgb.r,e.detail.rgb.g,e.detail.rgb.b],255*this._colorBrightnessSliderValue/100):[e.detail.rgb.r,e.detail.rgb.g,e.detail.rgb.b]);else if((0,L.Fe)(this.stateObj,L.JM.RGB)){var t=[e.detail.rgb.r,e.detail.rgb.g,e.detail.rgb.b];this._brightnessAdjusted?this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,brightness_pct:this._brightnessSliderValue,rgb_color:this._adjustColorBrightness(t,this._brightnessAdjusted,!0)}):this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,rgb_color:t})}else this.hass.callService("light","turn_on",{entity_id:this.stateObj.entity_id,hs_color:[e.detail.hs.h,100*e.detail.hs.s]})}},{kind:"get",static:!0,key:"styles",value:function(){return(0,i.iv)(A||(A=I(["\n .content {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n .content > * {\n width: 100%;\n }\n\n .color_temp {\n --ha-slider-background: -webkit-linear-gradient(\n right,\n rgb(255, 160, 0) 0%,\n white 50%,\n rgb(166, 209, 255) 100%\n );\n /* The color temp minimum value shouldn't be rendered differently. It's not \"off\". */\n --paper-slider-knob-start-border-color: var(--primary-color);\n margin-bottom: 4px;\n }\n\n .segmentationContainer {\n position: relative;\n max-height: 500px;\n display: flex;\n justify-content: center;\n }\n\n ha-button-toggle-group {\n margin-bottom: 8px;\n }\n\n ha-color-picker {\n --ha-color-picker-wheel-borderwidth: 5;\n --ha-color-picker-wheel-bordercolor: white;\n --ha-color-picker-wheel-shadow: none;\n --ha-color-picker-marker-borderwidth: 2;\n --ha-color-picker-marker-bordercolor: white;\n }\n\n .segmentationButton {\n position: absolute;\n top: 5%;\n left: 0;\n color: var(--secondary-text-color);\n }\n\n paper-item {\n cursor: pointer;\n }\n\n hr {\n border-color: var(--divider-color);\n border-bottom: none;\n margin: 16px 0;\n }\n "])))}}]}}),i.oi)}}]); //# sourceMappingURL=chunk.00a2daa5a6115b659c68.js.map