color-math
Version:
expressions to manipulate colors
58 lines • 183 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ColorMath=t():e.ColorMath=t()}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=16)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n,o=(n=r(5))&&n.__esModule?n:{default:n};function a(e){return(a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function u(e,t){return!t||"object"!==a(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function i(e){return(i=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var c=function(e){function t(e,r){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),u(this,i(t).call(this,"expr.".concat(e),r))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}(t,o["default"]),t}();t.default=c},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.blendColors=function(e,t,r){for(var n=f(r),o=e.rgba(),a=t.rgba(),u=[void 0,void 0,void 0,a[3]+o[3]*(1-a[3])],i=0;i<3;i++){var l=o[i]/255,s=a[i]/255,p=n(o[i],a[i])/255;u[3]&&(p=(a[3]*s+o[3]*(l-a[3]*(l+s-p)))/u[3]),u[i]=255*p}return c(u)},t.cmyToCmykArray=s,t.cmyToCmyk=function(e,t,r){var n=s(e,t,r);return c(n,"cmyk")},t.inverseColor=function(e){var t=m(e);return t=(t=(t=t.set("rgb.r",255-e.get("rgb.r"))).set("rgb.g",255-e.get("rgb.g"))).set("rgb.b",255-e.get("rgb.b"))},t.colorArithmeticOp=function(e,t,r){var n,o;v(e)?(n=e,o=t):(o=e,n=t);return n=(n=(n=(n=m(n)).set("rgb.r",r+o)).set("rgb.g",r+o)).set("rgb.b",r+o)},t.roundColorComps=p,t.getColorSpaceParamsValidRanges=h,t.isColor=v,t.formatColor=function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=(e=p(e)).hex(),n=e.hex("rgba"),o=e.alpha(),a=e.name(),u=1===o||isNaN(o)?r:n;t&&a!==r&&(u+=" (".concat(a,")"));return u},t.colorFromWavelength=function(e){var t=0,r=0,n=0,o=1;e>=380&&e<440?(t=-1*(e-440)/60,r=0,n=1):e>=440&&e<490?(t=0,r=(e-440)/50,n=1):e>=490&&e<510?(t=0,r=1,n=-1*(e-510)/20):e>=510&&e<580?(t=(e-510)/70,r=1,n=0):e>=580&&e<645?(t=1,r=-1*(e-645)/65,n=0):e>=645&&e<=780&&(t=1,r=0,n=0);e>780||e<380?o=0:e>700?o=(780-e)/80:e<420&&(o=(e-380)/40);return c([t,r,n,o],"gl")},t.throwError=y,t.getType=b,t.forceType=d,t.forceRange=function(e,t){b(e)===a.default.NumberArray&&2===e.length||y("operand is not valid numeric range",t);return e},t.cloneValue=m,t.forceNumInRange=function(e,t,r,n){var o=Array.isArray(t)?t[0]:t,u=Array.isArray(t)?t[1]:r;n=Array.isArray(t)?r:n;var i=d(e,a.default.Number,n);(i<o||i>u)&&y("number in a range [".concat(o,"..").concat(u,"] is expected, you provided: ").concat(i),n);return i},t.getObjKey=function(e,t){for(var r in e)if((!e.hasOwnProperty||r in e)&&e[r]===t)return r};var n=u(r(2)),o=u(r(3)),a=u(r(4));function u(e){return e&&e.__esModule?e:{default:e}}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,o=!1,a=void 0;try{for(var u,i=e[Symbol.iterator]();!(n=(u=i.next()).done)&&(r.push(u.value),!t||r.length!==t);n=!0);}catch(e){o=!0,a=e}finally{try{n||null==i.return||i.return()}finally{if(o)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}var l,c=r(6),f=((l={})[o.default.None]=function(e){return e},l[o.default.Replace]=function(e,t){return t},l[o.default.Add]=function(e,t){return Math.min(e+t,255)},l[o.default.ColorBurn]=function(e,t){return t<=0?0:Math.max(255-255*(255-e)/t,0)},l[o.default.ColorDodge]=function(e,t){return t>=255?255:Math.min(255*e/(255-t),255)},l[o.default.Darken]=function(e,t){return Math.min(e,t)},l[o.default.Difference]=function(e,t){return Math.abs(e-t)},l[o.default.Divide]=function(e,t){return Math.min(e/255/(t/255)*255,255)},l[o.default.Exclusion]=function(e,t){return 255-((255-e)*(255-t)/255+e*t/255)},l[o.default.HardLight]=function(e,t){return t<128?2*e*t/255:255-2*(255-e)*(255-t)/255},l[o.default.Lighten]=function(e,t){return Math.max(e,t)},l[o.default.LinearBurn]=function(e,t){return Math.max(0,e+t-255)},l[o.default.LinearDodge]=function(e,t){return Math.min(e+t,255)},l[o.default.Multiply]=function(e,t){return e*t/255},l[o.default.Negate]=function(e,t){return 255-Math.abs(255-e-t)},l[o.default.Overlay]=function(e,t){return e<128?2*e*t/255:255-2*(255-e)*(255-t)/255},l[o.default.Screen]=function(e,t){return 255-(255-e)*(255-t)/255},l[o.default.SoftLight]=function(e,t){return e<128?(64+(t>>1))*e*(2/255):255-(191-(t>>1))*(255-e)*(2/255)},l[o.default.Subtract]=function(e,t){return Math.max(e-t,0)},function(e){return l[e]});function s(e,t,r){var n,o=1;if(Array.isArray(e)){var a=i(e,3);n=a[0],t=a[1],r=a[2]}else n=e;return n<o&&(o=n),t<o&&(o=t),r<o&&(o=r),1===o?(n=0,t=0,r=0):(n=(n-o)/(1-o),t=(t-o)/(1-o),r=(r-o)/(1-o)),[n,t,r,o]}function p(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"rgb",r=h(t),n=e.get(t),o=0;o<r.length;o++)r[o][1]-r[o][0]>2&&(n[o]=Math.round(n[o]));var a=c(n,t);return a=a.alpha(e.alpha())}function h(e){switch(e){case"rgb":return[[0,255],[0,255],[0,255]];case"cmy":return[[0,1],[0,1],[0,1]];case"cmyk":return[[0,1],[0,1],[0,1],[0,1]];case"hsl":case"hsv":case"hsi":return[[0,360],[0,1],[0,1]];case"lab":return[[0,100],[-128,127],[-128,127]];case"lch":return[[0,100],[0,140],[0,360]];case"hcl":return[[0,360],[0,140],[0,100]];default:throw new SyntaxError("unknown namespace: ".concat(e.toUpperCase(),"."))}}function v(e){return e&&Array.isArray(e._rgb)&&4===e._rgb.length}function y(e,t){var r=t?" (".concat(t,")"):"";throw"Error".concat(r,": ").concat(e,".")}function b(e){if("number"==typeof e)return a.default.Number;if(v(e))return a.default.Color;if(Array.isArray(e)){if(e.length){if(e.every(function(e){return b(e)===a.default.Number}))return a.default.NumberArray;if(e.every(function(e){return b(e)===a.default.Color}))return a.default.ColorArray}return a.default.Array}return e instanceof n.default?a.default.ColorScale:void 0}function d(e,t,r){var n=b(e),o=Array.isArray(t)?t:[t];if(o.every(function(e){return(e&n)!==e})){var u=o.map(function(e){switch(e){case a.default.Number:return"a number";case a.default.Color:return"a color";case a.default.ColorScale:return"a color scale";case a.default.Array:return"an array";case a.default.NumberArray:return"a number array";case a.default.ColorArray:return"a color array";default:throw new Error("invalid value type")}}),i=u[0];u.length>1&&(i=u.slice(0,-1).join(", ")+" or "+u.slice(-1)),y("value is not ".concat(i),r)}return e}function m(e){switch(b(e)){case a.default.Color:return c(e.rgba());case a.default.ColorScale:return e.clone();case a.default.Array:case a.default.NumberArray:case a.default.ColorArray:return e.map(function(e){return m(e)});default:return e}}},function(e,t,r){"use strict";function n(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=r(6),a=function(){function e(t,r,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name=t.toLowerCase(),this.params=r||[],this.scaleParams=n||[]}var t,r,a;return t=e,(r=[{key:"toString",value:function(){return"<colorScale.".concat(this.name,">")}},{key:"clone",value:function(){return new e(this.name,this.params.slice(0),this.scaleParams.slice(0))}},{key:"_getParamValue",value:function(e,t){for(var r=0;r<e.length;r++)if(e[r].name===t)return e[r].value}},{key:"_applyParams",value:function(e,t){for(var r=0;r<t.length;r++)"colors"!==t[r].name&&(e=e[t[r].name](t[r].value))}},{key:"getFn",value:function(){var e=this._getParamValue(this.scaleParams,"colors"),t=o[this.name],r=e?t(e):t();return this._applyParams(r,this.params),"scale"!==this.name&&(r=r.scale()),this._applyParams(r,this.scaleParams),r}}])&&n(t.prototype,r),a&&n(t,a),e}();t.default=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={None:0,Replace:1,Add:2,ColorBurn:3,ColorDodge:4,Darken:5,Difference:6,Divide:7,Exclusion:8,HardLight:9,Lighten:10,LinearBurn:11,LinearDodge:12,Multiply:13,Negate:14,Overlay:15,Screen:16,SoftLight:17,Subtract:18}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;t.default={Number:1,Color:2,ColorScale:4,Array:8,NumberArray:16,ColorArray:32}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=i(r(20)),o=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){var n=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(e,r):{};n.get||n.set?Object.defineProperty(t,r,n):t[r]=e[r]}return t.default=e,t}(r(1)),a=i(r(12)),u=i(r(2));function i(e){return e&&e.__esModule?e:{default:e}}function l(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var c=function(){function e(t,r){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.$type=t,r&&(this.$loc=r instanceof a.default?r:new a.default(r))}var t,r,i;return t=e,(r=[{key:"getDto",value:function(){var t=this,r=!(arguments.length>0&&void 0!==arguments[0])||arguments[0],i=(0,n.default)(this,function(n){if(n!==t){if(n instanceof e)return n.getDto(r);if(n instanceof a.default)return t.$loc.toString();if(o.isColor(n))return o.formatColor(n);if(n instanceof u.default)return String(n)}});return r||delete i.$loc,i}},{key:"evaluate",value:function(e){var t=this._evaluateInternal(e);return null==t&&o.throwError("evaluation of '".concat(this.$type,"' is not supported by '").concat(e.$type,"'"),this.$loc),this.$eval=t,this.$eval}},{key:"_evaluateInternal",value:function(){throw new Error("Not implemented")}}])&&l(t.prototype,r),i&&l(t,i),e}();t.default=c},function(e,t,r){
/**
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2011-2019, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
*
* chroma.js includes colors from colorbrewer2.org, which are released under
* the following license:
*
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
* and The Pennsylvania State University.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* ------------------------------------------------------
*
* Named colors are taken from X11 Color Names.
* http://www.w3.org/TR/css3-color/#svg-color
*
* @preserve
*/
e.exports=function(){"use strict";for(var e=function(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=1),e<t?t:e>r?r:e},t={},r=0,n=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];r<n.length;r+=1){var o=n[r];t["[object "+o+"]"]=o.toLowerCase()}var a=function(e){return t[Object.prototype.toString.call(e)]||"object"},u=Math.PI,i={clip_rgb:function(t){t._clipped=!1,t._unclipped=t.slice(0);for(var r=0;r<=3;r++)r<3?((t[r]<0||t[r]>255)&&(t._clipped=!0),t[r]=e(t[r],0,255)):3===r&&(t[r]=e(t[r],0,1));return t},limit:e,type:a,unpack:function(e,t){return void 0===t&&(t=null),e.length>=3?Array.prototype.slice.call(e):"object"==a(e[0])&&t?t.split("").filter(function(t){return void 0!==e[0][t]}).map(function(t){return e[0][t]}):e[0]},last:function(e){if(e.length<2)return null;var t=e.length-1;return"string"==a(e[t])?e[t].toLowerCase():null},PI:u,TWOPI:2*u,PITHIRD:u/3,DEG2RAD:u/180,RAD2DEG:180/u},l={format:{},autodetect:[]},c=i.last,f=i.clip_rgb,s=i.type,p=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=this;if("object"===s(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];var n=c(e),o=!1;if(!n){o=!0,l.sorted||(l.autodetect=l.autodetect.sort(function(e,t){return t.p-e.p}),l.sorted=!0);for(var a=0,u=l.autodetect;a<u.length;a+=1){var i=u[a];if(n=i.test.apply(i,e))break}}if(!l.format[n])throw new Error("unknown format: "+e);var p=l.format[n].apply(null,o?e:e.slice(0,-1));r._rgb=f(p),3===r._rgb.length&&r._rgb.push(1)};p.prototype.toString=function(){return"function"==s(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var h=p,v=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(v.Color,[null].concat(e)))};v.Color=h,v.version="2.0.4";var y=v,b=i.unpack,d=Math.max,m=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=b(e,"rgb"),n=r[0],o=r[1],a=r[2],u=1-d(n/=255,d(o/=255,a/=255)),i=u<1?1/(1-u):0,l=(1-n-u)*i,c=(1-o-u)*i,f=(1-a-u)*i;return[l,c,f,u]},g=i.unpack,_=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=(e=g(e,"cmyk"))[0],n=e[1],o=e[2],a=e[3],u=e.length>4?e[4]:1;return 1===a?[0,0,0,u]:[r>=1?0:255*(1-r)*(1-a),n>=1?0:255*(1-n)*(1-a),o>=1?0:255*(1-o)*(1-a),u]},C=i.unpack,k=i.type;h.prototype.cmyk=function(){return m(this._rgb)},y.cmyk=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["cmyk"])))},l.format.cmyk=_,l.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=C(e,"cmyk"),"array"===k(e)&&4===e.length)return"cmyk"}});var w=i.unpack,O=i.last,S=function(e){return Math.round(100*e)/100},P=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=w(e,"hsla"),n=O(e)||"lsa";return r[0]=S(r[0]||0),r[1]=S(100*r[1])+"%",r[2]=S(100*r[2])+"%","hsla"===n||r.length>3&&r[3]<1?(r[3]=r.length>3?r[3]:1,n="hsla"):r.length=3,n+"("+r.join(",")+")"},j=i.unpack,E=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=(e=j(e,"rgba"))[0],n=e[1],o=e[2];r/=255,n/=255,o/=255;var a,u,i=Math.min(r,n,o),l=Math.max(r,n,o),c=(l+i)/2;return l===i?(a=0,u=Number.NaN):a=c<.5?(l-i)/(l+i):(l-i)/(2-l-i),r==l?u=(n-o)/(l-i):n==l?u=2+(o-r)/(l-i):o==l&&(u=4+(r-n)/(l-i)),(u*=60)<0&&(u+=360),e.length>3&&void 0!==e[3]?[u,a,c,e[3]]:[u,a,c]},M=i.unpack,x=i.last,A=Math.round,$=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=M(e,"rgba"),n=x(e)||"rgb";return"hsl"==n.substr(0,3)?P(E(r),n):(r[0]=A(r[0]),r[1]=A(r[1]),r[2]=A(r[2]),("rgba"===n||r.length>3&&r[3]<1)&&(r[3]=r.length>3?r[3]:1,n="rgba"),n+"("+r.slice(0,"rgb"===n?3:4).join(",")+")")},L=i.unpack,N=Math.round,B=function(){for(var e,t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,o,a,u=(t=L(t,"hsl"))[0],i=t[1],l=t[2];if(0===i)n=o=a=255*l;else{var c=[0,0,0],f=[0,0,0],s=l<.5?l*(1+i):l+i-l*i,p=2*l-s,h=u/360;c[0]=h+1/3,c[1]=h,c[2]=h-1/3;for(var v=0;v<3;v++)c[v]<0&&(c[v]+=1),c[v]>1&&(c[v]-=1),6*c[v]<1?f[v]=p+6*(s-p)*c[v]:2*c[v]<1?f[v]=s:3*c[v]<2?f[v]=p+(s-p)*(2/3-c[v])*6:f[v]=p;n=(e=[N(255*f[0]),N(255*f[1]),N(255*f[2])])[0],o=e[1],a=e[2]}return t.length>3?[n,o,a,t[3]]:[n,o,a,1]},I=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,R=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,T=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,D=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,H=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,V=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,U=Math.round,G=function(e){var t;if(e=e.toLowerCase().trim(),l.format.named)try{return l.format.named(e)}catch(e){}if(t=e.match(I)){for(var r=t.slice(1,4),n=0;n<3;n++)r[n]=+r[n];return r[3]=1,r}if(t=e.match(R)){for(var o=t.slice(1,5),a=0;a<4;a++)o[a]=+o[a];return o}if(t=e.match(T)){for(var u=t.slice(1,4),i=0;i<3;i++)u[i]=U(2.55*u[i]);return u[3]=1,u}if(t=e.match(D)){for(var c=t.slice(1,5),f=0;f<3;f++)c[f]=U(2.55*c[f]);return c[3]=+c[3],c}if(t=e.match(H)){var s=t.slice(1,4);s[1]*=.01,s[2]*=.01;var p=B(s);return p[3]=1,p}if(t=e.match(V)){var h=t.slice(1,4);h[1]*=.01,h[2]*=.01;var v=B(h);return v[3]=+t[4],v}};G.test=function(e){return I.test(e)||R.test(e)||T.test(e)||D.test(e)||H.test(e)||V.test(e)};var F=G,q=i.type;h.prototype.css=function(e){return $(this._rgb,e)},y.css=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["css"])))},l.format.css=F,l.autodetect.push({p:5,test:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];if(!t.length&&"string"===q(e)&&F.test(e))return"css"}});var W=i.unpack;l.format.gl=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=W(e,"rgba");return r[0]*=255,r[1]*=255,r[2]*=255,r},y.gl=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["gl"])))},h.prototype.gl=function(){var e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]};var Y=i.unpack,z=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r,n=Y(e,"rgb"),o=n[0],a=n[1],u=n[2],i=Math.min(o,a,u),l=Math.max(o,a,u),c=l-i,f=100*c/255,s=i/(255-c)*100;return 0===c?r=Number.NaN:(o===l&&(r=(a-u)/c),a===l&&(r=2+(u-o)/c),u===l&&(r=4+(o-a)/c),(r*=60)<0&&(r+=360)),[r,f,s]},K=i.unpack,X=Math.floor,Z=function(){for(var e,t,r,n,o,a,u=[],i=arguments.length;i--;)u[i]=arguments[i];var l,c,f,s=(u=K(u,"hcg"))[0],p=u[1],h=u[2];h*=255;var v=255*p;if(0===p)l=c=f=h;else{360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360);var y=X(s/=60),b=s-y,d=h*(1-p),m=d+v*(1-b),g=d+v*b,_=d+v;switch(y){case 0:l=(e=[_,g,d])[0],c=e[1],f=e[2];break;case 1:l=(t=[m,_,d])[0],c=t[1],f=t[2];break;case 2:l=(r=[d,_,g])[0],c=r[1],f=r[2];break;case 3:l=(n=[d,m,_])[0],c=n[1],f=n[2];break;case 4:l=(o=[g,d,_])[0],c=o[1],f=o[2];break;case 5:l=(a=[_,d,m])[0],c=a[1],f=a[2]}}return[l,c,f,u.length>3?u[3]:1]},J=i.unpack,Q=i.type;h.prototype.hcg=function(){return z(this._rgb)},y.hcg=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["hcg"])))},l.format.hcg=Z,l.autodetect.push({p:1,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=J(e,"hcg"),"array"===Q(e)&&3===e.length)return"hcg"}});var ee=i.unpack,te=i.last,re=Math.round,ne=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=ee(e,"rgba"),n=r[0],o=r[1],a=r[2],u=r[3],i=te(e)||"auto";void 0===u&&(u=1),"auto"===i&&(i=u<1?"rgba":"rgb");var l=(n=re(n))<<16|(o=re(o))<<8|(a=re(a)),c="000000"+l.toString(16);c=c.substr(c.length-6);var f="0"+re(255*u).toString(16);switch(f=f.substr(f.length-2),i.toLowerCase()){case"rgba":return"#"+c+f;case"argb":return"#"+f+c;default:return"#"+c}},oe=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,ae=/^#?([A-Fa-f0-9]{8})$/,ue=function(e){if(e.match(oe)){4!==e.length&&7!==e.length||(e=e.substr(1)),3===e.length&&(e=(e=e.split(""))[0]+e[0]+e[1]+e[1]+e[2]+e[2]);var t=parseInt(e,16);return[t>>16,t>>8&255,255&t,1]}if(e.match(ae)){9===e.length&&(e=e.substr(1));var r=parseInt(e,16);return[r>>24&255,r>>16&255,r>>8&255,Math.round((255&r)/255*100)/100]}throw new Error("unknown hex color: "+e)},ie=i.type;h.prototype.hex=function(e){return ne(this._rgb,e)},y.hex=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["hex"])))},l.format.hex=ue,l.autodetect.push({p:4,test:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];if(!t.length&&"string"===ie(e)&&[3,4,6,7,8,9].includes(e.length))return"hex"}});var le=i.unpack,ce=i.TWOPI,fe=Math.min,se=Math.sqrt,pe=Math.acos,he=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r,n=le(e,"rgb"),o=n[0],a=n[1],u=n[2],i=fe(o/=255,a/=255,u/=255),l=(o+a+u)/3,c=l>0?1-i/l:0;return 0===c?r=NaN:(r=(o-a+(o-u))/2,r/=se((o-a)*(o-a)+(o-u)*(a-u)),r=pe(r),u>a&&(r=ce-r),r/=ce),[360*r,c,l]},ve=i.unpack,ye=i.limit,be=i.TWOPI,de=i.PITHIRD,me=Math.cos,ge=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r,n,o,a=(e=ve(e,"hsi"))[0],u=e[1],i=e[2];return isNaN(a)&&(a=0),isNaN(u)&&(u=0),a>360&&(a-=360),a<0&&(a+=360),(a/=360)<1/3?n=1-((o=(1-u)/3)+(r=(1+u*me(be*a)/me(de-be*a))/3)):a<2/3?o=1-((r=(1-u)/3)+(n=(1+u*me(be*(a-=1/3))/me(de-be*a))/3)):r=1-((n=(1-u)/3)+(o=(1+u*me(be*(a-=2/3))/me(de-be*a))/3)),[255*(r=ye(i*r*3)),255*(n=ye(i*n*3)),255*(o=ye(i*o*3)),e.length>3?e[3]:1]},_e=i.unpack,Ce=i.type;h.prototype.hsi=function(){return he(this._rgb)},y.hsi=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["hsi"])))},l.format.hsi=ge,l.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=_e(e,"hsi"),"array"===Ce(e)&&3===e.length)return"hsi"}});var ke=i.unpack,we=i.type;h.prototype.hsl=function(){return E(this._rgb)},y.hsl=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["hsl"])))},l.format.hsl=B,l.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=ke(e,"hsl"),"array"===we(e)&&3===e.length)return"hsl"}});var Oe=i.unpack,Se=Math.min,Pe=Math.max,je=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r,n,o,a=(e=Oe(e,"rgb"))[0],u=e[1],i=e[2],l=Se(a,u,i),c=Pe(a,u,i),f=c-l;return o=c/255,0===c?(r=Number.NaN,n=0):(n=f/c,a===c&&(r=(u-i)/f),u===c&&(r=2+(i-a)/f),i===c&&(r=4+(a-u)/f),(r*=60)<0&&(r+=360)),[r,n,o]},Ee=i.unpack,Me=Math.floor,xe=function(){for(var e,t,r,n,o,a,u=[],i=arguments.length;i--;)u[i]=arguments[i];var l,c,f,s=(u=Ee(u,"hsv"))[0],p=u[1],h=u[2];if(h*=255,0===p)l=c=f=h;else{360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360);var v=Me(s/=60),y=s-v,b=h*(1-p),d=h*(1-p*y),m=h*(1-p*(1-y));switch(v){case 0:l=(e=[h,m,b])[0],c=e[1],f=e[2];break;case 1:l=(t=[d,h,b])[0],c=t[1],f=t[2];break;case 2:l=(r=[b,h,m])[0],c=r[1],f=r[2];break;case 3:l=(n=[b,d,h])[0],c=n[1],f=n[2];break;case 4:l=(o=[m,b,h])[0],c=o[1],f=o[2];break;case 5:l=(a=[h,b,d])[0],c=a[1],f=a[2]}}return[l,c,f,u.length>3?u[3]:1]},Ae=i.unpack,$e=i.type;h.prototype.hsv=function(){return je(this._rgb)},y.hsv=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["hsv"])))},l.format.hsv=xe,l.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=Ae(e,"hsv"),"array"===$e(e)&&3===e.length)return"hsv"}});var Le=18,Ne=.95047,Be=1,Ie=1.08883,Re=.137931034,Te=.206896552,De=.12841855,He=.008856452,Ve=i.unpack,Ue=Math.pow,Ge=function(e){return(e/=255)<=.04045?e/12.92:Ue((e+.055)/1.055,2.4)},Fe=function(e){return e>He?Ue(e,1/3):e/De+Re},qe=function(e,t,r){return e=Ge(e),t=Ge(t),r=Ge(r),[Fe((.4124564*e+.3575761*t+.1804375*r)/Ne),Fe((.2126729*e+.7151522*t+.072175*r)/Be),Fe((.0193339*e+.119192*t+.9503041*r)/Ie)]},We=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=Ve(e,"rgb"),n=r[0],o=r[1],a=r[2],u=qe(n,o,a),i=u[0],l=u[1],c=u[2],f=116*l-16;return[f<0?0:f,500*(i-l),200*(l-c)]},Ye=i.unpack,ze=Math.pow,Ke=function(e){return 255*(e<=.00304?12.92*e:1.055*ze(e,1/2.4)-.055)},Xe=function(e){return e>Te?e*e*e:De*(e-Re)},Ze=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r,n,o,a=(e=Ye(e,"lab"))[0],u=e[1],i=e[2];return n=(a+16)/116,r=isNaN(u)?n:n+u/500,o=isNaN(i)?n:n-i/200,n=Be*Xe(n),r=Ne*Xe(r),o=Ie*Xe(o),[Ke(3.2404542*r-1.5371385*n-.4985314*o),Ke(-.969266*r+1.8760108*n+.041556*o),Ke(.0556434*r-.2040259*n+1.0572252*o),e.length>3?e[3]:1]},Je=i.unpack,Qe=i.type;h.prototype.lab=function(){return We(this._rgb)},y.lab=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["lab"])))},l.format.lab=Ze,l.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=Je(e,"lab"),"array"===Qe(e)&&3===e.length)return"lab"}});var et=i.unpack,tt=i.RAD2DEG,rt=Math.sqrt,nt=Math.atan2,ot=Math.round,at=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=et(e,"lab"),n=r[0],o=r[1],a=r[2],u=rt(o*o+a*a),i=(nt(a,o)*tt+360)%360;return 0===ot(1e4*u)&&(i=Number.NaN),[n,u,i]},ut=i.unpack,it=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=ut(e,"rgb"),n=r[0],o=r[1],a=r[2],u=We(n,o,a),i=u[0],l=u[1],c=u[2];return at(i,l,c)},lt=i.unpack,ct=i.DEG2RAD,ft=Math.sin,st=Math.cos,pt=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=lt(e,"lch"),n=r[0],o=r[1],a=r[2];return isNaN(a)&&(a=0),[n,st(a*=ct)*o,ft(a)*o]},ht=i.unpack,vt=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=(e=ht(e,"lch"))[0],n=e[1],o=e[2],a=pt(r,n,o),u=a[0],i=a[1],l=a[2],c=Ze(u,i,l),f=c[0],s=c[1],p=c[2];return[f,s,p,e.length>3?e[3]:1]},yt=i.unpack,bt=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=yt(e,"hcl").reverse();return vt.apply(void 0,r)},dt=i.unpack,mt=i.type;h.prototype.lch=function(){return it(this._rgb)},h.prototype.hcl=function(){return it(this._rgb).reverse()},y.lch=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["lch"])))},y.hcl=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["hcl"])))},l.format.lch=vt,l.format.hcl=bt,["lch","hcl"].forEach(function(e){return l.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if(t=dt(t,e),"array"===mt(t)&&3===t.length)return e}})});var gt={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",cornflower:"#6495ed",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"},_t=i.type;h.prototype.name=function(){for(var e=ne(this._rgb,"rgb"),t=0,r=Object.keys(gt);t<r.length;t+=1){var n=r[t];if(gt[n]===e)return n.toLowerCase()}return e},l.format.named=function(e){if(e=e.toLowerCase(),gt[e])return ue(gt[e]);throw new Error("unknown color name: "+e)},l.autodetect.push({p:5,test:function(e){for(var t=[],r=arguments.length-1;r-- >0;)t[r]=arguments[r+1];if(!t.length&&"string"===_t(e)&>[e.toLowerCase()])return"named"}});var Ct=i.unpack,kt=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=Ct(e,"rgb"),n=r[0],o=r[1],a=r[2];return(n<<16)+(o<<8)+a},wt=i.type,Ot=function(e){if("number"==wt(e)&&e>=0&&e<=16777215)return[e>>16,e>>8&255,255&e,1];throw new Error("unknown num color: "+e)},St=i.type;h.prototype.num=function(){return kt(this._rgb)},y.num=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["num"])))},l.format.num=Ot,l.autodetect.push({p:5,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(1===e.length&&"number"===St(e[0])&&e[0]>=0&&e[0]<=16777215)return"num"}});var Pt=i.unpack,jt=i.type,Et=Math.round;h.prototype.rgb=function(e){return void 0===e&&(e=!0),!1===e?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Et)},h.prototype.rgba=function(e){return void 0===e&&(e=!0),this._rgb.slice(0,4).map(function(t,r){return r<3?!1===e?t:Et(t):t})},y.rgb=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["rgb"])))},l.format.rgb=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var r=Pt(e,"rgba");return void 0===r[3]&&(r[3]=1),r},l.autodetect.push({p:3,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=Pt(e,"rgba"),"array"===jt(e)&&(3===e.length||4===e.length&&"number"==jt(e[3])&&e[3]>=0&&e[3]<=1))return"rgb"}});var Mt=Math.log,xt=function(e){var t,r,n,o=e/100;return o<66?(t=255,r=-155.25485562709179-.44596950469579133*(r=o-2)+104.49216199393888*Mt(r),n=o<20?0:.8274096064007395*(n=o-10)-254.76935184120902+115.67994401066147*Mt(n)):(t=351.97690566805693+.114206453784165*(t=o-55)-40.25366309332127*Mt(t),r=325.4494125711974+.07943456536662342*(r=o-50)-28.0852963507957*Mt(r),n=255),[t,r,n,1]},At=i.unpack,$t=Math.round,Lt=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];for(var r,n=At(e,"rgb"),o=n[0],a=n[2],u=1e3,i=4e4,l=.4;i-u>l;){var c=xt(r=.5*(i+u));c[2]/c[0]>=a/o?i=r:u=r}return $t(r)};h.prototype.temp=h.prototype.kelvin=h.prototype.temperature=function(){return Lt(this._rgb)},y.temp=y.kelvin=y.temperature=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(h,[null].concat(e,["temp"])))},l.format.temp=l.format.kelvin=l.format.temperature=xt;var Nt=i.type;h.prototype.alpha=function(e,t){return void 0===t&&(t=!1),void 0!==e&&"number"===Nt(e)?t?(this._rgb[3]=e,this):new h([this._rgb[0],this._rgb[1],this._rgb[2],e],"rgb"):this._rgb[3]},h.prototype.clipped=function(){return this._rgb._clipped||!1},h.prototype.darken=function(e){void 0===e&&(e=1);var t=this.lab();return t[0]-=Le*e,new h(t,"lab").alpha(this.alpha(),!0)},h.prototype.brighten=function(e){return void 0===e&&(e=1),this.darken(-e)},h.prototype.darker=h.prototype.darken,h.prototype.brighter=h.prototype.brighten,h.prototype.get=function(e){var t=e.split("."),r=t[0],n=t[1],o=this[r]();if(n){var a=r.indexOf(n);if(a>-1)return o[a];throw new Error("unknown channel "+n+" in mode "+r)}return o};var Bt=i.type,It=Math.pow;h.prototype.luminance=function(e){if(void 0!==e&&"number"===Bt(e)){if(0===e)return new h([0,0,0,this._rgb[3]],"rgb");if(1===e)return new h([255,255,255,this._rgb[3]],"rgb");var t=this.luminance(),r=20,n=function(t,o){var a=t.interpolate(o,.5,"rgb"),u=a.luminance();return Math.abs(e-u)<1e-7||!r--?a:u>e?n(t,a):n(a,o)},o=(t>e?n(new h([0,0,0]),this):n(this,new h([255,255,255]))).rgb();return new h(o.concat([this._rgb[3]]))}return Rt.apply(void 0,this._rgb.slice(0,3))};var Rt=function(e,t,r){return.2126*(e=Tt(e))+.7152*(t=Tt(t))+.0722*(r=Tt(r))},Tt=function(e){return(e/=255)<=.03928?e/12.92:It((e+.055)/1.055,2.4)},Dt={},Ht=i.type,Vt=function(e,t,r){void 0===r&&(r=.5);for(var n=[],o=arguments.length-3;o-- >0;)n[o]=arguments[o+3];var a=n[0]||"lrgb";if(Dt[a]||n.length||(a=Object.keys(Dt)[0]),!Dt[a])throw new Error("interpolation mode "+a+" is not defined");return"object"!==Ht(e)&&(e=new h(e)),"object"!==Ht(t)&&(t=new h(t)),Dt[a](e,t,r).alpha(e.alpha()+r*(t.alpha()-e.alpha()))};h.prototype.mix=h.prototype.interpolate=function(e,t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-2;n-- >0;)r[n]=arguments[n+2];return Vt.apply(void 0,[this,e,t].concat(r))},h.prototype.premultiply=function(e){void 0===e&&(e=!1);var t=this._rgb,r=t[3];return e?(this._rgb=[t[0]*r,t[1]*r,t[2]*r,r],this):new h([t[0]*r,t[1]*r,t[2]*r,r],"rgb")},h.prototype.saturate=function(e){void 0===e&&(e=1);var t=this.lch();return t[1]+=Le*e,t[1]<0&&(t[1]=0),new h(t,"lch").alpha(this.alpha(),!0)},h.prototype.desaturate=function(e){return void 0===e&&(e=1),this.saturate(-e)};var Ut=i.type;h.prototype.set=function(e,t,r){void 0===r&&(r=!1);var n=e.split("."),o=n[0],a=n[1],u=this[o]();if(a){var i=o.indexOf(a);if(i>-1){if("string"==Ut(t))switch(t.charAt(0)){case"+":case"-":u[i]+=+t;break;case"*":u[i]*=+t.substr(1);break;case"/":u[i]/=+t.substr(1);break;default:u[i]=+t}else{if("number"!==Ut(t))throw new Error("unsupported value for Color.set");u[i]=t}var l=new h(u,o);return r?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+a+" in mode "+o)}return u},Dt.rgb=function(e,t,r){var n=e._rgb,o=t._rgb;return new h(n[0]+r*(o[0]-n[0]),n[1]+r*(o[1]-n[1]),n[2]+r*(o[2]-n[2]),"rgb")};var Gt=Math.sqrt,Ft=Math.pow;Dt.lrgb=function(e,t,r){var n=e._rgb,o=n[0],a=n[1],u=n[2],i=t._rgb,l=i[0],c=i[1],f=i[2];return new h(Gt(Ft(o,2)*(1-r)+Ft(l,2)*r),Gt(Ft(a,2)*(1-r)+Ft(c,2)*r),Gt(Ft(u,2)*(1-r)+Ft(f,2)*r),"rgb")},Dt.lab=function(e,t,r){var n=e.lab(),o=t.lab();return new h(n[0]+r*(o[0]-n[0]),n[1]+r*(o[1]-n[1]),n[2]+r*(o[2]-n[2]),"lab")};var qt=function(e,t,r,n){var o,a,u,i,l,c,f,s,p,v,y,b;return"hsl"===n?(u=e.hsl(),i=t.hsl()):"hsv"===n?(u=e.hsv(),i=t.hsv()):"hcg"===n?(u=e.hcg(),i=t.hcg()):"hsi"===n?(u=e.hsi(),i=t.hsi()):"lch"!==n&&"hcl"!==n||(n="hcl",u=e.hcl(),i=t.hcl()),"h"===n.substr(0,1)&&(l=(o=u)[0],f=o[1],p=o[2],c=(a=i)[0],s=a[1],v=a[2]),isNaN(l)||isNaN(c)?isNaN(l)?isNaN(c)?b=Number.NaN:(b=c,1!=p&&0!=p||"hsv"==n||(y=s)):(b=l,1!=v&&0!=v||"hsv"==n||(y=f)):b=l+r*(c>l&&c-l>180?c-(l+360):c<l&&l-c>180?c+360-l:c-l),void 0===y&&(y=f+r*(s-f)),new h([b,y,p+r*(v-p)],n)},Wt=function(e,t,r){return qt(e,t,r,"lch")};Dt.lch=Wt,Dt.hcl=Wt,Dt.num=function(e,t,r){var n=e.num(),o=t.num();return new h(n+r*(o-n),"num")},Dt.hcg=function(e,t,r){return qt(e,t,r,"hcg")},Dt.hsi=function(e,t,r){return qt(e,t,r,"hsi")},Dt.hsl=function(e,t,r){return qt(e,t,r,"hsl")},Dt.hsv=function(e,t,r){return qt(e,t,r,"hsv")};var Yt=i.clip_rgb,zt=Math.pow,Kt=Math.sqrt,Xt=Math.PI,Zt=Math.cos,Jt=Math.sin,Qt=Math.atan2,er=function(e){for(var t=1/e.length,r=[0,0,0,0],n=0,o=e;n<o.length;n+=1){var a=o[n]._rgb;r[0]+=zt(a[0],2)*t,r[1]+=zt(a[1],2)*t,r[2]+=zt(a[2],2)*t,r[3]+=a[3]*t}return r[0]=Kt(r[0]),r[1]=Kt(r[1]),r[2]=Kt(r[2]),r[3]>.9999999&&(r[3]=1),new h(Yt(r))},tr=i.type,rr=Math.pow,nr=function(e){var t="rgb",r=y("#ccc"),n=0,o=[0,1],a=[],u=[0,0],i=!1,l=[],c=!1,f=0,s=1,p=!1,h={},v=!0,b=1,d=function(e){if((e=e||["#fff","#000"])&&"string"===tr(e)&&y.brewer&&y.brewer[e.toLowerCase()]&&(e=y.brewer[e.toLowerCase()]),"array"===tr(e)){1===e.length&&(e=[e[0],e[0]]),e=e.slice(0);for(var t=0;t<e.length;t++)e[t]=y(e[t]);a.length=0;for(var r=0;r<e.length;r++)a.push(r/(e.length-1))}return _(),l=e},m=function(e){return e},g=function(e,n){var o,c;if(null==n&&(n=!1),isNaN(e)||null===e)return r;c=n?e:i&&i.length>2?function(e){if(null!=i){for(var t=i.length-1,r=0;r<t&&e>=i[r];)r++;return r-1}return 0}(e)/(i.length-2):s!==f?(e-f)/(s-f):1,n||(c=m(c)),1!==b&&(c=rr(c,b)),c=u[0]+c*(1-u[0]-u[1]),c=Math.min(1,Math.max(0,c));var p=Math.floor(1e4*c);if(v&&h[p])o=h[p];else{if("array"===tr(l))for(var d=0;d<a.length;d++){var g=a[d];if(c<=g){o=l[d];break}if(c>=g&&d===a.length-1){o=l[d];break}if(c>g&&c<a[d+1]){c=(c-g)/(a[d+1]-g),o=y.interpolate(l[d],l[d+1],c,t);break}}else"function"===tr(l)&&(o=l(c));v&&(h[p]=o)}return o},_=function(){return h={}};d(e);var C=function(e){var t=y(g(e));return c&&t[c]?t[c]():t};return C.classes=function(e){if(null!=e){if("array"===tr(e))i=e,o=[e[0],e[e.length-1]];else{var t=y.analyze(o);i=0===e?[t.min,t.max]:y.limits(t,"e",e)}return C}return i},C.domain=function(e){if(!arguments.length)return o;f=e[0],s=e[e.length-1],a=[];var t=l.length;if(e.length===t&&f!==s)for(var r=0,n=Array.from(e);r<n.length;r+=1){var u=n[r];a.push((u-f)/(s-f))}else for(var i=0;i<t;i++)a.push(i/(t-1));return o=[f,s],C},C.mode=function(e){return arguments.length?(t=e,_(),C):t},C.range=function(e,t){return d(e),C},C.out=function(e){return c=e,C},C.spread=function(e){return arguments.length?(n=e,C):n},C.correctLightness=function(e){return null==e&&(e=!0),p=e,_(),m=p?function(e){for(var t=g(0,!0).lab()[0],r=g(1,!0).lab()[0],n=t>r,o=g(e,!0).lab()[0],a=t+(r-t)*e,u=o-a,i=0,l=1,c=20;Math.abs(u)>.01&&c-- >0;)n&&(u*=-1),u<0?(i=e,e+=.5*(l-e)):(l=e,e+=.5*(i-e)),o=g(e,!0).lab()[0],u=o-a;return e}:function(e){return e},C},C.padding=function(e){return null!=e?("number"===tr(e)&&(e=[e,e]),u=e,C):u},C.colors=function(t,r){arguments.length<2&&(r="hex");var n=[];if(0===arguments.length)n=l.slice(0);else if(1===t)n=[C(.5)];else if(t>1){var a=o[0],u=o[1]-a;n=or(0,t,!1).map(function(e){return C(a+e/(t-1)*u)})}else{e=[];var c=[];if(i&&i.length>2)for(var f=1,s=i.length,p=1<=s;p?f<s:f>s;p?f++:f--)c.push(.5*(i[f-1]+i[f]));else c=o;n=c.map(function(e){return C(e)})}return y[r]&&(n=n.map(function(e){return e[r]()})),n},C.cache=function(e){return null!=e?(v=e,C):v},C.gamma=function(e){return null!=e?(b=e,C):b},C.nodata=function(e){return null!=e?(r=y(e),C):r},C};function or(e,t,r){for(var n=[],o=e<t,a=r?o?t+1:t-1:t,u=e;o?u<a:u>a;o?u++:u--)n.push(u);return n}var ar=function(e){var t,r,n,o,a,u,i;if(2===(e=e.map(function(e){return new h(e)})).length)t=e.map(function(e){return e.lab()}),a=t[0],u=t[1],o=function(e){var t=[0,1,2].map(function(t){return a[t]+e*(u[t]-a[t])});return new h(t,"lab")};else if(3===e.length)r=e.map(function(e){return e.lab()}),a=r[0],u=r[1],i=r[2],o=function(e){var t=[0,1,2].map(function(t){return(1-e)*(1-e)*a[t]+2*(1-e)*e*u[t]+e*e*i[t]});return new h(t,"lab")};else if(4===e.length){var l;n=e.map(function(e){return e.lab()}),a=n[0],u=n[1],i=n[2],l=n[3],o=function(e){var t=[0,1,2].map(function(t){return(1-e)*(1-e)*(1-e)*a[t]+3*(1-e)*(1-e)*e*u[t]+3*(1-e)*e*e*i[t]+e*e*e*l[t]});return new h(t,"lab")}}else if(5===e.length){var c=ar(e.slice(0,3)),f=ar(e.slice(2,5));o=function(e){return e<.5?c(2*e):f(2*(e-.5))}}return o},ur=function(e,t,r){if(!ur[r])throw new Error("unknown blend mode "+r);return ur[r](e,t)},ir=function(e){return function(t,r){var n=y(r).rgb(),o=y(t).rgb();return y.rgb(e(n,o))}},lr=function(e){return function(t,r){var n=[];return n[0]=e(t[0],r[0]),n[1]=e(t[1],r[1]),n[2]=e(t[2],r[2]),n}};ur.normal=ir(lr(function(e){return e})),ur.multiply=ir(lr(function(e,t){return e*t/255})),ur.screen=ir(lr(function(e,t){return 255*(1-(1-e/255)*(1-t/255))})),ur.overlay=ir(lr(function(e,t){return t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255))})),ur.darken=ir(lr(function(e,t){return e>t?t:e})),ur.lighten=ir(lr(function(e,t){return e>t?e:t})),ur.dodge=ir(lr(function(e,t){return 255===e?255:(e=t/255*255/(1-e/255))>255?255:e})),ur.burn=ir(lr(function(e,t){return 255*(1-(1-t/255)/(e/255))}));for(var cr=ur,fr=i.type,sr=i.clip_rgb,pr=i.TWOPI,hr=Math.pow,vr=Math.sin,yr=Math.cos,br=Math.floor,dr=Math.random,mr=Math.log,gr=Math.pow,_r=Math.floor,Cr=Math.abs,kr=function(e,t){void 0===t&&(t=null);var r={min:Number.MAX_VALUE,max:-1*Number.MAX_VALUE,sum:0,values:[],count:0};return"object"===a(e)&&(e=Object.values(e)),e.forEach(function(e){t&&"object"===a(e)&&(e=e[t]),null==e||isNaN(e)||(r.values.push(e),r.sum+=e,e<r.min&&(r.min=e),e>r.max&&(r.max=e),r.count+=1)}),r.domain=[r.min,r.max],r.limits=function(e,t){return wr(r,e,t)},r},wr=function(e,t,r){void 0===t&&(t="equal"),void 0===r&&(r=7),"array"==a(e)&&(e=kr(e));var n=e.min,o=e.max,u=e.values.sort(function(e,t){return e-t});if(1===r)return[n,o];var i=[];if("c"===t.substr(0,1)&&(i.push(n),i.push(o)),"e"===t.substr(0,1)){i.push(n);for(var l=1;l<r;l++)i.push(n+l/r*(o-n));i.push(o)}else if("l"===t.substr(0,1)){if(n<=0)throw new Error("Logarithmic scales are only possible for values > 0");var c=Math.LOG10E*mr(n),f=Math.LOG10E*mr(o);i.push(n);for(var s=1;s<r;s++)i.push(gr(10,c+s/r*(f-c)));i.push(o)}else if("q"===t.substr(0,1)){i.push(n);for(var p=1;p<r;p++){var h=(u.length-1)*p/r,v=_r(h);if(v===h)i.push(u[v]);else{var y=h-v;i.push(u[v]*(1-y)+u[v+1]*y)}}i.push(o)}else if("k"===t.substr(0,1)){var b,d=u.length,m=new Array(d),g=new Array(r),_=!0,C=0,k=null;(k=[]).push(n);for(var w=1;w<r;w++)k.push(n+w/r*(o-n));for(k.push(o);_;){for(var O=0;O<r;O++)g[O]=0;for(var S=0;S<d;S++)for(var P=u[S],j=Number.MAX_VALUE,E=void 0,M=0;M<r;M++){var x=Cr(k[M]-P);x<j&&(j=x,E=M),g[E]++,m[S]=E}for(var A=new Array(r),$=0;$<r;$++)A[$]=null;for(var L=0;L<d;L++)null===A[b=m[L]]?A[b]=u[L]:A[b]+=u[L];for(var N=0;N<r;N++)A[N]*=1/g[N];_=!1;for(var B=0;B<r;B++)if(A[B]!==k[B]){_=!0;break}k=A,++C>200&&(_=!1)}for(var I={},R=0;R<r;R++)I[R]=[];for(var T=0;T<d;T++)I[b=m[T]].push(u[T]);for(var D=[],H=0;H<r;H++)D.push(I[H][0]),D.push(I[H][I[H].length-1]);D=D.sort(function(e,t){return e-t}),i.push(D[0]);for(var V=1;V<D.length;V+=2){var U=D[V];isNaN(U)||-1!==i.indexOf(U)||i.push(U)}}return i},Or={analyze:kr,limits:wr},Sr=Math.sqrt,Pr=Math.atan2,jr=Math.abs,Er=Math.cos,Mr=Math.PI,xr={cool:function(){return nr([y.hsl(180,1,.9),y.hsl(250,.7,.4)])},hot:function(){return nr(["#000","#f00","#ff0","#fff"]).mode("rgb")}},Ar={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},$r=0,Lr=Object.keys(Ar);$r<Lr.length;$r+=1){var Nr=Lr[$r];Ar[Nr.toLowerCase()]=Ar[Nr]}var Br=Ar;return y.average=function(e,t){void 0===t&&(t="lrgb");var r=e.length;if(e=e.map(function(e){return new h(e)}),"lrgb"===t)return er(e);for(var n=e.shift(),o=n.get(t),a=[],u=0,i=0,l=0;l<o.length;l++)if(o[l]=o[l]||0,a.push(isNaN(o[l])?0:1),"h"===t.charAt(l)&&!isNaN(o[l])){var c=o[l]/180*Xt;u+=Zt(c),i+=Jt(c)}var f=n.alpha();e.forEach(function(e){var r=e.get(t);f+=e.alpha();for(var n=0;