platypush/platypush/backend/http/webapp/dist/static/js/1340-legacy.cec09101.js

2 lines
33 KiB
JavaScript
Raw Normal View History

"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1340],{634:function(e,t,n){n.d(t,{N:function(){return a}});var i=n(9584);n(1703);function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}function l(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}n(7941),n(6977),n(1249),n(2222);var a=function(){function e(t){if(o(this,e),this.ranges={hue:[0,360],sat:[0,100],bri:[0,100],ct:[154,500]},t)for(var n=0,i=Object.keys(this.ranges);n<i.length;n++){var r=i[n];t[r]&&(this.ranges[r]=t[r])}}return l(e,[{key:"normalize",value:function(e,t,n){return n[0]+(e-t[0])*(n[1]-n[0])/(t[1]-t[0])}},{key:"hslToRgb",value:function(e,t,n){var i=[this.normalize(e,this.ranges.hue,[0,360]),this.normalize(t,this.ranges.sat,[0,100]),this.normalize(n,this.ranges.bri,[0,100])];e=i[0],t=i[1],n=i[2],n/=100;var o=t*Math.min(n,1-n)/100,r=function(t){var i=(t+e/30)%12,r=n-o*Math.max(Math.min(i-3,9-i,1),-1);return Math.round(255*r)};return[r(0),r(8),r(4)]}},{key:"rgbToHsl",value:function(e,t,n){e/=255,t/=255,n/=255;var i,o,r=Math.max(e,t,n),l=Math.min(e,t,n),a=(r+l)/2;if(r===l)i=o=0;else{var s=r-l;switch(o=a>.5?s/(2-r-l):s/(r+l),r){case e:i=(t-n)/s+(t<n?6:0);break;case t:i=(n-e)/s+2;break;case n:i=(e-t)/s+4;break}i/=6}return[parseInt(this.normalize(i,[0,1],this.ranges.hue)),parseInt(this.normalize(o,[0,1],this.ranges.sat)),parseInt(this.normalize(a,[0,1],this.ranges.bri))]}},{key:"xyToRgb",value:function(e,t,n){null==n&&(n=this.ranges.bri[1]);var i=1-e-t,o=(n/(this.ranges.bri[1]-1)).toFixed(2),r=o/t*e,l=o/t*i,a=1.656492*r-.354851*o-.255038*l,s=.707196*-r+1.655397*o+.036152*l,u=.051713*r-.121364*o+1.01153*l;return a>u&&a>s&&a>1?(s/=a,u/=a,a=1):s>u&&s>a&&s>1?(a/=s,u/=s,s=1):u>a&&u>s&&u>1&&(a/=u,s/=u,u=1),a=a<=.0031308?12.92*a:1.055*Math.pow(a,1/2.4)-.055,s=s<=.0031308?12.92*s:1.055*Math.pow(s,1/2.4)-.055,u=u<=.0031308?12.92*u:1.055*Math.pow(u,1/2.4)-.055,a=Math.round(255*a),s=Math.round(255*s),u=Math.round(255*u),isNaN(a)&&(a=0),isNaN(s)&&(s=0),isNaN(u)&&(u=0),[a,s,u].map((function(e){return Math.min(Math.max(0,e),255)}))}},{key:"rgbToXY",value:function(e,t,n){e>1&&(e/=255),t>1&&(t/=255),n>1&&(n/=255),e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var i=.664511*e+.154324*t+.162028*n,o=.283881*e+.668433*t+.047685*n,r=88e-6*e+.07231*t+.986039*n,l=parseFloat((i/(i+o+r)).toFixed(4)),a=parseFloat((o/(i+o+r)).toFixed(4));return isNaN(l)&&(l=0),isNaN(a)&&(a=0),[l,a]}},{key:"rgbToBri",value:function(e,t,n){return Math.min(2*this.rgbToHsl(e,t,n)[2],this.ranges.bri[1])}},{key:"getRGB",value:function(e){return null!=e.red&&null!=e.green&&null!=e.blue?[e.red,e.green,e.blue]:null!=e.r&&null!=e.g&&null!=e.b?[e.r,e.g,e.b]:e.rgb?e.rgb:void 0}},{key:"getXY",value:function(e){return null!=e.x&&null!=e.y?[e.x,e.y]:e.xy?e.xy:void 0}},{key:"toRGB",value:function(e){var t=this.getRGB(e);if(t)return t;var n=this.getXY(e);return n&&e.bri?this.xyToRgb.apply(this,(0,i.Z)(n).concat([e.bri])):e.hue&&e.sat&&e.bri?this.hslToRgb(e.hue,e.sat,e.bri):(console.debug("Could not determine color space"),void console.debug(e))}},{key:"toXY",value:function(e){var t=this.getXY(e);if(t&&e.bri)return[t[0],t[1],e.bri];var n=this.getRGB(e);if(n)return this.rgbToXY.apply(this,(0,i.Z)(n));if(e.hue&&e.sat&&e.bri){var o=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,(0,i.Z)(o))}console.debug("Could not determine color space"),console.debug(e)}},{key:"toHSL",value:function(e){if(e.hue&&e.sat&&e.bri)return[e.hue,e.sat,e.bri];var t=this.getRGB(e);if(t)return this.rgbToHsl.apply(this,(0,i.Z)(t));var n=this.getXY(e);if(n&&e.bri){var o=this.xyToRgb.apply(this,(0,i.Z)(n).concat([e.bri]));return this.rgbToHsl.apply(this,(0,i.Z)(o))}console.debug("Could not determine color space"),console.debug(e)}}]),e}()},542:function(e,t,
//# sourceMappingURL=1340-legacy.cec09101.js.map