diff --git a/dist/chroma-light.cjs b/dist/chroma-light.cjs index 81065509..e5bd4678 100644 --- a/dist/chroma-light.cjs +++ b/dist/chroma-light.cjs @@ -182,7 +182,7 @@ }; // this gets updated automatically - var version = '2.5.0'; + var version = '2.6.0'; var chroma = function () { var args = [], len = arguments.length; diff --git a/dist/chroma-light.min.cjs b/dist/chroma-light.min.cjs index 1f49f757..99a4fda5 100644 --- a/dist/chroma-light.min.cjs +++ b/dist/chroma-light.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";function t(t,r,n){return void 0===n&&(n=1),s(l(r,t),n)}for(var r={},n=0,e=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(t):"object"==a(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0]}function u(t){if(t.length<2)return null;var r=t.length-1;return"string"==a(t[r])?t[r].toLowerCase():null}var s=Math.min,l=Math.max,c={format:{},autodetect:[]},h=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===a(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var o=u(r),i=!1;if(!o){i=!0,c.sorted||(c.autodetect=c.autodetect.sort((function(t,r){return r.p-t.p})),c.sorted=!0);for(var s=0,l=c.autodetect;s255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(f),3===e._rgb.length&&e._rgb.push(1)};h.prototype.toString=function(){return"function"==a(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var f=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f.Color,[null].concat(t)))};f.Color=h,f.version="2.5.0";var p=function(t){return Math.round(100*t)/100},g=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o=(t=i(t,"rgba"))[0],a=t[1],u=t[2],c=s(o/=255,a/=255,u/=255),h=l(o,a,u),f=(h+c)/2;return h===c?(n=0,e=Number.NaN):n=f<.5?(h-c)/(h+c):(h-c)/(2-h-c),o==h?e=(a-u)/(h-c):a==h?e=2+(u-o)/(h-c):u==h&&(e=4+(o-a)/(h-c)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},b=Math.round,d=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=u(t)||"rgb";return"hsl"==e.substr(0,3)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=u(t)||"lsa";return n[0]=p(n[0]||0),n[1]=p(100*n[1])+"%",n[2]=p(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]=n.length>3?n[3]:1,e="hsla"):n.length=3,e+"("+n.join(",")+")"}(g(n),e):(n[0]=b(n[0]),n[1]=b(n[1]),n[2]=b(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]=n.length>3?n[3]:1,e="rgba"),e+"("+n.slice(0,"rgb"===e?3:4).join(",")+")")},v=Math.round,y=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,o,a,u=(r=i(r,"hsl"))[0],s=r[1],l=r[2];if(0===s)e=o=a=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+s):l+s-l*s,p=2*l-f,g=u/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var b=0;b<3;b++)c[b]<0&&(c[b]+=1),c[b]>1&&(c[b]-=1),6*c[b]<1?h[b]=p+6*(f-p)*c[b]:2*c[b]<1?h[b]=f:3*c[b]<2?h[b]=p+(f-p)*(2/3-c[b])*6:h[b]=p;e=(t=[v(255*h[0]),v(255*h[1]),v(255*h[2])])[0],o=t[1],a=t[2]}return r.length>3?[e,o,a,r[3]]:[e,o,a,1]},w=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,m=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,k=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,_=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,M=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,x=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,F=Math.round,j=function(t){var r;if(t=t.toLowerCase().trim(),c.format.named)try{return c.format.named(t)}catch(t){}if(r=t.match(w)){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if(r=t.match(m)){for(var o=r.slice(1,5),a=0;a<4;a++)o[a]=+o[a];return o}if(r=t.match(k)){for(var i=r.slice(1,4),u=0;u<3;u++)i[u]=F(2.55*i[u]);return i[3]=1,i}if(r=t.match(_)){for(var s=r.slice(1,5),l=0;l<3;l++)s[l]=F(2.55*s[l]);return s[3]=+s[3],s}if(r=t.match(M)){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;var f=y(h);return f[3]=1,f}if(r=t.match(x)){var p=r.slice(1,4);p[1]*=.01,p[2]*=.01;var g=y(p);return g[3]=+r[4],g}};j.test=function(t){return w.test(t)||m.test(t)||k.test(t)||_.test(t)||M.test(t)||x.test(t)},h.prototype.css=function(t){return d(this._rgb,t)},f.css=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["css"])))},c.format.css=j,c.autodetect.push({p:5,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===a(t)&&j.test(t))return"css"}});var N=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,$=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,A=Math.round;h.prototype.hex=function(t){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=n[0],o=n[1],a=n[2],s=n[3],l=u(t)||"auto";void 0===s&&(s=1),"auto"===l&&(l=s<1?"rgba":"rgb");var c="000000"+((e=A(e))<<16|(o=A(o))<<8|(a=A(a))).toString(16);c=c.substr(c.length-6);var h="0"+A(255*s).toString(16);switch(h=h.substr(h.length-2),l.toLowerCase()){case"rgba":return"#"+c+h;case"argb":return"#"+h+c;default:return"#"+c}}(this._rgb,t)},f.hex=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["hex"])))},c.format.hex=function(t){if(t.match(N)){4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var r=parseInt(t,16);return[r>>16,r>>8&255,255&r,1]}if(t.match($)){5!==t.length&&9!==t.length||(t=t.substr(1)),4===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);var n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+t)},c.autodetect.push({p:4,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===a(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),h.prototype.hsl=function(){return g(this._rgb)},f.hsl=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["hsl"])))},c.format.hsl=y,c.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"hsl"))&&3===t.length)return"hsl"}});var C=18,E=.95047,O=1,S=1.08883,L=.137931034,q=.206896552,I=.12841855,B=.008856452,D=Math.pow,R=function(t){return 255*(t<=.00304?12.92*t:1.055*D(t,1/2.4)-.055)},U=function(t){return t>q?t*t*t:I*(t-L)},z=Math.pow,G=function(t){return(t/=255)<=.04045?t/12.92:z((t+.055)/1.055,2.4)},H=function(t){return t>B?z(t,1/3):t/I+L},J=function(t,r,n){return t=G(t),r=G(r),n=G(n),[H((.4124564*t+.3575761*r+.1804375*n)/E),H((.2126729*t+.7151522*r+.072175*n)/O),H((.0193339*t+.119192*r+.9503041*n)/S)]};h.prototype.lab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],o=n[1],a=n[2],u=J(e,o,a),s=u[0],l=u[1],c=116*l-16;return[c<0?0:c,500*(s-l),200*(l-u[2])]}(this._rgb)},f.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["lab"])))},c.format.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o,a=(t=i(t,"lab"))[0],u=t[1],s=t[2];return e=(a+16)/116,n=isNaN(u)?e:e+u/500,o=isNaN(s)?e:e-s/200,e=O*U(e),n=E*U(n),o=S*U(o),[R(3.2404542*n-1.5371385*e-.4985314*o),R(-.969266*n+1.8760108*e+.041556*o),R(.0556434*n-.2040259*e+1.0572252*o),t.length>3?t[3]:1]},c.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"lab"))&&3===t.length)return"lab"}});var K=Math.pow,P=Math.sign;function Q(t){var r=Math.abs(t);return r>.0031308?(P(t)||1)*(1.055*K(r,1/2.4)-.055):12.92*t}var T=Math.cbrt,V=Math.pow,W=Math.sign;function X(t){var r=Math.abs(t);return r<.04045?t/12.92:(W(t)||1)*V((r+.055)/1.055,2.4)}h.prototype.oklab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],o=n[1],a=n[2],u=[X(e/255),X(o/255),X(a/255)],s=u[0],l=u[1],c=u[2],h=T(.4122214708*s+.5363325363*l+.0514459929*c),f=T(.2119034982*s+.6806995451*l+.1073969566*c),p=T(.0883024619*s+.2817188376*l+.6299787005*c);return[.2104542553*h+.793617785*f-.0040720468*p,1.9779984951*h-2.428592205*f+.4505937099*p,.0259040371*h+.7827717662*f-.808675766*p]}(this._rgb)},f.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["oklab"])))},c.format.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lab"))[0],e=t[1],o=t[2],a=K(n+.3963377774*e+.2158037573*o,3),u=K(n-.1055613458*e-.0638541728*o,3),s=K(n-.0894841775*e-1.291485548*o,3);return[255*Q(4.0767416621*a-3.3077115913*u+.2309699292*s),255*Q(-1.2684380046*a+2.6097574011*u-.3413193965*s),255*Q(-.0041960863*a-.7034186147*u+1.707614701*s),t.length>3?t[3]:1]},c.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"oklab"))&&3===t.length)return"oklab"}});var Y=Math.round;h.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Y)},h.prototype.rgba=function(t){return void 0===t&&(t=!0),this._rgb.slice(0,4).map((function(r,n){return n<3?!1===t?r:Y(r):r}))},f.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["rgb"])))},c.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba");return void 0===n[3]&&(n[3]=1),n},c.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"rgba"))&&(3===t.length||4===t.length&&"number"==a(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),h.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===a(t)?r?(this._rgb[3]=t,this):new h([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},h.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=C*t,new h(r,"lab").alpha(this.alpha(),!0)},h.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},h.prototype.darker=h.prototype.darken,h.prototype.brighter=h.prototype.brighten,h.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],o=this[n]();if(e){var a=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(a>-1)return o[a];throw new Error("unknown channel "+e+" in mode "+n)}return o};var Z={};function tt(t,r,n){void 0===n&&(n=.5);for(var e=[],o=arguments.length-3;o-- >0;)e[o]=arguments[o+3];var i=e[0]||"lrgb";if(Z[i]||e.length||(i=Object.keys(Z)[0]),!Z[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==a(t)&&(t=new h(t)),"object"!==a(r)&&(r=new h(r)),Z[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}h.prototype.mix=h.prototype.interpolate=function(t,r){void 0===r&&(r=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return tt.apply(void 0,[this,t,r].concat(n))},h.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),o=e[0],i=e[1],u=this[o]();if(i){var s=o.indexOf(i)-("ok"===o.substr(0,2)?2:0);if(s>-1){if("string"==a(r))switch(r.charAt(0)){case"+":case"-":u[s]+=+r;break;case"*":u[s]*=+r.substr(1);break;case"/":u[s]/=+r.substr(1);break;default:u[s]=+r}else{if("number"!==a(r))throw new Error("unsupported value for Color.set");u[s]=r}var l=new h(u,o);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+i+" in mode "+o)}return u},h.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"white",t].concat(r))},h.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"black",t].concat(r))};var rt=Math.sqrt,nt=Math.pow;Z.lrgb=function(t,r,n){var e=t._rgb,o=e[0],a=e[1],i=e[2],u=r._rgb,s=u[0],l=u[1],c=u[2];return new h(rt(nt(o,2)*(1-n)+nt(s,2)*n),rt(nt(a,2)*(1-n)+nt(l,2)*n),rt(nt(i,2)*(1-n)+nt(c,2)*n),"rgb")};Z.oklab=function(t,r,n){var e=t.oklab(),o=r.oklab();return new h(e[0]+n*(o[0]-e[0]),e[1]+n*(o[1]-e[1]),e[2]+n*(o[2]-e[2]),"oklab")},f.mix=f.interpolate=require("./src/generator/mix"),f.valid=require("./src/utils/valid"),module.exports=f})); +!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";function t(t,r,n){return void 0===n&&(n=1),s(l(r,t),n)}for(var r={},n=0,e=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(t):"object"==a(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0]}function u(t){if(t.length<2)return null;var r=t.length-1;return"string"==a(t[r])?t[r].toLowerCase():null}var s=Math.min,l=Math.max,c={format:{},autodetect:[]},h=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===a(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var o=u(r),i=!1;if(!o){i=!0,c.sorted||(c.autodetect=c.autodetect.sort((function(t,r){return r.p-t.p})),c.sorted=!0);for(var s=0,l=c.autodetect;s255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(f),3===e._rgb.length&&e._rgb.push(1)};h.prototype.toString=function(){return"function"==a(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var f=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(f.Color,[null].concat(t)))};f.Color=h,f.version="2.6.0";var p=function(t){return Math.round(100*t)/100},g=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o=(t=i(t,"rgba"))[0],a=t[1],u=t[2],c=s(o/=255,a/=255,u/=255),h=l(o,a,u),f=(h+c)/2;return h===c?(n=0,e=Number.NaN):n=f<.5?(h-c)/(h+c):(h-c)/(2-h-c),o==h?e=(a-u)/(h-c):a==h?e=2+(u-o)/(h-c):u==h&&(e=4+(o-a)/(h-c)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},b=Math.round,d=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=u(t)||"rgb";return"hsl"==e.substr(0,3)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=u(t)||"lsa";return n[0]=p(n[0]||0),n[1]=p(100*n[1])+"%",n[2]=p(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]=n.length>3?n[3]:1,e="hsla"):n.length=3,e+"("+n.join(",")+")"}(g(n),e):(n[0]=b(n[0]),n[1]=b(n[1]),n[2]=b(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]=n.length>3?n[3]:1,e="rgba"),e+"("+n.slice(0,"rgb"===e?3:4).join(",")+")")},v=Math.round,y=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,o,a,u=(r=i(r,"hsl"))[0],s=r[1],l=r[2];if(0===s)e=o=a=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+s):l+s-l*s,p=2*l-f,g=u/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var b=0;b<3;b++)c[b]<0&&(c[b]+=1),c[b]>1&&(c[b]-=1),6*c[b]<1?h[b]=p+6*(f-p)*c[b]:2*c[b]<1?h[b]=f:3*c[b]<2?h[b]=p+(f-p)*(2/3-c[b])*6:h[b]=p;e=(t=[v(255*h[0]),v(255*h[1]),v(255*h[2])])[0],o=t[1],a=t[2]}return r.length>3?[e,o,a,r[3]]:[e,o,a,1]},w=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,m=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,k=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,_=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,M=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,x=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,F=Math.round,j=function(t){var r;if(t=t.toLowerCase().trim(),c.format.named)try{return c.format.named(t)}catch(t){}if(r=t.match(w)){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if(r=t.match(m)){for(var o=r.slice(1,5),a=0;a<4;a++)o[a]=+o[a];return o}if(r=t.match(k)){for(var i=r.slice(1,4),u=0;u<3;u++)i[u]=F(2.55*i[u]);return i[3]=1,i}if(r=t.match(_)){for(var s=r.slice(1,5),l=0;l<3;l++)s[l]=F(2.55*s[l]);return s[3]=+s[3],s}if(r=t.match(M)){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;var f=y(h);return f[3]=1,f}if(r=t.match(x)){var p=r.slice(1,4);p[1]*=.01,p[2]*=.01;var g=y(p);return g[3]=+r[4],g}};j.test=function(t){return w.test(t)||m.test(t)||k.test(t)||_.test(t)||M.test(t)||x.test(t)},h.prototype.css=function(t){return d(this._rgb,t)},f.css=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["css"])))},c.format.css=j,c.autodetect.push({p:5,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===a(t)&&j.test(t))return"css"}});var N=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,$=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,A=Math.round;h.prototype.hex=function(t){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=n[0],o=n[1],a=n[2],s=n[3],l=u(t)||"auto";void 0===s&&(s=1),"auto"===l&&(l=s<1?"rgba":"rgb");var c="000000"+((e=A(e))<<16|(o=A(o))<<8|(a=A(a))).toString(16);c=c.substr(c.length-6);var h="0"+A(255*s).toString(16);switch(h=h.substr(h.length-2),l.toLowerCase()){case"rgba":return"#"+c+h;case"argb":return"#"+h+c;default:return"#"+c}}(this._rgb,t)},f.hex=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["hex"])))},c.format.hex=function(t){if(t.match(N)){4!==t.length&&7!==t.length||(t=t.substr(1)),3===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]);var r=parseInt(t,16);return[r>>16,r>>8&255,255&r,1]}if(t.match($)){5!==t.length&&9!==t.length||(t=t.substr(1)),4===t.length&&(t=(t=t.split(""))[0]+t[0]+t[1]+t[1]+t[2]+t[2]+t[3]+t[3]);var n=parseInt(t,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+t)},c.autodetect.push({p:4,test:function(t){for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];if(!r.length&&"string"===a(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),h.prototype.hsl=function(){return g(this._rgb)},f.hsl=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["hsl"])))},c.format.hsl=y,c.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"hsl"))&&3===t.length)return"hsl"}});var C=18,E=.95047,O=1,S=1.08883,L=.137931034,q=.206896552,I=.12841855,B=.008856452,D=Math.pow,R=function(t){return 255*(t<=.00304?12.92*t:1.055*D(t,1/2.4)-.055)},U=function(t){return t>q?t*t*t:I*(t-L)},z=Math.pow,G=function(t){return(t/=255)<=.04045?t/12.92:z((t+.055)/1.055,2.4)},H=function(t){return t>B?z(t,1/3):t/I+L},J=function(t,r,n){return t=G(t),r=G(r),n=G(n),[H((.4124564*t+.3575761*r+.1804375*n)/E),H((.2126729*t+.7151522*r+.072175*n)/O),H((.0193339*t+.119192*r+.9503041*n)/S)]};h.prototype.lab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],o=n[1],a=n[2],u=J(e,o,a),s=u[0],l=u[1],c=116*l-16;return[c<0?0:c,500*(s-l),200*(l-u[2])]}(this._rgb)},f.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["lab"])))},c.format.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o,a=(t=i(t,"lab"))[0],u=t[1],s=t[2];return e=(a+16)/116,n=isNaN(u)?e:e+u/500,o=isNaN(s)?e:e-s/200,e=O*U(e),n=E*U(n),o=S*U(o),[R(3.2404542*n-1.5371385*e-.4985314*o),R(-.969266*n+1.8760108*e+.041556*o),R(.0556434*n-.2040259*e+1.0572252*o),t.length>3?t[3]:1]},c.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"lab"))&&3===t.length)return"lab"}});var K=Math.pow,P=Math.sign;function Q(t){var r=Math.abs(t);return r>.0031308?(P(t)||1)*(1.055*K(r,1/2.4)-.055):12.92*t}var T=Math.cbrt,V=Math.pow,W=Math.sign;function X(t){var r=Math.abs(t);return r<.04045?t/12.92:(W(t)||1)*V((r+.055)/1.055,2.4)}h.prototype.oklab=function(){return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],o=n[1],a=n[2],u=[X(e/255),X(o/255),X(a/255)],s=u[0],l=u[1],c=u[2],h=T(.4122214708*s+.5363325363*l+.0514459929*c),f=T(.2119034982*s+.6806995451*l+.1073969566*c),p=T(.0883024619*s+.2817188376*l+.6299787005*c);return[.2104542553*h+.793617785*f-.0040720468*p,1.9779984951*h-2.428592205*f+.4505937099*p,.0259040371*h+.7827717662*f-.808675766*p]}(this._rgb)},f.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["oklab"])))},c.format.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lab"))[0],e=t[1],o=t[2],a=K(n+.3963377774*e+.2158037573*o,3),u=K(n-.1055613458*e-.0638541728*o,3),s=K(n-.0894841775*e-1.291485548*o,3);return[255*Q(4.0767416621*a-3.3077115913*u+.2309699292*s),255*Q(-1.2684380046*a+2.6097574011*u-.3413193965*s),255*Q(-.0041960863*a-.7034186147*u+1.707614701*s),t.length>3?t[3]:1]},c.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"oklab"))&&3===t.length)return"oklab"}});var Y=Math.round;h.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Y)},h.prototype.rgba=function(t){return void 0===t&&(t=!0),this._rgb.slice(0,4).map((function(r,n){return n<3?!1===t?r:Y(r):r}))},f.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(h,[null].concat(t,["rgb"])))},c.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba");return void 0===n[3]&&(n[3]=1),n},c.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===a(t=i(t,"rgba"))&&(3===t.length||4===t.length&&"number"==a(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),h.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===a(t)?r?(this._rgb[3]=t,this):new h([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},h.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=C*t,new h(r,"lab").alpha(this.alpha(),!0)},h.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},h.prototype.darker=h.prototype.darken,h.prototype.brighter=h.prototype.brighten,h.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],o=this[n]();if(e){var a=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(a>-1)return o[a];throw new Error("unknown channel "+e+" in mode "+n)}return o};var Z={};function tt(t,r,n){void 0===n&&(n=.5);for(var e=[],o=arguments.length-3;o-- >0;)e[o]=arguments[o+3];var i=e[0]||"lrgb";if(Z[i]||e.length||(i=Object.keys(Z)[0]),!Z[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==a(t)&&(t=new h(t)),"object"!==a(r)&&(r=new h(r)),Z[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}h.prototype.mix=h.prototype.interpolate=function(t,r){void 0===r&&(r=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return tt.apply(void 0,[this,t,r].concat(n))},h.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),o=e[0],i=e[1],u=this[o]();if(i){var s=o.indexOf(i)-("ok"===o.substr(0,2)?2:0);if(s>-1){if("string"==a(r))switch(r.charAt(0)){case"+":case"-":u[s]+=+r;break;case"*":u[s]*=+r.substr(1);break;case"/":u[s]/=+r.substr(1);break;default:u[s]=+r}else{if("number"!==a(r))throw new Error("unsupported value for Color.set");u[s]=r}var l=new h(u,o);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+i+" in mode "+o)}return u},h.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"white",t].concat(r))},h.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return tt.apply(void 0,[this,"black",t].concat(r))};var rt=Math.sqrt,nt=Math.pow;Z.lrgb=function(t,r,n){var e=t._rgb,o=e[0],a=e[1],i=e[2],u=r._rgb,s=u[0],l=u[1],c=u[2];return new h(rt(nt(o,2)*(1-n)+nt(s,2)*n),rt(nt(a,2)*(1-n)+nt(l,2)*n),rt(nt(i,2)*(1-n)+nt(c,2)*n),"rgb")};Z.oklab=function(t,r,n){var e=t.oklab(),o=r.oklab();return new h(e[0]+n*(o[0]-e[0]),e[1]+n*(o[1]-e[1]),e[2]+n*(o[2]-e[2]),"oklab")},f.mix=f.interpolate=require("./src/generator/mix"),f.valid=require("./src/utils/valid"),module.exports=f})); diff --git a/dist/chroma.cjs b/dist/chroma.cjs index 4f5c47d2..1eef66f3 100644 --- a/dist/chroma.cjs +++ b/dist/chroma.cjs @@ -190,7 +190,7 @@ }; // this gets updated automatically - var version = '2.5.0'; + var version = '2.6.0'; var chroma = function () { var args = [], len = arguments.length; @@ -2802,7 +2802,7 @@ /* * interpolates between a set of colors uzing a bezier spline - * blend mode formulas taken from http://www.venture-ware.com/kevin/coding/lets-learn-math-photoshop-blend-modes/ + * blend mode formulas taken from https://web.archive.org/web/20180110014946/http://www.venture-ware.com/kevin/coding/lets-learn-math-photoshop-blend-modes/ */ diff --git a/dist/chroma.min.cjs b/dist/chroma.min.cjs index ec461792..c86b7a2b 100644 --- a/dist/chroma.min.cjs +++ b/dist/chroma.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=e()}(this,(function(){"use strict";function r(r,e,t){return void 0===e&&(e=0),void 0===t&&(t=1),l(h(e,r),t)}function e(e){e._clipped=!1,e._unclipped=e.slice(0);for(var t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=r(e[t],0,255)):3===t&&(e[t]=r(e[t],0,1));return e}for(var t={},n=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(r):"object"==o(r[0])&&e?e.split("").filter((function(e){return void 0!==r[0][e]})).map((function(e){return r[0][e]})):r[0]}function c(r){if(r.length<2)return null;var e=r.length-1;return"string"==o(r[e])?r[e].toLowerCase():null}var i=Math.PI,l=Math.min,h=Math.max,d=2*i,s=i/3,b=i/180,g=180/i,p={format:{},autodetect:[]},v=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=c(r),f=!1;if(!a){f=!0,p.sorted||(p.autodetect=p.autodetect.sort((function(r,e){return e.p-r.p})),p.sorted=!0);for(var u=0,i=p.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[t>=1?0:255*(1-t)*(1-f),n>=1?0:255*(1-n)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var w=function(r){return Math.round(100*r)/100},k=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a=(r=u(r,"rgba"))[0],f=r[1],o=r[2],c=l(a/=255,f/=255,o/=255),i=h(a,f,o),d=(i+c)/2;return i===c?(t=0,n=Number.NaN):t=d<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?n=(f-o)/(i-c):f==i?n=2+(o-a)/(i-c):o==i&&(n=4+(a-f)/(i-c)),(n*=60)<0&&(n+=360),r.length>3&&void 0!==r[3]?[n,t,d,r[3]]:[n,t,d]},M=Math.round,N=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba"),n=c(r)||"rgb";return"hsl"==n.substr(0,3)?function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"hsla"),n=c(r)||"lsa";return t[0]=w(t[0]||0),t[1]=w(100*t[1])+"%",t[2]=w(100*t[2])+"%","hsla"===n||t.length>3&&t[3]<1?(t[3]=t.length>3?t[3]:1,n="hsla"):t.length=3,n+"("+t.join(",")+")"}(k(t),n):(t[0]=M(t[0]),t[1]=M(t[1]),t[2]=M(t[2]),("rgba"===n||t.length>3&&t[3]<1)&&(t[3]=t.length>3?t[3]:1,n="rgba"),n+"("+t.slice(0,"rgb"===n?3:4).join(",")+")")},_=Math.round,x=function(){for(var r,e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=u(e,"hsl"))[0],c=e[1],i=e[2];if(0===c)n=a=f=255*i;else{var l=[0,0,0],h=[0,0,0],d=i<.5?i*(1+c):i+c-i*c,s=2*i-d,b=o/360;l[0]=b+1/3,l[1]=b,l[2]=b-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?h[g]=s+6*(d-s)*l[g]:2*l[g]<1?h[g]=d:3*l[g]<2?h[g]=s+(d-s)*(2/3-l[g])*6:h[g]=s;n=(r=[_(255*h[0]),_(255*h[1]),_(255*h[2])])[0],a=r[1],f=r[2]}return e.length>3?[n,a,f,e[3]]:[n,a,f,1]},A=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,F=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,E=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,j=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,q=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,L=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,O=Math.round,P=function(r){var e;if(r=r.toLowerCase().trim(),p.format.named)try{return p.format.named(r)}catch(r){}if(e=r.match(A)){for(var t=e.slice(1,4),n=0;n<3;n++)t[n]=+t[n];return t[3]=1,t}if(e=r.match(F)){for(var a=e.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if(e=r.match(E)){for(var o=e.slice(1,4),u=0;u<3;u++)o[u]=O(2.55*o[u]);return o[3]=1,o}if(e=r.match(j)){for(var c=e.slice(1,5),i=0;i<3;i++)c[i]=O(2.55*c[i]);return c[3]=+c[3],c}if(e=r.match(q)){var l=e.slice(1,4);l[1]*=.01,l[2]*=.01;var h=x(l);return h[3]=1,h}if(e=r.match(L)){var d=e.slice(1,4);d[1]*=.01,d[2]*=.01;var s=x(d);return s[3]=+e[4],s}};P.test=function(r){return A.test(r)||F.test(r)||E.test(r)||j.test(r)||q.test(r)||L.test(r)},v.prototype.css=function(r){return N(this._rgb,r)},m.css=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["css"])))},p.format.css=P,p.autodetect.push({p:5,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&P.test(r))return"css"}}),p.format.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t},m.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["gl"])))},v.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var G=Math.floor;v.prototype.hcg=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=u(r,"rgb"),a=n[0],f=n[1],o=n[2],c=l(a,f,o),i=h(a,f,o),d=i-c,s=100*d/255,b=c/(255-d)*100;return 0===d?t=Number.NaN:(a===i&&(t=(f-o)/d),f===i&&(t=2+(o-a)/d),o===i&&(t=4+(a-f)/d),(t*=60)<0&&(t+=360)),[t,s,b]}(this._rgb)},m.hcg=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hcg"])))},p.format.hcg=function(){for(var r,e,t,n,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,d=(o=u(o,"hcg"))[0],s=o[1],b=o[2];b*=255;var g=255*s;if(0===s)i=l=h=b;else{360===d&&(d=0),d>360&&(d-=360),d<0&&(d+=360);var p=G(d/=60),v=d-p,m=b*(1-s),y=m+g*(1-v),w=m+g*v,k=m+g;switch(p){case 0:i=(r=[k,w,m])[0],l=r[1],h=r[2];break;case 1:i=(e=[y,k,m])[0],l=e[1],h=e[2];break;case 2:i=(t=[m,k,w])[0],l=t[1],h=t[2];break;case 3:i=(n=[m,y,k])[0],l=n[1],h=n[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],h=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},p.autodetect.push({p:1,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var B=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,C=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,R=function(r){if(r.match(B)){4!==r.length&&7!==r.length||(r=r.substr(1)),3===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var e=parseInt(r,16);return[e>>16,e>>8&255,255&e,1]}if(r.match(C)){5!==r.length&&9!==r.length||(r=r.substr(1)),4===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var t=parseInt(r,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error("unknown hex color: "+r)},S=Math.round,$=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba"),n=t[0],a=t[1],f=t[2],o=t[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((n=S(n))<<16|(a=S(a))<<8|(f=S(f))).toString(16);l=l.substr(l.length-6);var h="0"+S(255*o).toString(16);switch(h=h.substr(h.length-2),i.toLowerCase()){case"rgba":return"#"+l+h;case"argb":return"#"+h+l;default:return"#"+l}};v.prototype.hex=function(r){return $(this._rgb,r)},m.hex=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hex"])))},p.format.hex=R,p.autodetect.push({p:4,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Y=Math.cos,z=Math.min,I=Math.sqrt,U=Math.acos;v.prototype.hsi=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=u(r,"rgb"),a=n[0],f=n[1],o=n[2],c=z(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?t=NaN:(t=(a-f+(a-o))/2,t/=I((a-f)*(a-f)+(a-o)*(f-o)),t=U(t),o>f&&(t=d-t),t/=d),[360*t,l,i]}(this._rgb)},m.hsi=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsi"])))},p.format.hsi=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=u(e,"hsi"))[0],c=e[1],i=e[2];return isNaN(o)&&(o=0),isNaN(c)&&(c=0),o>360&&(o-=360),o<0&&(o+=360),(o/=360)<1/3?a=1-((f=(1-c)/3)+(n=(1+c*Y(d*o)/Y(s-d*o))/3)):o<2/3?f=1-((n=(1-c)/3)+(a=(1+c*Y(d*(o-=1/3))/Y(s-d*o))/3)):n=1-((a=(1-c)/3)+(f=(1+c*Y(d*(o-=2/3))/Y(s-d*o))/3)),[255*(n=r(i*n*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),e.length>3?e[3]:1]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),v.prototype.hsl=function(){return k(this._rgb)},m.hsl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsl"])))},p.format.hsl=x,p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var V=Math.floor,X=Math.min,D=Math.max;v.prototype.hsv=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=X(f,o,c),l=D(f,o,c),h=l-i;return a=l/255,0===l?(t=Number.NaN,n=0):(n=h/l,f===l&&(t=(o-c)/h),o===l&&(t=2+(c-f)/h),c===l&&(t=4+(f-o)/h),(t*=60)<0&&(t+=360)),[t,n,a]}(this._rgb)},m.hsv=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsv"])))},p.format.hsv=function(){for(var r,e,t,n,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,d=(o=u(o,"hsv"))[0],s=o[1],b=o[2];if(b*=255,0===s)i=l=h=b;else{360===d&&(d=0),d>360&&(d-=360),d<0&&(d+=360);var g=V(d/=60),p=d-g,v=b*(1-s),m=b*(1-s*p),y=b*(1-s*(1-p));switch(g){case 0:i=(r=[b,y,v])[0],l=r[1],h=r[2];break;case 1:i=(e=[m,b,v])[0],l=e[1],h=e[2];break;case 2:i=(t=[v,b,y])[0],l=t[1],h=t[2];break;case 3:i=(n=[v,m,b])[0],l=n[1],h=n[2];break;case 4:i=(a=[y,v,b])[0],l=a[1],h=a[2];break;case 5:i=(f=[b,v,m])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}});var T=18,H=.95047,J=1,K=1.08883,Q=.137931034,W=.206896552,Z=.12841855,rr=.008856452,er=Math.pow,tr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=u(r,"lab"))[0],o=r[1],c=r[2];return n=(f+16)/116,t=isNaN(o)?n:n+o/500,a=isNaN(c)?n:n-c/200,n=J*ar(n),t=H*ar(t),a=K*ar(a),[nr(3.2404542*t-1.5371385*n-.4985314*a),nr(-.969266*t+1.8760108*n+.041556*a),nr(.0556434*t-.2040259*n+1.0572252*a),r.length>3?r[3]:1]},nr=function(r){return 255*(r<=.00304?12.92*r:1.055*er(r,1/2.4)-.055)},ar=function(r){return r>W?r*r*r:Z*(r-Q)},fr=Math.pow,or=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=ir(n,a,f),c=o[0],i=o[1],l=116*i-16;return[l<0?0:l,500*(c-i),200*(i-o[2])]},ur=function(r){return(r/=255)<=.04045?r/12.92:fr((r+.055)/1.055,2.4)},cr=function(r){return r>rr?fr(r,1/3):r/Z+Q},ir=function(r,e,t){return r=ur(r),e=ur(e),t=ur(t),[cr((.4124564*r+.3575761*e+.1804375*t)/H),cr((.2126729*r+.7151522*e+.072175*t)/J),cr((.0193339*r+.119192*e+.9503041*t)/K)]};v.prototype.lab=function(){return or(this._rgb)},m.lab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["lab"])))},p.format.lab=tr,p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});var lr=Math.sin,hr=Math.cos,dr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"lch"),n=t[0],a=t[1],f=t[2];return isNaN(f)&&(f=0),[n,hr(f*=b)*a,lr(f)*a]},sr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lch"))[0],n=r[1],a=r[2],f=dr(t,n,a),o=f[0],c=f[1],i=f[2],l=tr(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},br=Math.sqrt,gr=Math.atan2,pr=Math.round,vr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"lab"),n=t[0],a=t[1],f=t[2],o=br(a*a+f*f),c=(gr(f,a)*g+360)%360;return 0===pr(1e4*o)&&(c=Number.NaN),[n,o,c]},mr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=or(n,a,f),c=o[0],i=o[1],l=o[2];return vr(c,i,l)};v.prototype.lch=function(){return mr(this._rgb)},v.prototype.hcl=function(){return mr(this._rgb).reverse()},m.lch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["lch"])))},m.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hcl"])))},p.format.lch=sr,p.format.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"hcl").reverse();return sr.apply(void 0,t)},["lch","hcl"].forEach((function(r){return p.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if("array"===o(e=u(e,r))&&3===e.length)return r}})}));var yr={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};v.prototype.name=function(){for(var r=$(this._rgb,"rgb"),e=0,t=Object.keys(yr);e0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&yr[r.toLowerCase()])return"named"}});v.prototype.num=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb");return(t[0]<<16)+(t[1]<<8)+t[2]}(this._rgb)},m.num=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["num"])))},p.format.num=function(r){if("number"==o(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},p.autodetect.push({p:5,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var wr=Math.round;v.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(wr)},v.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(e,t){return t<3?!1===r?e:wr(e):e}))},m.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["rgb"])))},p.format.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba");return void 0===t[3]&&(t[3]=1),t},p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"rgba"))&&(3===r.length||4===r.length&&"number"==o(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var kr=Math.log,Mr=function(r){var e,t,n,a=r/100;return a<66?(e=255,t=a<6?0:-155.25485562709179-.44596950469579133*(t=a-2)+104.49216199393888*kr(t),n=a<20?0:.8274096064007395*(n=a-10)-254.76935184120902+115.67994401066147*kr(n)):(e=351.97690566805693+.114206453784165*(e=a-55)-40.25366309332127*kr(e),t=325.4494125711974+.07943456536662342*(t=a-50)-28.0852963507957*kr(t),n=255),[e,t,n,1]},Nr=Math.round;v.prototype.temp=v.prototype.kelvin=v.prototype.temperature=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];for(var t,n=u(r,"rgb"),a=n[0],f=n[2],o=1e3,c=4e4;c-o>.4;){var i=Mr(t=.5*(c+o));i[2]/i[0]>=f/a?c=t:o=t}return Nr(t)}(this._rgb)},m.temp=m.kelvin=m.temperature=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["temp"])))},p.format.temp=p.format.kelvin=p.format.temperature=Mr;var _r=Math.pow,xr=Math.sign,Ar=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lab"))[0],n=r[1],a=r[2],f=_r(t+.3963377774*n+.2158037573*a,3),o=_r(t-.1055613458*n-.0638541728*a,3),c=_r(t-.0894841775*n-1.291485548*a,3);return[255*Fr(4.0767416621*f-3.3077115913*o+.2309699292*c),255*Fr(-1.2684380046*f+2.6097574011*o-.3413193965*c),255*Fr(-.0041960863*f-.7034186147*o+1.707614701*c),r.length>3?r[3]:1]};function Fr(r){var e=Math.abs(r);return e>.0031308?(xr(r)||1)*(1.055*_r(e,1/2.4)-.055):12.92*r}var Er=Math.cbrt,jr=Math.pow,qr=Math.sign,Lr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=[Or(n/255),Or(a/255),Or(f/255)],c=o[0],i=o[1],l=o[2],h=Er(.4122214708*c+.5363325363*i+.0514459929*l),d=Er(.2119034982*c+.6806995451*i+.1073969566*l),s=Er(.0883024619*c+.2817188376*i+.6299787005*l);return[.2104542553*h+.793617785*d-.0040720468*s,1.9779984951*h-2.428592205*d+.4505937099*s,.0259040371*h+.7827717662*d-.808675766*s]};function Or(r){var e=Math.abs(r);return e<.04045?r/12.92:(qr(r)||1)*jr((e+.055)/1.055,2.4)}v.prototype.oklab=function(){return Lr(this._rgb)},m.oklab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["oklab"])))},p.format.oklab=Ar,p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}});v.prototype.oklch=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=Lr(n,a,f),c=o[0],i=o[1],l=o[2];return vr(c,i,l)}(this._rgb)},m.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["oklch"])))},p.format.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lch"))[0],n=r[1],a=r[2],f=dr(t,n,a),o=f[0],c=f[1],i=f[2],l=Ar(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}}),v.prototype.alpha=function(r,e){return void 0===e&&(e=!1),void 0!==r&&"number"===o(r)?e?(this._rgb[3]=r,this):new v([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},v.prototype.clipped=function(){return this._rgb._clipped||!1},v.prototype.darken=function(r){void 0===r&&(r=1);var e=this.lab();return e[0]-=T*r,new v(e,"lab").alpha(this.alpha(),!0)},v.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},v.prototype.darker=v.prototype.darken,v.prototype.brighter=v.prototype.brighten,v.prototype.get=function(r){var e=r.split("."),t=e[0],n=e[1],a=this[t]();if(n){var f=t.indexOf(n)-("ok"===t.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+n+" in mode "+t)}return a};var Pr=Math.pow;v.prototype.luminance=function(r,e){if(void 0===e&&(e="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new v([0,0,0,this._rgb[3]],"rgb");if(1===r)return new v([255,255,255,this._rgb[3]],"rgb");var t=this.luminance(),n=20,a=function(t,f){var o=t.interpolate(f,.5,e),u=o.luminance();return Math.abs(r-u)<1e-7||!n--?o:u>r?a(t,o):a(o,f)},f=(t>r?a(new v([0,0,0]),this):a(this,new v([255,255,255]))).rgb();return new v(f.concat([this._rgb[3]]))}return Gr.apply(void 0,this._rgb.slice(0,3))};var Gr=function(r,e,t){return.2126*(r=Br(r))+.7152*(e=Br(e))+.0722*(t=Br(t))},Br=function(r){return(r/=255)<=.03928?r/12.92:Pr((r+.055)/1.055,2.4)},Cr={};function Rr(r,e,t){void 0===t&&(t=.5);for(var n=[],a=arguments.length-3;a-- >0;)n[a]=arguments[a+3];var f=n[0]||"lrgb";if(Cr[f]||n.length||(f=Object.keys(Cr)[0]),!Cr[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new v(r)),"object"!==o(e)&&(e=new v(e)),Cr[f](r,e,t).alpha(r.alpha()+t*(e.alpha()-r.alpha()))}v.prototype.mix=v.prototype.interpolate=function(r,e){void 0===e&&(e=.5);for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return Rr.apply(void 0,[this,r,e].concat(t))},v.prototype.premultiply=function(r){void 0===r&&(r=!1);var e=this._rgb,t=e[3];return r?(this._rgb=[e[0]*t,e[1]*t,e[2]*t,t],this):new v([e[0]*t,e[1]*t,e[2]*t,t],"rgb")},v.prototype.saturate=function(r){void 0===r&&(r=1);var e=this.lch();return e[1]+=T*r,e[1]<0&&(e[1]=0),new v(e,"lch").alpha(this.alpha(),!0)},v.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},v.prototype.set=function(r,e,t){void 0===t&&(t=!1);var n=r.split("."),a=n[0],f=n[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(e))switch(e.charAt(0)){case"+":case"-":u[c]+=+e;break;case"*":u[c]*=+e.substr(1);break;case"/":u[c]/=+e.substr(1);break;default:u[c]=+e}else{if("number"!==o(e))throw new Error("unsupported value for Color.set");u[c]=e}var i=new v(u,a);return t?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},v.prototype.tint=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"white",r].concat(e))},v.prototype.shade=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"black",r].concat(e))};Cr.rgb=function(r,e,t){var n=r._rgb,a=e._rgb;return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"rgb")};var Sr=Math.sqrt,$r=Math.pow;Cr.lrgb=function(r,e,t){var n=r._rgb,a=n[0],f=n[1],o=n[2],u=e._rgb,c=u[0],i=u[1],l=u[2];return new v(Sr($r(a,2)*(1-t)+$r(c,2)*t),Sr($r(f,2)*(1-t)+$r(i,2)*t),Sr($r(o,2)*(1-t)+$r(l,2)*t),"rgb")};function Yr(r,e,t,n){var a,f,o,u,c,i,l,h,d,s,b,g,p;return"hsl"===n?(o=r.hsl(),u=e.hsl()):"hsv"===n?(o=r.hsv(),u=e.hsv()):"hcg"===n?(o=r.hcg(),u=e.hcg()):"hsi"===n?(o=r.hsi(),u=e.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=r.hcl(),u=e.hcl()):"oklch"===n&&(o=r.oklch().reverse(),u=e.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||(c=(a=o)[0],l=a[1],d=a[2],i=(f=u)[0],h=f[1],s=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=d&&0!=d||"hsv"==n||(b=h)):(g=c,1!=s&&0!=s||"hsv"==n||(b=l)):g=c+t*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+t*(h-l)),p=d+t*(s-d),new v("oklch"===n?[p,b,g]:[g,b,p],n)}Cr.lab=function(r,e,t){var n=r.lab(),a=e.lab();return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"lab")};var zr=function(r,e,t){return Yr(r,e,t,"lch")};Cr.lch=zr,Cr.hcl=zr;Cr.num=function(r,e,t){var n=r.num(),a=e.num();return new v(n+t*(a-n),"num")};Cr.hcg=function(r,e,t){return Yr(r,e,t,"hcg")};Cr.hsi=function(r,e,t){return Yr(r,e,t,"hsi")};Cr.hsl=function(r,e,t){return Yr(r,e,t,"hsl")};Cr.hsv=function(r,e,t){return Yr(r,e,t,"hsv")};Cr.oklab=function(r,e,t){var n=r.oklab(),a=e.oklab();return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"oklab")};Cr.oklch=function(r,e,t){return Yr(r,e,t,"oklch")};var Ir=Math.pow,Ur=Math.sqrt,Vr=Math.PI,Xr=Math.cos,Dr=Math.sin,Tr=Math.atan2;var Hr=function(r,t){for(var n=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new v(e(a))},Jr=Math.pow;function Kr(e){var t="rgb",n=m("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],h=!1,d=0,s=1,b=!1,g={},p=!0,v=1,y=function(r){if((r=r||["#fff","#000"])&&"string"===o(r)&&m.brewer&&m.brewer[r.toLowerCase()]&&(r=m.brewer[r.toLowerCase()]),"array"===o(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var e=0;e2){var b=function(r){if(null!=i){for(var e=i.length-1,t=0;t=i[t];)t++;return t-1}return 0}(e);h=b/(i.length-2)}else h=s!==d?(e-d)/(s-d):1;h=k(h),a||(h=w(h)),1!==v&&(h=Jr(h,v)),h=r(h=c[0]+h*(1-c[0]-c[1]),0,1);var y=Math.floor(1e4*h);if(p&&g[y])f=g[y];else{if("array"===o(l))for(var M=0;M=N&&M===u.length-1){f=l[M];break}if(h>N&&h2){var c=r.map((function(e,t){return t/(r.length-1)})),i=r.map((function(r){return(r-d)/(s-d)}));i.every((function(r,e){return c[e]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var e=0;r>=i[e+1];)e++;var t=(r-i[e])/(i[e+1]-i[e]);return c[e]+t*(c[e+1]-c[e])})}}return f=[d,s],_},_.mode=function(r){return arguments.length?(t=r,N(),_):t},_.range=function(r,e){return y(r),_},_.out=function(r){return h=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),w=b?function(r){for(var e=M(0,!0).lab()[0],t=M(1,!0).lab()[0],n=e>t,a=M(r,!0).lab()[0],f=e+(t-e)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)n&&(o*=-1),o<0?(u=r,r+=.5*(c-r)):(c=r,r+=.5*(u-r)),a=M(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===o(r)&&(r=[r,r]),c=r,_):c},_.colors=function(r,t){arguments.length<2&&(t="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===r)n=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;n=function(r,e){for(var t=[],n=ra;n?f++:f--)t.push(f);return t}(0,r).map((function(e){return _(a+e/(r-1)*o)}))}else{e=[];var u=[];if(i&&i.length>2)for(var c=1,h=i.length,d=1<=h;d?ch;d?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;n=u.map((function(r){return _(r)}))}return m[t]&&(n=n.map((function(r){return r[t]()}))),n},_.cache=function(r){return null!=r?(p=r,_):p},_.gamma=function(r){return null!=r?(v=r,_):v},_.nodata=function(r){return null!=r?(n=m(r),_):n},_}var Qr=function(r,e,t){if(!Qr[t])throw new Error("unknown blend mode "+t);return Qr[t](r,e)},Wr=function(r){return function(e,t){var n=m(t).rgb(),a=m(e).rgb();return m.rgb(r(n,a))}},Zr=function(r){return function(e,t){var n=[];return n[0]=r(e[0],t[0]),n[1]=r(e[1],t[1]),n[2]=r(e[2],t[2]),n}};Qr.normal=Wr(Zr((function(r){return r}))),Qr.multiply=Wr(Zr((function(r,e){return r*e/255}))),Qr.screen=Wr(Zr((function(r,e){return 255*(1-(1-r/255)*(1-e/255))}))),Qr.overlay=Wr(Zr((function(r,e){return e<128?2*r*e/255:255*(1-2*(1-r/255)*(1-e/255))}))),Qr.darken=Wr(Zr((function(r,e){return r>e?e:r}))),Qr.lighten=Wr(Zr((function(r,e){return r>e?r:e}))),Qr.dodge=Wr(Zr((function(r,e){return 255===r||(r=e/255*255/(1-r/255))>255?255:r}))),Qr.burn=Wr(Zr((function(r,e){return 255*(1-(1-e/255)/(r/255))})));var re=Math.pow,ee=Math.sin,te=Math.cos;var ne=Math.floor,ae=Math.random;var fe=Math.log,oe=Math.pow,ue=Math.floor,ce=Math.abs;function ie(r,e){void 0===e&&(e=null);var t={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===o(r)&&(r=Object.values(r)),r.forEach((function(r){e&&"object"===o(r)&&(r=r[e]),null==r||isNaN(r)||(t.values.push(r),t.sum+=r,rt.max&&(t.max=r),t.count+=1)})),t.domain=[t.min,t.max],t.limits=function(r,e){return le(t,r,e)},t}function le(r,e,t){void 0===e&&(e="equal"),void 0===t&&(t=7),"array"==o(r)&&(r=ie(r));var n=r.min,a=r.max,f=r.values.sort((function(r,e){return r-e}));if(1===t)return[n,a];var u=[];if("c"===e.substr(0,1)&&(u.push(n),u.push(a)),"e"===e.substr(0,1)){u.push(n);for(var c=1;c 0");var i=Math.LOG10E*fe(n),l=Math.LOG10E*fe(a);u.push(n);for(var h=1;h200&&(w=!1)}for(var C={},R=0;R=360;)b-=360;o[s]=b}else o[s]=o[s]/u[s];return d/=n,new v(o,e).alpha(d>.99999?1:d,!0)},bezier:function(r){var e=function(r){var e,t,n,a,f,o,u;if(2===(r=r.map((function(r){return new v(r)}))).length)e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],a=function(r){var e=[0,1,2].map((function(e){return f[e]+r*(o[e]-f[e])}));return new v(e,"lab")};else if(3===r.length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],u=t[2],a=function(r){var e=[0,1,2].map((function(e){return(1-r)*(1-r)*f[e]+2*(1-r)*r*o[e]+r*r*u[e]}));return new v(e,"lab")};else if(4===r.length){var c;n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],c=n[3],a=function(r){var e=[0,1,2].map((function(e){return(1-r)*(1-r)*(1-r)*f[e]+3*(1-r)*(1-r)*r*o[e]+3*(1-r)*r*r*u[e]+r*r*r*c[e]}));return new v(e,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,h;i=r.map((function(r){return r.lab()})),h=r.length-1,l=function(r){for(var e=[1,1],t=1;tn?(t+.05)/(n+.05):(n+.05)/(t+.05)},deltaE:function(r,e,t,n,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*we)},o=function(r){return 2*we*r/360};r=new v(r),e=new v(e);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],h=Array.from(e.lab()),d=h[0],s=h[1],b=h[2],g=(c+d)/2,p=(he(de(i,2)+de(l,2))+he(de(s,2)+de(b,2)))/2,m=.5*(1-he(de(p,7)/(de(p,7)+de(25,7)))),y=i*(1+m),w=s*(1+m),k=he(de(y,2)+de(l,2)),M=he(de(w,2)+de(b,2)),N=(k+M)/2,_=f(ge(l,y)),x=f(ge(b,w)),A=_>=0?_:_+360,F=x>=0?x:x+360,E=pe(A-F)>180?(A+F+360)/2:(A+F)/2,j=1-.17*ve(o(E-30))+.24*ve(o(2*E))+.32*ve(o(3*E+6))-.2*ve(o(4*E-63)),q=F-A;q=pe(q)<=180?q:F<=A?q+360:q-360,q=2*he(k*M)*me(o(q)/2);var L=d-c,O=M-k,P=1+.015*de(g-50,2)/he(20+de(g-50,2)),G=1+.045*N,B=1+.015*N*j,C=30*ye(-de((E-275)/25,2)),R=-(2*he(de(N,7)/(de(N,7)+de(25,7))))*me(2*o(C)),S=he(de(L/(t*P),2)+de(O/(n*G),2)+de(q/(a*B),2)+R*(O/(n*G))*(q/(a*B)));return be(0,se(100,S))},distance:function(r,e,t){void 0===t&&(t="lab"),r=new v(r),e=new v(e);var n=r.get(t),a=e.get(t),f=0;for(var o in n){var u=(n[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},limits:le,valid:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];try{return new(Function.prototype.bind.apply(v,[null].concat(r))),!0}catch(r){return!1}},scales:ke,input:p,colors:yr,brewer:Me}),m})); +!function(r,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=e()}(this,(function(){"use strict";function r(r,e,t){return void 0===e&&(e=0),void 0===t&&(t=1),l(h(e,r),t)}function e(e){e._clipped=!1,e._unclipped=e.slice(0);for(var t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=r(e[t],0,255)):3===t&&(e[t]=r(e[t],0,1));return e}for(var t={},n=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];n=3?Array.prototype.slice.call(r):"object"==o(r[0])&&e?e.split("").filter((function(e){return void 0!==r[0][e]})).map((function(e){return r[0][e]})):r[0]}function c(r){if(r.length<2)return null;var e=r.length-1;return"string"==o(r[e])?r[e].toLowerCase():null}var i=Math.PI,l=Math.min,h=Math.max,d=2*i,s=i/3,b=i/180,g=180/i,p={format:{},autodetect:[]},v=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=c(r),f=!1;if(!a){f=!0,p.sorted||(p.autodetect=p.autodetect.sort((function(r,e){return e.p-r.p})),p.sorted=!0);for(var u=0,i=p.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[t>=1?0:255*(1-t)*(1-f),n>=1?0:255*(1-n)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var w=function(r){return Math.round(100*r)/100},k=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a=(r=u(r,"rgba"))[0],f=r[1],o=r[2],c=l(a/=255,f/=255,o/=255),i=h(a,f,o),d=(i+c)/2;return i===c?(t=0,n=Number.NaN):t=d<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?n=(f-o)/(i-c):f==i?n=2+(o-a)/(i-c):o==i&&(n=4+(a-f)/(i-c)),(n*=60)<0&&(n+=360),r.length>3&&void 0!==r[3]?[n,t,d,r[3]]:[n,t,d]},M=Math.round,N=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba"),n=c(r)||"rgb";return"hsl"==n.substr(0,3)?function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"hsla"),n=c(r)||"lsa";return t[0]=w(t[0]||0),t[1]=w(100*t[1])+"%",t[2]=w(100*t[2])+"%","hsla"===n||t.length>3&&t[3]<1?(t[3]=t.length>3?t[3]:1,n="hsla"):t.length=3,n+"("+t.join(",")+")"}(k(t),n):(t[0]=M(t[0]),t[1]=M(t[1]),t[2]=M(t[2]),("rgba"===n||t.length>3&&t[3]<1)&&(t[3]=t.length>3?t[3]:1,n="rgba"),n+"("+t.slice(0,"rgb"===n?3:4).join(",")+")")},_=Math.round,x=function(){for(var r,e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=u(e,"hsl"))[0],c=e[1],i=e[2];if(0===c)n=a=f=255*i;else{var l=[0,0,0],h=[0,0,0],d=i<.5?i*(1+c):i+c-i*c,s=2*i-d,b=o/360;l[0]=b+1/3,l[1]=b,l[2]=b-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?h[g]=s+6*(d-s)*l[g]:2*l[g]<1?h[g]=d:3*l[g]<2?h[g]=s+(d-s)*(2/3-l[g])*6:h[g]=s;n=(r=[_(255*h[0]),_(255*h[1]),_(255*h[2])])[0],a=r[1],f=r[2]}return e.length>3?[n,a,f,e[3]]:[n,a,f,1]},A=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,F=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,E=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,j=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,q=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,L=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,O=Math.round,P=function(r){var e;if(r=r.toLowerCase().trim(),p.format.named)try{return p.format.named(r)}catch(r){}if(e=r.match(A)){for(var t=e.slice(1,4),n=0;n<3;n++)t[n]=+t[n];return t[3]=1,t}if(e=r.match(F)){for(var a=e.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if(e=r.match(E)){for(var o=e.slice(1,4),u=0;u<3;u++)o[u]=O(2.55*o[u]);return o[3]=1,o}if(e=r.match(j)){for(var c=e.slice(1,5),i=0;i<3;i++)c[i]=O(2.55*c[i]);return c[3]=+c[3],c}if(e=r.match(q)){var l=e.slice(1,4);l[1]*=.01,l[2]*=.01;var h=x(l);return h[3]=1,h}if(e=r.match(L)){var d=e.slice(1,4);d[1]*=.01,d[2]*=.01;var s=x(d);return s[3]=+e[4],s}};P.test=function(r){return A.test(r)||F.test(r)||E.test(r)||j.test(r)||q.test(r)||L.test(r)},v.prototype.css=function(r){return N(this._rgb,r)},m.css=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["css"])))},p.format.css=P,p.autodetect.push({p:5,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&P.test(r))return"css"}}),p.format.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba");return t[0]*=255,t[1]*=255,t[2]*=255,t},m.gl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["gl"])))},v.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var G=Math.floor;v.prototype.hcg=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=u(r,"rgb"),a=n[0],f=n[1],o=n[2],c=l(a,f,o),i=h(a,f,o),d=i-c,s=100*d/255,b=c/(255-d)*100;return 0===d?t=Number.NaN:(a===i&&(t=(f-o)/d),f===i&&(t=2+(o-a)/d),o===i&&(t=4+(a-f)/d),(t*=60)<0&&(t+=360)),[t,s,b]}(this._rgb)},m.hcg=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hcg"])))},p.format.hcg=function(){for(var r,e,t,n,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,d=(o=u(o,"hcg"))[0],s=o[1],b=o[2];b*=255;var g=255*s;if(0===s)i=l=h=b;else{360===d&&(d=0),d>360&&(d-=360),d<0&&(d+=360);var p=G(d/=60),v=d-p,m=b*(1-s),y=m+g*(1-v),w=m+g*v,k=m+g;switch(p){case 0:i=(r=[k,w,m])[0],l=r[1],h=r[2];break;case 1:i=(e=[y,k,m])[0],l=e[1],h=e[2];break;case 2:i=(t=[m,k,w])[0],l=t[1],h=t[2];break;case 3:i=(n=[m,y,k])[0],l=n[1],h=n[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],h=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},p.autodetect.push({p:1,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var B=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,C=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,R=function(r){if(r.match(B)){4!==r.length&&7!==r.length||(r=r.substr(1)),3===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]);var e=parseInt(r,16);return[e>>16,e>>8&255,255&e,1]}if(r.match(C)){5!==r.length&&9!==r.length||(r=r.substr(1)),4===r.length&&(r=(r=r.split(""))[0]+r[0]+r[1]+r[1]+r[2]+r[2]+r[3]+r[3]);var t=parseInt(r,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((255&t)/255*100)/100]}throw new Error("unknown hex color: "+r)},S=Math.round,$=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba"),n=t[0],a=t[1],f=t[2],o=t[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((n=S(n))<<16|(a=S(a))<<8|(f=S(f))).toString(16);l=l.substr(l.length-6);var h="0"+S(255*o).toString(16);switch(h=h.substr(h.length-2),i.toLowerCase()){case"rgba":return"#"+l+h;case"argb":return"#"+h+l;default:return"#"+l}};v.prototype.hex=function(r){return $(this._rgb,r)},m.hex=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hex"])))},p.format.hex=R,p.autodetect.push({p:4,test:function(r){for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Y=Math.cos,z=Math.min,I=Math.sqrt,U=Math.acos;v.prototype.hsi=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n=u(r,"rgb"),a=n[0],f=n[1],o=n[2],c=z(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?t=NaN:(t=(a-f+(a-o))/2,t/=I((a-f)*(a-f)+(a-o)*(f-o)),t=U(t),o>f&&(t=d-t),t/=d),[360*t,l,i]}(this._rgb)},m.hsi=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsi"])))},p.format.hsi=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n,a,f,o=(e=u(e,"hsi"))[0],c=e[1],i=e[2];return isNaN(o)&&(o=0),isNaN(c)&&(c=0),o>360&&(o-=360),o<0&&(o+=360),(o/=360)<1/3?a=1-((f=(1-c)/3)+(n=(1+c*Y(d*o)/Y(s-d*o))/3)):o<2/3?f=1-((n=(1-c)/3)+(a=(1+c*Y(d*(o-=1/3))/Y(s-d*o))/3)):n=1-((a=(1-c)/3)+(f=(1+c*Y(d*(o-=2/3))/Y(s-d*o))/3)),[255*(n=r(i*n*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),e.length>3?e[3]:1]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),v.prototype.hsl=function(){return k(this._rgb)},m.hsl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsl"])))},p.format.hsl=x,p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var V=Math.floor,X=Math.min,D=Math.max;v.prototype.hsv=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=X(f,o,c),l=D(f,o,c),h=l-i;return a=l/255,0===l?(t=Number.NaN,n=0):(n=h/l,f===l&&(t=(o-c)/h),o===l&&(t=2+(c-f)/h),c===l&&(t=4+(f-o)/h),(t*=60)<0&&(t+=360)),[t,n,a]}(this._rgb)},m.hsv=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hsv"])))},p.format.hsv=function(){for(var r,e,t,n,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,d=(o=u(o,"hsv"))[0],s=o[1],b=o[2];if(b*=255,0===s)i=l=h=b;else{360===d&&(d=0),d>360&&(d-=360),d<0&&(d+=360);var g=V(d/=60),p=d-g,v=b*(1-s),m=b*(1-s*p),y=b*(1-s*(1-p));switch(g){case 0:i=(r=[b,y,v])[0],l=r[1],h=r[2];break;case 1:i=(e=[m,b,v])[0],l=e[1],h=e[2];break;case 2:i=(t=[v,b,y])[0],l=t[1],h=t[2];break;case 3:i=(n=[v,m,b])[0],l=n[1],h=n[2];break;case 4:i=(a=[y,v,b])[0],l=a[1],h=a[2];break;case 5:i=(f=[b,v,m])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}});var T=18,H=.95047,J=1,K=1.08883,Q=.137931034,W=.206896552,Z=.12841855,rr=.008856452,er=Math.pow,tr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t,n,a,f=(r=u(r,"lab"))[0],o=r[1],c=r[2];return n=(f+16)/116,t=isNaN(o)?n:n+o/500,a=isNaN(c)?n:n-c/200,n=J*ar(n),t=H*ar(t),a=K*ar(a),[nr(3.2404542*t-1.5371385*n-.4985314*a),nr(-.969266*t+1.8760108*n+.041556*a),nr(.0556434*t-.2040259*n+1.0572252*a),r.length>3?r[3]:1]},nr=function(r){return 255*(r<=.00304?12.92*r:1.055*er(r,1/2.4)-.055)},ar=function(r){return r>W?r*r*r:Z*(r-Q)},fr=Math.pow,or=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=ir(n,a,f),c=o[0],i=o[1],l=116*i-16;return[l<0?0:l,500*(c-i),200*(i-o[2])]},ur=function(r){return(r/=255)<=.04045?r/12.92:fr((r+.055)/1.055,2.4)},cr=function(r){return r>rr?fr(r,1/3):r/Z+Q},ir=function(r,e,t){return r=ur(r),e=ur(e),t=ur(t),[cr((.4124564*r+.3575761*e+.1804375*t)/H),cr((.2126729*r+.7151522*e+.072175*t)/J),cr((.0193339*r+.119192*e+.9503041*t)/K)]};v.prototype.lab=function(){return or(this._rgb)},m.lab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["lab"])))},p.format.lab=tr,p.autodetect.push({p:2,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});var lr=Math.sin,hr=Math.cos,dr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"lch"),n=t[0],a=t[1],f=t[2];return isNaN(f)&&(f=0),[n,hr(f*=b)*a,lr(f)*a]},sr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lch"))[0],n=r[1],a=r[2],f=dr(t,n,a),o=f[0],c=f[1],i=f[2],l=tr(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},br=Math.sqrt,gr=Math.atan2,pr=Math.round,vr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"lab"),n=t[0],a=t[1],f=t[2],o=br(a*a+f*f),c=(gr(f,a)*g+360)%360;return 0===pr(1e4*o)&&(c=Number.NaN),[n,o,c]},mr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=or(n,a,f),c=o[0],i=o[1],l=o[2];return vr(c,i,l)};v.prototype.lch=function(){return mr(this._rgb)},v.prototype.hcl=function(){return mr(this._rgb).reverse()},m.lch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["lch"])))},m.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["hcl"])))},p.format.lch=sr,p.format.hcl=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"hcl").reverse();return sr.apply(void 0,t)},["lch","hcl"].forEach((function(r){return p.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if("array"===o(e=u(e,r))&&3===e.length)return r}})}));var yr={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",laserlemon:"#ffff54",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrod:"#fafad2",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",maroon2:"#7f0000",maroon3:"#b03060",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",purple2:"#7f007f",purple3:"#a020f0",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"};v.prototype.name=function(){for(var r=$(this._rgb,"rgb"),e=0,t=Object.keys(yr);e0;)e[t]=arguments[t+1];if(!e.length&&"string"===o(r)&&yr[r.toLowerCase()])return"named"}});v.prototype.num=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb");return(t[0]<<16)+(t[1]<<8)+t[2]}(this._rgb)},m.num=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["num"])))},p.format.num=function(r){if("number"==o(r)&&r>=0&&r<=16777215)return[r>>16,r>>8&255,255&r,1];throw new Error("unknown num color: "+r)},p.autodetect.push({p:5,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var wr=Math.round;v.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(wr)},v.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(e,t){return t<3?!1===r?e:wr(e):e}))},m.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["rgb"])))},p.format.rgb=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgba");return void 0===t[3]&&(t[3]=1),t},p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"rgba"))&&(3===r.length||4===r.length&&"number"==o(r[3])&&r[3]>=0&&r[3]<=1))return"rgb"}});var kr=Math.log,Mr=function(r){var e,t,n,a=r/100;return a<66?(e=255,t=a<6?0:-155.25485562709179-.44596950469579133*(t=a-2)+104.49216199393888*kr(t),n=a<20?0:.8274096064007395*(n=a-10)-254.76935184120902+115.67994401066147*kr(n)):(e=351.97690566805693+.114206453784165*(e=a-55)-40.25366309332127*kr(e),t=325.4494125711974+.07943456536662342*(t=a-50)-28.0852963507957*kr(t),n=255),[e,t,n,1]},Nr=Math.round;v.prototype.temp=v.prototype.kelvin=v.prototype.temperature=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];for(var t,n=u(r,"rgb"),a=n[0],f=n[2],o=1e3,c=4e4;c-o>.4;){var i=Mr(t=.5*(c+o));i[2]/i[0]>=f/a?c=t:o=t}return Nr(t)}(this._rgb)},m.temp=m.kelvin=m.temperature=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["temp"])))},p.format.temp=p.format.kelvin=p.format.temperature=Mr;var _r=Math.pow,xr=Math.sign,Ar=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lab"))[0],n=r[1],a=r[2],f=_r(t+.3963377774*n+.2158037573*a,3),o=_r(t-.1055613458*n-.0638541728*a,3),c=_r(t-.0894841775*n-1.291485548*a,3);return[255*Fr(4.0767416621*f-3.3077115913*o+.2309699292*c),255*Fr(-1.2684380046*f+2.6097574011*o-.3413193965*c),255*Fr(-.0041960863*f-.7034186147*o+1.707614701*c),r.length>3?r[3]:1]};function Fr(r){var e=Math.abs(r);return e>.0031308?(xr(r)||1)*(1.055*_r(e,1/2.4)-.055):12.92*r}var Er=Math.cbrt,jr=Math.pow,qr=Math.sign,Lr=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=[Or(n/255),Or(a/255),Or(f/255)],c=o[0],i=o[1],l=o[2],h=Er(.4122214708*c+.5363325363*i+.0514459929*l),d=Er(.2119034982*c+.6806995451*i+.1073969566*l),s=Er(.0883024619*c+.2817188376*i+.6299787005*l);return[.2104542553*h+.793617785*d-.0040720468*s,1.9779984951*h-2.428592205*d+.4505937099*s,.0259040371*h+.7827717662*d-.808675766*s]};function Or(r){var e=Math.abs(r);return e<.04045?r/12.92:(qr(r)||1)*jr((e+.055)/1.055,2.4)}v.prototype.oklab=function(){return Lr(this._rgb)},m.oklab=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["oklab"])))},p.format.oklab=Ar,p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}});v.prototype.oklch=function(){return function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=u(r,"rgb"),n=t[0],a=t[1],f=t[2],o=Lr(n,a,f),c=o[0],i=o[1],l=o[2];return vr(c,i,l)}(this._rgb)},m.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];return new(Function.prototype.bind.apply(v,[null].concat(r,["oklch"])))},p.format.oklch=function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];var t=(r=u(r,"lch"))[0],n=r[1],a=r[2],f=dr(t,n,a),o=f[0],c=f[1],i=f[2],l=Ar(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},p.autodetect.push({p:3,test:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}}),v.prototype.alpha=function(r,e){return void 0===e&&(e=!1),void 0!==r&&"number"===o(r)?e?(this._rgb[3]=r,this):new v([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},v.prototype.clipped=function(){return this._rgb._clipped||!1},v.prototype.darken=function(r){void 0===r&&(r=1);var e=this.lab();return e[0]-=T*r,new v(e,"lab").alpha(this.alpha(),!0)},v.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},v.prototype.darker=v.prototype.darken,v.prototype.brighter=v.prototype.brighten,v.prototype.get=function(r){var e=r.split("."),t=e[0],n=e[1],a=this[t]();if(n){var f=t.indexOf(n)-("ok"===t.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+n+" in mode "+t)}return a};var Pr=Math.pow;v.prototype.luminance=function(r,e){if(void 0===e&&(e="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new v([0,0,0,this._rgb[3]],"rgb");if(1===r)return new v([255,255,255,this._rgb[3]],"rgb");var t=this.luminance(),n=20,a=function(t,f){var o=t.interpolate(f,.5,e),u=o.luminance();return Math.abs(r-u)<1e-7||!n--?o:u>r?a(t,o):a(o,f)},f=(t>r?a(new v([0,0,0]),this):a(this,new v([255,255,255]))).rgb();return new v(f.concat([this._rgb[3]]))}return Gr.apply(void 0,this._rgb.slice(0,3))};var Gr=function(r,e,t){return.2126*(r=Br(r))+.7152*(e=Br(e))+.0722*(t=Br(t))},Br=function(r){return(r/=255)<=.03928?r/12.92:Pr((r+.055)/1.055,2.4)},Cr={};function Rr(r,e,t){void 0===t&&(t=.5);for(var n=[],a=arguments.length-3;a-- >0;)n[a]=arguments[a+3];var f=n[0]||"lrgb";if(Cr[f]||n.length||(f=Object.keys(Cr)[0]),!Cr[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new v(r)),"object"!==o(e)&&(e=new v(e)),Cr[f](r,e,t).alpha(r.alpha()+t*(e.alpha()-r.alpha()))}v.prototype.mix=v.prototype.interpolate=function(r,e){void 0===e&&(e=.5);for(var t=[],n=arguments.length-2;n-- >0;)t[n]=arguments[n+2];return Rr.apply(void 0,[this,r,e].concat(t))},v.prototype.premultiply=function(r){void 0===r&&(r=!1);var e=this._rgb,t=e[3];return r?(this._rgb=[e[0]*t,e[1]*t,e[2]*t,t],this):new v([e[0]*t,e[1]*t,e[2]*t,t],"rgb")},v.prototype.saturate=function(r){void 0===r&&(r=1);var e=this.lch();return e[1]+=T*r,e[1]<0&&(e[1]=0),new v(e,"lch").alpha(this.alpha(),!0)},v.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},v.prototype.set=function(r,e,t){void 0===t&&(t=!1);var n=r.split("."),a=n[0],f=n[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(e))switch(e.charAt(0)){case"+":case"-":u[c]+=+e;break;case"*":u[c]*=+e.substr(1);break;case"/":u[c]/=+e.substr(1);break;default:u[c]=+e}else{if("number"!==o(e))throw new Error("unsupported value for Color.set");u[c]=e}var i=new v(u,a);return t?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},v.prototype.tint=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"white",r].concat(e))},v.prototype.shade=function(r){void 0===r&&(r=.5);for(var e=[],t=arguments.length-1;t-- >0;)e[t]=arguments[t+1];return Rr.apply(void 0,[this,"black",r].concat(e))};Cr.rgb=function(r,e,t){var n=r._rgb,a=e._rgb;return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"rgb")};var Sr=Math.sqrt,$r=Math.pow;Cr.lrgb=function(r,e,t){var n=r._rgb,a=n[0],f=n[1],o=n[2],u=e._rgb,c=u[0],i=u[1],l=u[2];return new v(Sr($r(a,2)*(1-t)+$r(c,2)*t),Sr($r(f,2)*(1-t)+$r(i,2)*t),Sr($r(o,2)*(1-t)+$r(l,2)*t),"rgb")};function Yr(r,e,t,n){var a,f,o,u,c,i,l,h,d,s,b,g,p;return"hsl"===n?(o=r.hsl(),u=e.hsl()):"hsv"===n?(o=r.hsv(),u=e.hsv()):"hcg"===n?(o=r.hcg(),u=e.hcg()):"hsi"===n?(o=r.hsi(),u=e.hsi()):"lch"===n||"hcl"===n?(n="hcl",o=r.hcl(),u=e.hcl()):"oklch"===n&&(o=r.oklch().reverse(),u=e.oklch().reverse()),"h"!==n.substr(0,1)&&"oklch"!==n||(c=(a=o)[0],l=a[1],d=a[2],i=(f=u)[0],h=f[1],s=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=d&&0!=d||"hsv"==n||(b=h)):(g=c,1!=s&&0!=s||"hsv"==n||(b=l)):g=c+t*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+t*(h-l)),p=d+t*(s-d),new v("oklch"===n?[p,b,g]:[g,b,p],n)}Cr.lab=function(r,e,t){var n=r.lab(),a=e.lab();return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"lab")};var zr=function(r,e,t){return Yr(r,e,t,"lch")};Cr.lch=zr,Cr.hcl=zr;Cr.num=function(r,e,t){var n=r.num(),a=e.num();return new v(n+t*(a-n),"num")};Cr.hcg=function(r,e,t){return Yr(r,e,t,"hcg")};Cr.hsi=function(r,e,t){return Yr(r,e,t,"hsi")};Cr.hsl=function(r,e,t){return Yr(r,e,t,"hsl")};Cr.hsv=function(r,e,t){return Yr(r,e,t,"hsv")};Cr.oklab=function(r,e,t){var n=r.oklab(),a=e.oklab();return new v(n[0]+t*(a[0]-n[0]),n[1]+t*(a[1]-n[1]),n[2]+t*(a[2]-n[2]),"oklab")};Cr.oklch=function(r,e,t){return Yr(r,e,t,"oklch")};var Ir=Math.pow,Ur=Math.sqrt,Vr=Math.PI,Xr=Math.cos,Dr=Math.sin,Tr=Math.atan2;var Hr=function(r,t){for(var n=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new v(e(a))},Jr=Math.pow;function Kr(e){var t="rgb",n=m("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],h=!1,d=0,s=1,b=!1,g={},p=!0,v=1,y=function(r){if((r=r||["#fff","#000"])&&"string"===o(r)&&m.brewer&&m.brewer[r.toLowerCase()]&&(r=m.brewer[r.toLowerCase()]),"array"===o(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var e=0;e2){var b=function(r){if(null!=i){for(var e=i.length-1,t=0;t=i[t];)t++;return t-1}return 0}(e);h=b/(i.length-2)}else h=s!==d?(e-d)/(s-d):1;h=k(h),a||(h=w(h)),1!==v&&(h=Jr(h,v)),h=r(h=c[0]+h*(1-c[0]-c[1]),0,1);var y=Math.floor(1e4*h);if(p&&g[y])f=g[y];else{if("array"===o(l))for(var M=0;M=N&&M===u.length-1){f=l[M];break}if(h>N&&h2){var c=r.map((function(e,t){return t/(r.length-1)})),i=r.map((function(r){return(r-d)/(s-d)}));i.every((function(r,e){return c[e]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var e=0;r>=i[e+1];)e++;var t=(r-i[e])/(i[e+1]-i[e]);return c[e]+t*(c[e+1]-c[e])})}}return f=[d,s],_},_.mode=function(r){return arguments.length?(t=r,N(),_):t},_.range=function(r,e){return y(r),_},_.out=function(r){return h=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),w=b?function(r){for(var e=M(0,!0).lab()[0],t=M(1,!0).lab()[0],n=e>t,a=M(r,!0).lab()[0],f=e+(t-e)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)n&&(o*=-1),o<0?(u=r,r+=.5*(c-r)):(c=r,r+=.5*(u-r)),a=M(r,!0).lab()[0],o=a-f;return r}:function(r){return r},_},_.padding=function(r){return null!=r?("number"===o(r)&&(r=[r,r]),c=r,_):c},_.colors=function(r,t){arguments.length<2&&(t="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===r)n=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;n=function(r,e){for(var t=[],n=ra;n?f++:f--)t.push(f);return t}(0,r).map((function(e){return _(a+e/(r-1)*o)}))}else{e=[];var u=[];if(i&&i.length>2)for(var c=1,h=i.length,d=1<=h;d?ch;d?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;n=u.map((function(r){return _(r)}))}return m[t]&&(n=n.map((function(r){return r[t]()}))),n},_.cache=function(r){return null!=r?(p=r,_):p},_.gamma=function(r){return null!=r?(v=r,_):v},_.nodata=function(r){return null!=r?(n=m(r),_):n},_}var Qr=function(r,e,t){if(!Qr[t])throw new Error("unknown blend mode "+t);return Qr[t](r,e)},Wr=function(r){return function(e,t){var n=m(t).rgb(),a=m(e).rgb();return m.rgb(r(n,a))}},Zr=function(r){return function(e,t){var n=[];return n[0]=r(e[0],t[0]),n[1]=r(e[1],t[1]),n[2]=r(e[2],t[2]),n}};Qr.normal=Wr(Zr((function(r){return r}))),Qr.multiply=Wr(Zr((function(r,e){return r*e/255}))),Qr.screen=Wr(Zr((function(r,e){return 255*(1-(1-r/255)*(1-e/255))}))),Qr.overlay=Wr(Zr((function(r,e){return e<128?2*r*e/255:255*(1-2*(1-r/255)*(1-e/255))}))),Qr.darken=Wr(Zr((function(r,e){return r>e?e:r}))),Qr.lighten=Wr(Zr((function(r,e){return r>e?r:e}))),Qr.dodge=Wr(Zr((function(r,e){return 255===r||(r=e/255*255/(1-r/255))>255?255:r}))),Qr.burn=Wr(Zr((function(r,e){return 255*(1-(1-e/255)/(r/255))})));var re=Math.pow,ee=Math.sin,te=Math.cos;var ne=Math.floor,ae=Math.random;var fe=Math.log,oe=Math.pow,ue=Math.floor,ce=Math.abs;function ie(r,e){void 0===e&&(e=null);var t={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===o(r)&&(r=Object.values(r)),r.forEach((function(r){e&&"object"===o(r)&&(r=r[e]),null==r||isNaN(r)||(t.values.push(r),t.sum+=r,rt.max&&(t.max=r),t.count+=1)})),t.domain=[t.min,t.max],t.limits=function(r,e){return le(t,r,e)},t}function le(r,e,t){void 0===e&&(e="equal"),void 0===t&&(t=7),"array"==o(r)&&(r=ie(r));var n=r.min,a=r.max,f=r.values.sort((function(r,e){return r-e}));if(1===t)return[n,a];var u=[];if("c"===e.substr(0,1)&&(u.push(n),u.push(a)),"e"===e.substr(0,1)){u.push(n);for(var c=1;c 0");var i=Math.LOG10E*fe(n),l=Math.LOG10E*fe(a);u.push(n);for(var h=1;h200&&(w=!1)}for(var C={},R=0;R=360;)b-=360;o[s]=b}else o[s]=o[s]/u[s];return d/=n,new v(o,e).alpha(d>.99999?1:d,!0)},bezier:function(r){var e=function(r){var e,t,n,a,f,o,u;if(2===(r=r.map((function(r){return new v(r)}))).length)e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],a=function(r){var e=[0,1,2].map((function(e){return f[e]+r*(o[e]-f[e])}));return new v(e,"lab")};else if(3===r.length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],u=t[2],a=function(r){var e=[0,1,2].map((function(e){return(1-r)*(1-r)*f[e]+2*(1-r)*r*o[e]+r*r*u[e]}));return new v(e,"lab")};else if(4===r.length){var c;n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],c=n[3],a=function(r){var e=[0,1,2].map((function(e){return(1-r)*(1-r)*(1-r)*f[e]+3*(1-r)*(1-r)*r*o[e]+3*(1-r)*r*r*u[e]+r*r*r*c[e]}));return new v(e,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,h;i=r.map((function(r){return r.lab()})),h=r.length-1,l=function(r){for(var e=[1,1],t=1;tn?(t+.05)/(n+.05):(n+.05)/(t+.05)},deltaE:function(r,e,t,n,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*we)},o=function(r){return 2*we*r/360};r=new v(r),e=new v(e);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],h=Array.from(e.lab()),d=h[0],s=h[1],b=h[2],g=(c+d)/2,p=(he(de(i,2)+de(l,2))+he(de(s,2)+de(b,2)))/2,m=.5*(1-he(de(p,7)/(de(p,7)+de(25,7)))),y=i*(1+m),w=s*(1+m),k=he(de(y,2)+de(l,2)),M=he(de(w,2)+de(b,2)),N=(k+M)/2,_=f(ge(l,y)),x=f(ge(b,w)),A=_>=0?_:_+360,F=x>=0?x:x+360,E=pe(A-F)>180?(A+F+360)/2:(A+F)/2,j=1-.17*ve(o(E-30))+.24*ve(o(2*E))+.32*ve(o(3*E+6))-.2*ve(o(4*E-63)),q=F-A;q=pe(q)<=180?q:F<=A?q+360:q-360,q=2*he(k*M)*me(o(q)/2);var L=d-c,O=M-k,P=1+.015*de(g-50,2)/he(20+de(g-50,2)),G=1+.045*N,B=1+.015*N*j,C=30*ye(-de((E-275)/25,2)),R=-(2*he(de(N,7)/(de(N,7)+de(25,7))))*me(2*o(C)),S=he(de(L/(t*P),2)+de(O/(n*G),2)+de(q/(a*B),2)+R*(O/(n*G))*(q/(a*B)));return be(0,se(100,S))},distance:function(r,e,t){void 0===t&&(t="lab"),r=new v(r),e=new v(e);var n=r.get(t),a=e.get(t),f=0;for(var o in n){var u=(n[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},limits:le,valid:function(){for(var r=[],e=arguments.length;e--;)r[e]=arguments[e];try{return new(Function.prototype.bind.apply(v,[null].concat(r))),!0}catch(r){return!1}},scales:ke,input:p,colors:yr,brewer:Me}),m})); diff --git a/src/version.js b/src/version.js index a7968d56..9efda466 100644 --- a/src/version.js +++ b/src/version.js @@ -1,2 +1,2 @@ // this gets updated automatically -export const version = '2.5.0'; +export const version = '2.6.0';