platypush/platypush/backend/http/webapp/dist/static/js/1155-legacy.179db4ca.js

2 lines
14 KiB
JavaScript
Raw Normal View History

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