platypush/platypush/backend/http/webapp/dist/static/js/1406-legacy.41c0c47e.js

2 lines
34 KiB
JavaScript
Raw Normal View History

2022-03-29 23:45:57 +02:00
"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[1406],{634:function(e,t,n){n.d(t,{N:function(){return l}});var o=n(9584);n(1703);function i(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 o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function a(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 l=function(){function e(t){if(i(this,e),this.ranges={hue:[0,360],sat:[0,100],bri:[0,100],ct:[154,500]},t)for(var n=0,o=Object.keys(this.ranges);n<o.length;n++){var r=o[n];t[r]&&(this.ranges[r]=t[r])}}return a(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 o=[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=o[0],t=o[1],n=o[2],n/=100;var i=t*Math.min(n,1-n)/100,r=function(t){var o=(t+e/30)%12,r=n-i*Math.max(Math.min(o-3,9-o,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 o,i,r=Math.max(e,t,n),a=Math.min(e,t,n),l=(r+a)/2;if(r===a)o=i=0;else{var s=r-a;switch(i=l>.5?s/(2-r-a):s/(r+a),r){case e:o=(t-n)/s+(t<n?6:0);break;case t:o=(n-e)/s+2;break;case n:o=(e-t)/s+4;break}o/=6}return[parseInt(this.normalize(o,[0,1],this.ranges.hue)),parseInt(this.normalize(i,[0,1],this.ranges.sat)),parseInt(this.normalize(l,[0,1],this.ranges.bri))]}},{key:"xyToRgb",value:function(e,t,n){null==n&&(n=this.ranges.bri[1]);var o=1-e-t,i=(n/(this.ranges.bri[1]-1)).toFixed(2),r=i/t*e,a=i/t*o,l=1.656492*r-.354851*i-.255038*a,s=.707196*-r+1.655397*i+.036152*a,u=.051713*r-.121364*i+1.01153*a;return l>u&&l>s&&l>1?(s/=l,u/=l,l=1):s>u&&s>l&&s>1?(l/=s,u/=s,s=1):u>l&&u>s&&u>1&&(l/=u,s/=u,u=1),l=l<=.0031308?12.92*l:1.055*Math.pow(l,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,l=Math.round(255*l),s=Math.round(255*s),u=Math.round(255*u),isNaN(l)&&(l=0),isNaN(s)&&(s=0),isNaN(u)&&(u=0),[l,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 o=.664511*e+.154324*t+.162028*n,i=.283881*e+.668433*t+.047685*n,r=88e-6*e+.07231*t+.986039*n,a=parseFloat((o/(o+i+r)).toFixed(4)),l=parseFloat((i/(o+i+r)).toFixed(4));return isNaN(a)&&(a=0),isNaN(l)&&(l=0),[a,l]}},{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,o.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,o.Z)(n));if(e.hue&&e.sat&&e.bri){var i=this.hslToRgb(e.hue,e.sat,e.bri);return this.rgbToXY.apply(this,(0,o.Z)(i))}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,o.Z)(t));var n=this.getXY(e);if(n&&e.bri){var i=this.xyToRgb.apply(this,(0,o.Z)(n).concat([e.bri]));return this.rgbToHsl.apply(this,(0,o.Z)(i))}console.debug("Could not determine color space"),console.debug(e)}}]),e}()},1120:function(e,t
//# sourceMappingURL=1406-legacy.41c0c47e.js.map