From a115767cf885a76ea3ca661fead9089df5bc9048 Mon Sep 17 00:00:00 2001 From: Gregor Aisch Date: Sat, 17 Aug 2024 15:16:15 +0200 Subject: [PATCH] update docs + changelog + bump version to 3.0.0 --- CHANGELOG.md | 9 +- dist/chroma-light.cjs | 286 +++-- dist/chroma-light.min.cjs | 2 +- dist/chroma.cjs | 303 +++--- dist/chroma.min.cjs | 2 +- docs/index.html | 174 ++- docs/libs/chroma-light.cjs | 1077 ++++++++++++++---- docs/libs/chroma-light.min.cjs | 2 +- docs/libs/chroma.cjs | 1858 ++++++++++++++++++++------------ docs/libs/chroma.min.cjs | 2 +- docs/src/index.md | 1 + package.json | 2 +- src/version.js | 2 +- 13 files changed, 2561 insertions(+), 1159 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f34bd3ca..be8b4883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,11 @@ ## Changelog -### 3.0.0-0 -* 🎉 NEW: add support for modern CSS color spaces `lab()`, `lch()`, `oklab()`, `oklch()`. +### 3.0.0 +* 🎉 NEW: Add support for modern CSS color spaces. This means you can now export and parse CSS colors in `lab()`, `lch()`, `oklab()`, `oklch()` space. * 🎉 NEW: you can now control the standard white reference point for the CIE Lab and CIE Lch color spaces via `setLabWhitePoint`. -* chroma.css will no longer return legacy CSS colors like `rgb(255, 255, 0)` but modern CSS colors like `rgb(255 255 0)`. -* you can now use chroma.js both via the default export as well as named exports in ES6. +* Breaking: `color.css()` will no longer return [legacy CSS colors](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#legacy_syntax_comma-separated_values) like `rgb(255, 255, 0)` but use modern CSS colors like `rgb(255 255 0)` instead. +* fix: you can now use chroma.js both via the default export as well as named exports in ES6. +* fix: switch to W3C implementation of OKLab color space ### 2.6.0 * 🎉 NEW: add [`color.shade()`](#color-shade), [`color.tint()`](#color-shade). diff --git a/dist/chroma-light.cjs b/dist/chroma-light.cjs index 842c9529..bb58b840 100644 --- a/dist/chroma-light.cjs +++ b/dist/chroma-light.cjs @@ -130,6 +130,9 @@ var PI = Math.PI; var min = Math.min; var max = Math.max; + + var rnd2 = function (a) { return Math.round(a * 100) / 100; }; + var rnd3 = function (a) { return Math.round(a * 100) / 100; }; var DEG2RAD = PI / 180; var RAD2DEG = 180 / PI; @@ -188,7 +191,7 @@ }; // this gets updated automatically - var version = '3.0.0-0'; + var version = '3.0.0'; var chroma = function () { var args = [], len = arguments.length; @@ -199,8 +202,6 @@ chroma.version = version; - var rnd$4 = function (a) { return Math.round(a * 100) / 100; }; - /* * supported arguments: * - hsl2css(h,s,l) @@ -215,9 +216,9 @@ var hsla = unpack(args, 'hsla'); var mode = last(args) || 'lsa'; - hsla[0] = rnd$4(hsla[0] || 0) + 'deg'; - hsla[1] = rnd$4(hsla[1] * 100) + '%'; - hsla[2] = rnd$4(hsla[2] * 100) + '%'; + hsla[0] = rnd2(hsla[0] || 0) + 'deg'; + hsla[1] = rnd2(hsla[1] * 100) + '%'; + hsla[2] = rnd2(hsla[2] * 100) + '%'; if (mode === 'hsla' || (hsla.length > 3 && hsla[3] < 1)) { hsla[3] = '/ ' + (hsla.length > 3 ? hsla[3] : 1); mode = 'hsla'; @@ -274,8 +275,6 @@ return [h, s, l]; }; - var rnd$3 = function (a) { return Math.round(a * 100) / 100; }; - /* * supported arguments: * - lab2css(l,a,b) @@ -289,9 +288,9 @@ var laba = unpack(args, 'lab'); var mode = last(args) || 'lab'; - laba[0] = rnd$3(laba[0]) + '%'; - laba[1] = rnd$3(laba[1]); - laba[2] = rnd$3(laba[2]); + laba[0] = rnd2(laba[0]) + '%'; + laba[1] = rnd2(laba[1]); + laba[2] = rnd2(laba[2]); if (mode === 'laba' || (laba.length > 3 && laba[3] < 1)) { laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1); } else { @@ -505,8 +504,6 @@ return [x, y, z]; }; - var rnd$2 = function (a) { return Math.round(a * 100) / 100; }; - /* * supported arguments: * - lab2css(l,a,b) @@ -520,9 +517,9 @@ var lcha = unpack(args, 'lch'); var mode = last(args) || 'lab'; - lcha[0] = rnd$2(lcha[0]) + '%'; - lcha[1] = rnd$2(lcha[1]); - lcha[2] = rnd$2(lcha[2]) + 'deg'; // add deg unit to hue + lcha[0] = rnd2(lcha[0]) + '%'; + lcha[1] = rnd2(lcha[1]); + lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) { lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1); } else { @@ -569,58 +566,89 @@ return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); }; - var cbrt = Math.cbrt; - var pow$2 = Math.pow; - var sign$1 = Math.sign; + // from https://www.w3.org/TR/css-color-4/multiply-matrices.js + function multiplyMatrices(A, B) { + var m = A.length; + + if (!Array.isArray(A[0])) { + // A is vector, convert to [[a, b, c, ...]] + A = [A]; + } + + if (!Array.isArray(B[0])) { + // B is vector, convert to [[a], [b], [c], ...]] + B = B.map(function (x) { return [x]; }); + } + + var p = B[0].length; + var B_cols = B[0].map(function (_, i) { return B.map(function (x) { return x[i]; }); }); // transpose B + var product = A.map(function (row) { return B_cols.map(function (col) { + if (!Array.isArray(row)) { + return col.reduce(function (a, c) { return a + c * row; }, 0); + } + + return row.reduce(function (a, c, i) { return a + c * (col[i] || 0); }, 0); + }); } + ); + + if (m === 1) { + product = product[0]; // Avoid [[a, b, c, ...]] + } + + if (p === 1) { + return product.map(function (x) { return x[0]; }); // Avoid [[a], [b], [c], ...]] + } + + return product; + } var rgb2oklab = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; - // OKLab color space implementation taken from - // https://bottosson.github.io/posts/oklab/ var ref = unpack(args, 'rgb'); var r = ref[0]; var g = ref[1]; var b = ref[2]; var rest = ref.slice(3); - var ref$1 = [ - rgb2lrgb(r / 255), - rgb2lrgb(g / 255), - rgb2lrgb(b / 255) - ]; - var lr = ref$1[0]; - var lg = ref$1[1]; - var lb = ref$1[2]; - var l = cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb); - var m = cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb); - var s = cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb); - - return [ - 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, - 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, - 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : []) - ); + var xyz = rgb2xyz(r, g, b); + var oklab = XYZ_to_OKLab(xyz); + return oklab.concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); }; - function rgb2lrgb(c) { - var abs = Math.abs(c); - if (abs < 0.04045) { - return c / 12.92; - } - return (sign$1(c) || 1) * pow$2((abs + 0.055) / 1.055, 2.4); - } + // from https://www.w3.org/TR/css-color-4/#color-conversion-code + function XYZ_to_OKLab(XYZ) { + // Given XYZ relative to D65, convert to OKLab + var XYZtoLMS = [ + [0.819022437996703, 0.3619062600528904, -0.1288737815209879], + [0.0329836539323885, 0.9292868615863434, 0.0361446663506424], + [0.0481771893596242, 0.2642395317527308, 0.6335478284694309] + ]; + var LMStoOKLab = [ + [0.210454268309314, 0.7936177747023054, -0.0040720430116193], + [1.9779985324311684, -2.4285922420485799, 0.450593709617411], + [0.0259040424655478, 0.7827717124575296, -0.8086757549230774] + ]; - var rnd$1 = function (a) { return Math.round(a * 100) / 100; }; + var LMS = multiplyMatrices(XYZtoLMS, XYZ); + // JavaScript Math.cbrt returns a sign-matched cube root + // beware if porting to other languages + // especially if tempted to use a general power function + return multiplyMatrices( + LMStoOKLab, + LMS.map(function (c) { return Math.cbrt(c); }) + ); + // L in range [0,1]. For use in CSS, multiply by 100 and add a percent + } var oklab2css$1 = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var laba = unpack(args, 'lab'); - laba[0] = rnd$1(laba[0] * 100) + '%'; - laba[1] = rnd$1(laba[1]); - laba[2] = rnd$1(laba[2]); + laba[0] = rnd2(laba[0] * 100) + '%'; + laba[1] = rnd3(laba[1]); + laba[2] = rnd3(laba[2]); if (laba.length > 3 && laba[3] < 1) { laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1); } else { @@ -649,16 +677,14 @@ return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); }; - var rnd = function (a) { return Math.round(a * 100) / 100; }; - var oklab2css = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var laba = unpack(args, 'lab'); - laba[0] = rnd(laba[0] * 100) + '%'; - laba[1] = rnd(laba[1]); - laba[2] = rnd(laba[2]) + 'deg'; + laba[0] = rnd2(laba[0] * 100) + '%'; + laba[1] = rnd3(laba[1]); + laba[2] = rnd2(laba[2]) + 'deg'; if (laba.length > 3 && laba[3] < 1) { laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1); } else { @@ -915,6 +941,67 @@ return [r, g, b, args.length > 3 ? args[3] : 1]; }; + var oklab2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack(args, 'lab'); + var L = args[0]; + var a = args[1]; + var b = args[2]; + var rest = args.slice(3); + var ref = OKLab_to_XYZ([L, a, b]); + var X = ref[0]; + var Y = ref[1]; + var Z = ref[2]; + var ref$1 = xyz2rgb(X, Y, Z); + var r = ref$1[0]; + var g = ref$1[1]; + var b_ = ref$1[2]; + return [r, g, b_ ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); + }; + + // from https://www.w3.org/TR/css-color-4/#color-conversion-code + function OKLab_to_XYZ(OKLab) { + // Given OKLab, convert to XYZ relative to D65 + var LMStoXYZ = [ + [1.2268798758459243, -0.5578149944602171, 0.2813910456659647], + [-0.0405757452148008, 1.112286803280317, -0.0717110580655164], + [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816] + ]; + var OKLabtoLMS = [ + [1.0, 0.3963377773761749, 0.2158037573099136], + [1.0, -0.1055613458156586, -0.0638541728258133], + [1.0, -0.0894841775298119, -1.2914855480194092] + ]; + + var LMSnl = multiplyMatrices(OKLabtoLMS, OKLab); + return multiplyMatrices( + LMStoXYZ, + LMSnl.map(function (c) { return Math.pow( c, 3 ); }) + ); + } + + var oklch2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack(args, 'lch'); + var l = args[0]; + var c = args[1]; + var h = args[2]; + var rest = args.slice(3); + var ref = lch2lab(l, c, h); + var L = ref[0]; + var a = ref[1]; + var b_ = ref[2]; + var ref$1 = oklab2rgb(L, a, b_); + var r = ref$1[0]; + var g = ref$1[1]; + var b = ref$1[2]; + return [r, g, b ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); + }; + var RE_RGB = /^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/; var RE_RGB_LEGACY = /^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/; @@ -946,9 +1033,11 @@ var RE_LAB = /^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; var RE_LCH = - /^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; - // const RE_OKLAB = - // /^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; + /^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; + var RE_OKLAB = + /^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; + var RE_OKLCH = + /^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; var round$2 = Math.round; @@ -961,8 +1050,8 @@ if ( max === void 0 ) max = 100; if ( signed === void 0 ) signed = false; - if (pct.endsWith('%')) { - pct = parseFloat(pct.substr(0, pct.length - 1)) / 100; + if (typeof pct === 'string' && pct.endsWith('%')) { + pct = parseFloat(pct.substring(0, pct.length - 1)) / 100; if (signed) { // signed percentages are in the range -100% to 100% pct = min + (pct + 1) * 0.5 * (max - min); @@ -1058,7 +1147,12 @@ lab[0] = percentToAbsolute(lab[0], 0, 100); lab[1] = percentToAbsolute(lab[1], -125, 125, true); lab[2] = percentToAbsolute(lab[2], -125, 125, true); + // convert to D50 Lab whitepoint + var wp = getLabWhitePoint(); + setLabWhitePoint('d50'); var rgb$6 = roundRGB(lab2rgb(lab)); + // convert back to original Lab whitepoint + setLabWhitePoint(wp); rgb$6[3] = m[4] !== undefined ? +m[4] : 1; return rgb$6; } @@ -1068,20 +1162,35 @@ lch[0] = percentToAbsolute(lch[0], 0, 100); lch[1] = percentToAbsolute(noneToValue(lch[1], 0), 0, 150, false); lch[2] = +noneToValue(lch[2].replace('deg', ''), 0); + // convert to D50 Lab whitepoint + var wp$1 = getLabWhitePoint(); + setLabWhitePoint('d50'); var rgb$7 = roundRGB(lch2rgb(lch)); + // convert back to original Lab whitepoint + setLabWhitePoint(wp$1); rgb$7[3] = m[4] !== undefined ? +m[4] : 1; return rgb$7; } - // if ((m = css.match(RE_OKLAB))) { - // const oklab = m.slice(1, 4); - // oklab[0] = percentToAbsolute(oklab[0], 0, 1); - // oklab[1] = percentToAbsolute(oklab[1], -0.4, 0.4, true); - // oklab[2] = percentToAbsolute(oklab[2], -0.4, 0.4, true); - // const rgb = roundRGB(oklab2rgb(oklab)); - // rgb[3] = m[4] !== undefined ? +m[4] : 1; - // return rgb; - // } + if ((m = css.match(RE_OKLAB))) { + var oklab = m.slice(1, 4); + oklab[0] = percentToAbsolute(oklab[0], 0, 1); + oklab[1] = percentToAbsolute(oklab[1], -0.4, 0.4, true); + oklab[2] = percentToAbsolute(oklab[2], -0.4, 0.4, true); + var rgb$8 = roundRGB(oklab2rgb(oklab)); + rgb$8[3] = m[4] !== undefined ? +m[4] : 1; + return rgb$8; + } + + if ((m = css.match(RE_OKLCH))) { + var oklch = m.slice(1, 4); + oklch[0] = percentToAbsolute(oklch[0], 0, 1); + oklch[1] = percentToAbsolute(noneToValue(oklch[1], 0), 0, 0.4, false); + oklch[2] = +noneToValue(oklch[2].replace('deg', ''), 0); + var rgb$9 = roundRGB(oklch2rgb(oklch)); + rgb$9[3] = m[4] !== undefined ? +m[4] : 1; + return rgb$9; + } }; css2rgb.test = function (s) { @@ -1094,7 +1203,9 @@ RE_HSL.test(s) || RE_HSLA.test(s) || RE_LAB.test(s) || - // RE_OKLAB.test(s) || + RE_LCH.test(s) || + RE_OKLAB.test(s) || + RE_OKLCH.test(s) || // legacy RE_RGB_LEGACY.test(s) || RE_RGBA_LEGACY.test(s) || @@ -1303,43 +1414,6 @@ } }); - var pow$1 = Math.pow; - var sign = Math.sign; - - /* - * L* [0..100] - * a [-100..100] - * b [-100..100] - */ - var oklab2rgb = function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - args = unpack(args, 'lab'); - var L = args[0]; - var a = args[1]; - var b = args[2]; - - var l = pow$1(L + 0.3963377774 * a + 0.2158037573 * b, 3); - var m = pow$1(L - 0.1055613458 * a - 0.0638541728 * b, 3); - var s = pow$1(L - 0.0894841775 * a - 1.291485548 * b, 3); - - return [ - 255 * lrgb2rgb(+4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s), - 255 * lrgb2rgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s), - 255 * lrgb2rgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s), - args.length > 3 ? args[3] : 1 - ]; - }; - - function lrgb2rgb(c) { - var abs = Math.abs(c); - if (abs > 0.0031308) { - return (sign(c) || 1) * (1.055 * pow$1(abs, 1 / 2.4) - 0.055); - } - return c * 12.92; - } - Color.prototype.oklab = function () { return rgb2oklab(this._rgb); }; diff --git a/dist/chroma-light.min.cjs b/dist/chroma-light.min.cjs index 21eb5fb4..1e876062 100644 --- a/dist/chroma-light.min.cjs +++ b/dist/chroma-light.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).chroma=r()}(this,(function(){"use strict";function t(t,r,n){return void 0===n&&(n=1),l(h(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].slice(0)}function s(t){if(t.length<2)return null;var r=t.length-1;return"string"==a(t[r])?t[r].toLowerCase():null}var u=Math.PI,l=Math.min,h=Math.max,c=u/180,f=180/u,d={format:{},autodetect:[]},g=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=s(r),i=!1;if(!o){i=!0,d.sorted||(d.autodetect=d.autodetect.sort((function(t,r){return r.p-t.p})),d.sorted=!0);for(var u=0,l=d.autodetect;u255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(c),3===e._rgb.length&&e._rgb.push(1)};g.prototype.toString=function(){return"function"==a(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var m=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t)))};m.version="3.0.0-0";var p=function(t){return Math.round(100*t)/100},b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,o=(t=i(t,"rgba"))[0],a=t[1],s=t[2],u=l(o/=255,a/=255,s/=255),c=h(o,a,s),f=(c+u)/2;return c===u?(n=0,e=Number.NaN):n=f<.5?(c-u)/(c+u):(c-u)/(2-c-u),o==c?e=(a-s)/(c-u):a==c?e=2+(s-o)/(c-u):s==c&&(e=4+(o-a)/(c-u)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},v=function(t){return Math.round(100*t)/100},y={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},M=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function w(t){var r=M.get(String(t).toLowerCase());if(!r)throw new Error("unknown Lab illuminant "+t);y.labWhitePoint=t,y.Xn=r[0],y.Zn=r[1]}function k(){return y.labWhitePoint}var x=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],s=n.slice(3),u=j(e,o,a),l=function(t,r,n){var e=y.Xn,o=y.Yn,a=y.Zn,i=y.kE,s=y.kK,u=t/e,l=r/o,h=n/a,c=u>i?Math.pow(u,1/3):(s*u+16)/116,f=l>i?Math.pow(l,1/3):(s*l+16)/116,d=h>i?Math.pow(h,1/3):(s*h+16)/116;return[116*f-16,500*(c-f),200*(f-d)]}(u[0],u[1],u[2]);return[l[0],l[1],l[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])};function _(t){var r=Math.sign(t);return((t=Math.abs(t))<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*r}var j=function(t,r,n){t=_(t/255),r=_(r/255),n=_(n/255);var e=y.MtxRGB2XYZ,o=y.MtxAdaptMa,a=y.MtxAdaptMaI,i=y.Xn,s=y.Yn,u=y.Zn,l=y.As,h=y.Bs,c=y.Cs,f=t*e.m00+r*e.m10+n*e.m20,d=t*e.m01+r*e.m11+n*e.m21,g=t*e.m02+r*e.m12+n*e.m22,m=i*o.m00+s*o.m10+u*o.m20,p=i*o.m01+s*o.m11+u*o.m21,b=i*o.m02+s*o.m12+u*o.m22,v=f*o.m00+d*o.m10+g*o.m20,M=f*o.m01+d*o.m11+g*o.m21,w=f*o.m02+d*o.m12+g*o.m22;return M*=p/h,w*=b/c,[f=(v*=m/l)*a.m00+M*a.m10+w*a.m20,d=v*a.m01+M*a.m11+w*a.m21,g=v*a.m02+M*a.m12+w*a.m22]},$=function(t){return Math.round(100*t)/100},A=Math.sqrt,F=Math.atan2,X=Math.round,Z=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=n[0],o=n[1],a=n[2],s=A(o*o+a*a),u=(F(a,o)*f+360)%360;return 0===X(1e4*s)&&(u=Number.NaN),[e,s,u]},E=Math.cbrt,Y=Math.pow,N=Math.sign,B=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],s=n.slice(3),u=[C(e/255),C(o/255),C(a/255)],l=u[0],h=u[1],c=u[2],f=E(.4122214708*l+.5363325363*h+.0514459929*c),d=E(.2119034982*l+.6806995451*h+.1073969566*c),g=E(.0883024619*l+.2817188376*h+.6299787005*c);return[.2104542553*f+.793617785*d-.0040720468*g,1.9779984951*f-2.428592205*d+.4505937099*g,.0259040371*f+.7827717662*d-.808675766*g].concat(s.length>0&&s[0]<1?[s[0]]:[])};function C(t){var r=Math.abs(t);return r<.04045?t/12.92:(N(t)||1)*Y((r+.055)/1.055,2.4)}var O=function(t){return Math.round(100*t)/100},R=function(t){return Math.round(100*t)/100},L=Math.round,W=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=s(t)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=s(t)||"lsa";return n[0]=p(n[0]||0)+"deg",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.substr(0,3)+"("+n.join(" ")+")"}(b(n),e);if("lab"===e.substr(0,3)){var o=k();w("d50");var a=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=s(t)||"lab";return n[0]=v(n[0])+"%",n[1]=v(n[1]),n[2]=v(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(x(n),e);return w(o),a}if("lch"===e.substr(0,3)){var u=k();w("d50");var l=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=s(t)||"lab";return n[0]=$(n[0])+"%",n[1]=$(n[1]),n[2]=$(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(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],s=n.slice(3),u=x(e,o,a),l=u[0],h=u[1],c=u[2],f=Z(l,h,c);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n),e);return w(u),l}return"oklab"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=O(100*n[0])+"%",n[1]=O(n[1]),n[2]=O(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(B(n)):"oklch"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=R(100*n[0])+"%",n[1]=R(n[1]),n[2]=R(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(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],s=n.slice(3),u=B(e,o,a),l=u[0],h=u[1],c=u[2],f=Z(l,h,c);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n)):(n[0]=L(n[0]),n[1]=L(n[1]),n[2]=L(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},K=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,o,a,s=(r=i(r,"hsl"))[0],u=r[1],l=r[2];if(0===u)e=o=a=255*l;else{var h=[0,0,0],c=[0,0,0],f=l<.5?l*(1+u):l+u-l*u,d=2*l-f,g=s/360;h[0]=g+1/3,h[1]=g,h[2]=g-1/3;for(var m=0;m<3;m++)h[m]<0&&(h[m]+=1),h[m]>1&&(h[m]-=1),6*h[m]<1?c[m]=d+6*(f-d)*h[m]:2*h[m]<1?c[m]=f:3*h[m]<2?c[m]=d+(f-d)*(2/3-h[m])*6:c[m]=d;e=(t=[255*c[0],255*c[1],255*c[2]])[0],o=t[1],a=t[2]}return r.length>3?[e,o,a,r[3]]:[e,o,a,1]},G=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=I(n,e,o),s=a[0],u=a[1],l=a[2],h=S(s,u,l);return[h[0],h[1],h[2],t.length>3?t[3]:1]},I=function(t,r,n){var e=y.kE,o=y.kK,a=y.kKE,i=y.Xn,s=y.Yn,u=y.Zn,l=(t+16)/116,h=.002*r+l,c=l-.005*n,f=h*h*h,d=c*c*c;return[(f>e?f:(116*h-16)/o)*i,(t>a?Math.pow((t+16)/116,3):t/o)*s,(d>e?d:(116*c-16)/o)*u]},P=function(t){var r=Math.sign(t);return((t=Math.abs(t))<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)*r},S=function(t,r,n){var e=y.MtxAdaptMa,o=y.MtxAdaptMaI,a=y.MtxXYZ2RGB,i=y.RefWhiteRGB,s=y.Xn,u=y.Yn,l=y.Zn,h=s*e.m00+u*e.m10+l*e.m20,c=s*e.m01+u*e.m11+l*e.m21,f=s*e.m02+u*e.m12+l*e.m22,d=i.X*e.m00+i.Y*e.m10+i.Z*e.m20,g=i.X*e.m01+i.Y*e.m11+i.Z*e.m21,m=i.X*e.m02+i.Y*e.m12+i.Z*e.m22,p=(t*e.m00+r*e.m10+n*e.m20)*(d/h),b=(t*e.m01+r*e.m11+n*e.m21)*(g/c),v=(t*e.m02+r*e.m12+n*e.m22)*(m/f),M=p*o.m00+b*o.m10+v*o.m20,w=p*o.m01+b*o.m11+v*o.m21,k=p*o.m02+b*o.m12+v*o.m22;return[255*P(M*a.m00+w*a.m10+k*a.m20),255*P(M*a.m01+w*a.m11+k*a.m21),255*P(M*a.m02+w*a.m12+k*a.m22)]},q=Math.sin,T=Math.cos,D=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=n[0],o=n[1],a=n[2];return isNaN(a)&&(a=0),[e,T(a*=c)*o,q(a)*o]}((t=i(t,"lch"))[0],t[1],t[2]),e=n[0],o=n[1],a=n[2],s=G(e,o,a);return[s[0],s[1],s[2],t.length>3?t[3]:1]},U=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,z=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,H=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,J=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,Q=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,V=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,tt=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,rt=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,nt=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,et=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ot=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,at=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,it=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,st=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,ut=Math.round,lt=function(r){return r.map((function(r,n){return n<=2?t(ut(r),0,255):r}))},ht=function(t,r,n,e){return void 0===r&&(r=0),void 0===n&&(n=100),void 0===e&&(e=!1),t.endsWith("%")&&(t=parseFloat(t.substr(0,t.length-1))/100,t=e?r+.5*(t+1)*(n-r):r+t*(n-r)),+t},ct=function(t,r){return"none"===t?r:t},ft=function(t){var r;if(t=t.toLowerCase().trim(),d.format.named)try{return d.format.named(t)}catch(t){}if((r=t.match(U))||(r=t.match(z))){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(H))||(r=t.match(J))){for(var o=r.slice(1,5),a=0;a<4;a++)o[a]=+o[a];return o}if((r=t.match(Q))||(r=t.match(V))){for(var i=r.slice(1,4),s=0;s<3;s++)i[s]=ut(2.55*i[s]);return i[3]=1,i}if((r=t.match(tt))||(r=t.match(rt))){for(var u=r.slice(1,5),l=0;l<3;l++)u[l]=ut(2.55*u[l]);return u[3]=+u[3],u}if((r=t.match(nt))||(r=t.match(et))){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;for(var c=K(h),f=0;f<3;f++)c[f]=ut(c[f]);return c[3]=1,c}if((r=t.match(ot))||(r=t.match(at))){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var m=K(g),p=0;p<3;p++)m[p]=ut(m[p]);return m[3]=+r[4],m}if(r=t.match(it)){var b=r.slice(1,4);b[0]=ht(b[0],0,100),b[1]=ht(b[1],-125,125,!0),b[2]=ht(b[2],-125,125,!0);var v=lt(G(b));return v[3]=void 0!==r[4]?+r[4]:1,v}if(r=t.match(st)){var y=r.slice(1,4);y[0]=ht(y[0],0,100),y[1]=ht(ct(y[1],0),0,150,!1),y[2]=+ct(y[2].replace("deg",""),0);var M=lt(D(y));return M[3]=void 0!==r[4]?+r[4]:1,M}};ft.test=function(t){return U.test(t)||H.test(t)||Q.test(t)||tt.test(t)||nt.test(t)||ot.test(t)||it.test(t)||z.test(t)||J.test(t)||V.test(t)||rt.test(t)||et.test(t)||at.test(t)},g.prototype.css=function(t){return W(this._rgb,t)};var dt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t,["css"])))};m.css=dt,d.format.css=ft,d.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)&&ft.test(t))return"css"}});var gt=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,mt=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,pt=Math.round;g.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],u=n[3],l=s(t)||"auto";void 0===u&&(u=1),"auto"===l&&(l=u<1?"rgba":"rgb");var h="000000"+((e=pt(e))<<16|(o=pt(o))<<8|(a=pt(a))).toString(16);h=h.substr(h.length-6);var c="0"+pt(255*u).toString(16);switch(c=c.substr(c.length-2),l.toLowerCase()){case"rgba":return"#"+h+c;case"argb":return"#"+c+h;default:return"#"+h}}(this._rgb,t)};var bt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t,["hex"])))};m.hex=bt,d.format.hex=function(t){if(t.match(gt)){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(mt)){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)},d.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"}}),g.prototype.hsl=function(){return b(this._rgb)};var vt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t,["hsl"])))};m.hsl=vt,d.format.hsl=K,d.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"}}),g.prototype.lab=function(){return x(this._rgb)};var yt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t,["lab"])))};Object.assign(m,{lab:yt,getLabWhitePoint:k,setLabWhitePoint:w}),d.format.lab=G,d.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 Mt=Math.pow,wt=Math.sign;function kt(t){var r=Math.abs(t);return r>.0031308?(wt(t)||1)*(1.055*Mt(r,1/2.4)-.055):12.92*t}g.prototype.oklab=function(){return B(this._rgb)};var xt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t,["oklab"])))};Object.assign(m,{oklab:xt}),d.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=Mt(n+.3963377774*e+.2158037573*o,3),s=Mt(n-.1055613458*e-.0638541728*o,3),u=Mt(n-.0894841775*e-1.291485548*o,3);return[255*kt(4.0767416621*a-3.3077115913*s+.2309699292*u),255*kt(-1.2684380046*a+2.6097574011*s-.3413193965*u),255*kt(-.0041960863*a-.7034186147*s+1.707614701*u),t.length>3?t[3]:1]},d.autodetect.push({p:2,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 _t=Math.round;g.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(_t)},g.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:_t(r):r}))};var jt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(g,[null].concat(t,["rgb"])))};Object.assign(m,{rgb:jt}),d.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},d.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"}}),g.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===a(t)?r?(this._rgb[3]=t,this):new g([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},g.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=y.Kn*t,new g(r,"lab").alpha(this.alpha(),!0)},g.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},g.prototype.darker=g.prototype.darken,g.prototype.brighter=g.prototype.brighten,g.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 $t={};function At(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($t[i]||e.length||(i=Object.keys($t)[0]),!$t[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==a(t)&&(t=new g(t)),"object"!==a(r)&&(r=new g(r)),$t[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}g.prototype.mix=g.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 At.apply(void 0,[this,t,r].concat(n))},g.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),o=e[0],i=e[1],s=this[o]();if(i){var u=o.indexOf(i)-("ok"===o.substr(0,2)?2:0);if(u>-1){if("string"==a(r))switch(r.charAt(0)){case"+":case"-":s[u]+=+r;break;case"*":s[u]*=+r.substr(1);break;case"/":s[u]/=+r.substr(1);break;default:s[u]=+r}else{if("number"!==a(r))throw new Error("unsupported value for Color.set");s[u]=r}var l=new g(s,o);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+i+" in mode "+o)}return s},g.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return At.apply(void 0,[this,"white",t].concat(r))},g.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return At.apply(void 0,[this,"black",t].concat(r))};var Ft=Math.sqrt,Xt=Math.pow;$t.lrgb=function(t,r,n){var e=t._rgb,o=e[0],a=e[1],i=e[2],s=r._rgb,u=s[0],l=s[1],h=s[2];return new g(Ft(Xt(o,2)*(1-n)+Xt(u,2)*n),Ft(Xt(a,2)*(1-n)+Xt(l,2)*n),Ft(Xt(i,2)*(1-n)+Xt(h,2)*n),"rgb")};return $t.oklab=function(t,r,n){var e=t.oklab(),o=r.oklab();return new g(e[0]+n*(o[0]-e[0]),e[1]+n*(o[1]-e[1]),e[2]+n*(o[2]-e[2]),"oklab")},Object.assign(m,{Color:g,valid:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(g,[null].concat(t))),!0}catch(t){return!1}},css:dt,hex:bt,hsl:vt,lab:yt,oklab:xt,rgb:jt,mix:At,interpolate:At}),m})); +!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r():"function"==typeof define&&define.amd?define(r):(t="undefined"!=typeof globalThis?globalThis:t||self).chroma=r()}(this,(function(){"use strict";function t(t,r,n){return void 0===n&&(n=1),l(c(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"==o(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0].slice(0)}function s(t){if(t.length<2)return null;var r=t.length-1;return"string"==o(t[r])?t[r].toLowerCase():null}var u=Math.PI,l=Math.min,c=Math.max,h=function(t){return Math.round(100*t)/100},f=function(t){return Math.round(100*t)/100},d=u/180,g=180/u,m={format:{},autodetect:[]},p=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=this;if("object"===o(r[0])&&r[0].constructor&&r[0].constructor===this.constructor)return r[0];var a=s(r),i=!1;if(!a){i=!0,m.sorted||(m.autodetect=m.autodetect.sort((function(t,r){return r.p-t.p})),m.sorted=!0);for(var u=0,l=m.autodetect;u255)&&(r._clipped=!0),r[n]=t(r[n],0,255)):3===n&&(r[n]=t(r[n],0,1));return r}(h),3===e._rgb.length&&e._rgb.push(1)};p.prototype.toString=function(){return"function"==o(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var v=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t)))};v.version="3.0.0";var b=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=i(t,"rgba"))[0],o=t[1],s=t[2],u=l(a/=255,o/=255,s/=255),h=c(a,o,s),f=(h+u)/2;return h===u?(n=0,e=Number.NaN):n=f<.5?(h-u)/(h+u):(h-u)/(2-h-u),a==h?e=(o-s)/(h-u):o==h?e=2+(s-a)/(h-u):s==h&&(e=4+(a-o)/(h-u)),(e*=60)<0&&(e+=360),t.length>3&&void 0!==t[3]?[e,n,f,t[3]]:[e,n,f]},y={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},w=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function M(t){var r=w.get(String(t).toLowerCase());if(!r)throw new Error("unknown Lab illuminant "+t);y.labWhitePoint=t,y.Xn=r[0],y.Zn=r[1]}function k(){return y.labWhitePoint}var x=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=A(e,a,o),l=function(t,r,n){var e=y.Xn,a=y.Yn,o=y.Zn,i=y.kE,s=y.kK,u=t/e,l=r/a,c=n/o,h=u>i?Math.pow(u,1/3):(s*u+16)/116,f=l>i?Math.pow(l,1/3):(s*l+16)/116,d=c>i?Math.pow(c,1/3):(s*c+16)/116;return[116*f-16,500*(h-f),200*(f-d)]}(u[0],u[1],u[2]);return[l[0],l[1],l[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])};function _(t){var r=Math.sign(t);return((t=Math.abs(t))<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))*r}var A=function(t,r,n){t=_(t/255),r=_(r/255),n=_(n/255);var e=y.MtxRGB2XYZ,a=y.MtxAdaptMa,o=y.MtxAdaptMaI,i=y.Xn,s=y.Yn,u=y.Zn,l=y.As,c=y.Bs,h=y.Cs,f=t*e.m00+r*e.m10+n*e.m20,d=t*e.m01+r*e.m11+n*e.m21,g=t*e.m02+r*e.m12+n*e.m22,m=i*a.m00+s*a.m10+u*a.m20,p=i*a.m01+s*a.m11+u*a.m21,v=i*a.m02+s*a.m12+u*a.m22,b=f*a.m00+d*a.m10+g*a.m20,w=f*a.m01+d*a.m11+g*a.m21,M=f*a.m02+d*a.m12+g*a.m22;return w*=p/c,M*=v/h,[f=(b*=m/l)*o.m00+w*o.m10+M*o.m20,d=b*o.m01+w*o.m11+M*o.m21,g=b*o.m02+w*o.m12+M*o.m22]},j=Math.sqrt,$=Math.atan2,F=Math.round,X=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=n[0],a=n[1],o=n[2],s=j(a*a+o*o),u=($(o,a)*g+360)%360;return 0===F(1e4*s)&&(u=Number.NaN),[e,s,u]};function Z(t,r){var n=t.length;Array.isArray(t[0])||(t=[t]),Array.isArray(r[0])||(r=r.map((function(t){return[t]})));var e=r[0].length,a=r[0].map((function(t,n){return r.map((function(t){return t[n]}))})),o=t.map((function(t){return a.map((function(r){return Array.isArray(t)?t.reduce((function(t,n,e){return t+n*(r[e]||0)}),0):r.reduce((function(r,n){return r+n*t}),0)}))}));return 1===n&&(o=o[0]),1===e?o.map((function(t){return t[0]})):o}var E=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=i(t,"rgb"),o=a[0],s=a[1],u=a[2],l=a.slice(3),c=A(o,s,u);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Z([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],c),Z(n,e.map((function(t){return Math.cbrt(t)})))).concat(l.length>0&&l[0]<1?[l[0]]:[])};var Y=Math.round,N=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgba"),e=s(t)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"hsla"),e=s(t)||"lsa";return n[0]=h(n[0]||0)+"deg",n[1]=h(100*n[1])+"%",n[2]=h(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.substr(0,3)+"("+n.join(" ")+")"}(b(n),e);if("lab"===e.substr(0,3)){var a=k();M("d50");var o=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab"),e=s(t)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(x(n),e);return M(a),o}if("lch"===e.substr(0,3)){var u=k();M("d50");var l=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=s(t)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=x(e,a,o),l=u[0],c=u[1],h=u[2],f=X(l,c,h);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n),e);return M(u),l}return"oklab"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=h(100*n[0])+"%",n[1]=f(n[1]),n[2]=f(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(E(n)):"oklch"===e.substr(0,5)?function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lab");return n[0]=h(100*n[0])+"%",n[1]=f(n[1]),n[2]=h(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"rgb"),e=n[0],a=n[1],o=n[2],s=n.slice(3),u=E(e,a,o),l=u[0],c=u[1],h=u[2],f=X(l,c,h);return[f[0],f[1],f[2]].concat(s.length>0&&s[0]<1?[s[0]]:[])}(n)):(n[0]=Y(n[0]),n[1]=Y(n[1]),n[2]=Y(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},B=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,a,o,s=(r=i(r,"hsl"))[0],u=r[1],l=r[2];if(0===u)e=a=o=255*l;else{var c=[0,0,0],h=[0,0,0],f=l<.5?l*(1+u):l+u-l*u,d=2*l-f,g=s/360;c[0]=g+1/3,c[1]=g,c[2]=g-1/3;for(var m=0;m<3;m++)c[m]<0&&(c[m]+=1),c[m]>1&&(c[m]-=1),6*c[m]<1?h[m]=d+6*(f-d)*c[m]:2*c[m]<1?h[m]=f:3*c[m]<2?h[m]=d+(f-d)*(2/3-c[m])*6:h[m]=d;e=(t=[255*h[0],255*h[1],255*h[2]])[0],a=t[1],o=t[2]}return r.length>3?[e,a,o,r[3]]:[e,a,o,1]},C=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lab"))[0],e=t[1],a=t[2],o=O(n,e,a),s=o[0],u=o[1],l=o[2],c=L(s,u,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},O=function(t,r,n){var e=y.kE,a=y.kK,o=y.kKE,i=y.Xn,s=y.Yn,u=y.Zn,l=(t+16)/116,c=.002*r+l,h=l-.005*n,f=c*c*c,d=h*h*h;return[(f>e?f:(116*c-16)/a)*i,(t>o?Math.pow((t+16)/116,3):t/a)*s,(d>e?d:(116*h-16)/a)*u]},R=function(t){var r=Math.sign(t);return((t=Math.abs(t))<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)*r},L=function(t,r,n){var e=y.MtxAdaptMa,a=y.MtxAdaptMaI,o=y.MtxXYZ2RGB,i=y.RefWhiteRGB,s=y.Xn,u=y.Yn,l=y.Zn,c=s*e.m00+u*e.m10+l*e.m20,h=s*e.m01+u*e.m11+l*e.m21,f=s*e.m02+u*e.m12+l*e.m22,d=i.X*e.m00+i.Y*e.m10+i.Z*e.m20,g=i.X*e.m01+i.Y*e.m11+i.Z*e.m21,m=i.X*e.m02+i.Y*e.m12+i.Z*e.m22,p=(t*e.m00+r*e.m10+n*e.m20)*(d/c),v=(t*e.m01+r*e.m11+n*e.m21)*(g/h),b=(t*e.m02+r*e.m12+n*e.m22)*(m/f),w=p*a.m00+v*a.m10+b*a.m20,M=p*a.m01+v*a.m11+b*a.m21,k=p*a.m02+v*a.m12+b*a.m22;return[255*R(w*o.m00+M*o.m10+k*o.m20),255*R(w*o.m01+M*o.m11+k*o.m21),255*R(w*o.m02+M*o.m12+k*o.m22)]},W=Math.sin,K=Math.cos,G=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=i(t,"lch"),e=n[0],a=n[1],o=n[2];return isNaN(o)&&(o=0),[e,K(o*=d)*a,W(o)*a]},I=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a=(t=i(t,"lab"))[0],o=t[1],s=t[2],u=t.slice(3),l=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Z([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,o,s]),Z(n,e.map((function(t){return Math.pow(t,3)})))),c=l[0],h=l[1],f=l[2],d=L(c,h,f);return[d[0],d[1],d[2]].concat(u.length>0&&u[0]<1?[u[0]]:[])};var P=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,S=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,q=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,T=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,D=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,U=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,z=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,H=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,J=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,Q=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,V=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,tt=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,rt=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,nt=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,et=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,at=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,ot=Math.round,it=function(r){return r.map((function(r,n){return n<=2?t(ot(r),0,255):r}))},st=function(t,r,n,e){return void 0===r&&(r=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=e?r+.5*(t+1)*(n-r):r+t*(n-r)),+t},ut=function(t,r){return"none"===t?r:t},lt=function(t){var r;if(t=t.toLowerCase().trim(),m.format.named)try{return m.format.named(t)}catch(t){}if((r=t.match(P))||(r=t.match(S))){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(q))||(r=t.match(T))){for(var a=r.slice(1,5),o=0;o<4;o++)a[o]=+a[o];return a}if((r=t.match(D))||(r=t.match(U))){for(var s=r.slice(1,4),u=0;u<3;u++)s[u]=ot(2.55*s[u]);return s[3]=1,s}if((r=t.match(z))||(r=t.match(H))){for(var l=r.slice(1,5),c=0;c<3;c++)l[c]=ot(2.55*l[c]);return l[3]=+l[3],l}if((r=t.match(J))||(r=t.match(Q))){var h=r.slice(1,4);h[1]*=.01,h[2]*=.01;for(var f=B(h),d=0;d<3;d++)f[d]=ot(f[d]);return f[3]=1,f}if((r=t.match(V))||(r=t.match(tt))){var g=r.slice(1,4);g[1]*=.01,g[2]*=.01;for(var p=B(g),v=0;v<3;v++)p[v]=ot(p[v]);return p[3]=+r[4],p}if(r=t.match(rt)){var b=r.slice(1,4);b[0]=st(b[0],0,100),b[1]=st(b[1],-125,125,!0),b[2]=st(b[2],-125,125,!0);var y=k();M("d50");var w=it(C(b));return M(y),w[3]=void 0!==r[4]?+r[4]:1,w}if(r=t.match(nt)){var x=r.slice(1,4);x[0]=st(x[0],0,100),x[1]=st(ut(x[1],0),0,150,!1),x[2]=+ut(x[2].replace("deg",""),0);var _=k();M("d50");var A=it(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lch"))[0],e=t[1],a=t[2],o=G(n,e,a),s=o[0],u=o[1],l=o[2],c=C(s,u,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]}(x));return M(_),A[3]=void 0!==r[4]?+r[4]:1,A}if(r=t.match(et)){var j=r.slice(1,4);j[0]=st(j[0],0,1),j[1]=st(j[1],-.4,.4,!0),j[2]=st(j[2],-.4,.4,!0);var $=it(I(j));return $[3]=void 0!==r[4]?+r[4]:1,$}if(r=t.match(at)){var F=r.slice(1,4);F[0]=st(F[0],0,1),F[1]=st(ut(F[1],0),0,.4,!1),F[2]=+ut(F[2].replace("deg",""),0);var X=it(function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=i(t,"lch"))[0],e=t[1],a=t[2],o=t.slice(3),s=G(n,e,a),u=s[0],l=s[1],c=s[2],h=I(u,l,c);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])}(F));return X[3]=void 0!==r[4]?+r[4]:1,X}};lt.test=function(t){return P.test(t)||q.test(t)||D.test(t)||z.test(t)||J.test(t)||V.test(t)||rt.test(t)||nt.test(t)||et.test(t)||at.test(t)||S.test(t)||T.test(t)||U.test(t)||H.test(t)||Q.test(t)||tt.test(t)},p.prototype.css=function(t){return N(this._rgb,t)};var ct=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["css"])))};v.css=ct,m.format.css=lt,m.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"===o(t)&<.test(t))return"css"}});var ht=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,ft=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,dt=Math.round;p.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],a=n[1],o=n[2],u=n[3],l=s(t)||"auto";void 0===u&&(u=1),"auto"===l&&(l=u<1?"rgba":"rgb");var c="000000"+((e=dt(e))<<16|(a=dt(a))<<8|(o=dt(o))).toString(16);c=c.substr(c.length-6);var h="0"+dt(255*u).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)};var gt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["hex"])))};v.hex=gt,m.format.hex=function(t){if(t.match(ht)){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(ft)){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)},m.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"===o(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}}),p.prototype.hsl=function(){return b(this._rgb)};var mt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["hsl"])))};v.hsl=mt,m.format.hsl=B,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"hsl"))&&3===t.length)return"hsl"}}),p.prototype.lab=function(){return x(this._rgb)};var pt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["lab"])))};Object.assign(v,{lab:pt,getLabWhitePoint:k,setLabWhitePoint:M}),m.format.lab=C,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"lab"))&&3===t.length)return"lab"}}),p.prototype.oklab=function(){return E(this._rgb)};var vt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["oklab"])))};Object.assign(v,{oklab:vt}),m.format.oklab=I,m.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"oklab"))&&3===t.length)return"oklab"}});var bt=Math.round;p.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(bt)},p.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:bt(r):r}))};var yt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(p,[null].concat(t,["rgb"])))};Object.assign(v,{rgb:yt}),m.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},m.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if("array"===o(t=i(t,"rgba"))&&(3===t.length||4===t.length&&"number"==o(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}}),p.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===o(t)?r?(this._rgb[3]=t,this):new p([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]},p.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=y.Kn*t,new p(r,"lab").alpha(this.alpha(),!0)},p.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},p.prototype.darker=p.prototype.darken,p.prototype.brighter=p.prototype.brighten,p.prototype.get=function(t){var r=t.split("."),n=r[0],e=r[1],a=this[n]();if(e){var o=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(o>-1)return a[o];throw new Error("unknown channel "+e+" in mode "+n)}return a};var wt={};function Mt(t,r,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var i=e[0]||"lrgb";if(wt[i]||e.length||(i=Object.keys(wt)[0]),!wt[i])throw new Error("interpolation mode "+i+" is not defined");return"object"!==o(t)&&(t=new p(t)),"object"!==o(r)&&(r=new p(r)),wt[i](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))}p.prototype.mix=p.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 Mt.apply(void 0,[this,t,r].concat(n))},p.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),a=e[0],i=e[1],s=this[a]();if(i){var u=a.indexOf(i)-("ok"===a.substr(0,2)?2:0);if(u>-1){if("string"==o(r))switch(r.charAt(0)){case"+":case"-":s[u]+=+r;break;case"*":s[u]*=+r.substr(1);break;case"/":s[u]/=+r.substr(1);break;default:s[u]=+r}else{if("number"!==o(r))throw new Error("unsupported value for Color.set");s[u]=r}var l=new p(s,a);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+i+" in mode "+a)}return s},p.prototype.tint=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Mt.apply(void 0,[this,"white",t].concat(r))},p.prototype.shade=function(t){void 0===t&&(t=.5);for(var r=[],n=arguments.length-1;n-- >0;)r[n]=arguments[n+1];return Mt.apply(void 0,[this,"black",t].concat(r))};var kt=Math.sqrt,xt=Math.pow;wt.lrgb=function(t,r,n){var e=t._rgb,a=e[0],o=e[1],i=e[2],s=r._rgb,u=s[0],l=s[1],c=s[2];return new p(kt(xt(a,2)*(1-n)+xt(u,2)*n),kt(xt(o,2)*(1-n)+xt(l,2)*n),kt(xt(i,2)*(1-n)+xt(c,2)*n),"rgb")};return wt.oklab=function(t,r,n){var e=t.oklab(),a=r.oklab();return new p(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")},Object.assign(v,{Color:p,valid:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(p,[null].concat(t))),!0}catch(t){return!1}},css:ct,hex:gt,hsl:mt,lab:pt,oklab:vt,rgb:yt,mix:Mt,interpolate:Mt}),v})); diff --git a/dist/chroma.cjs b/dist/chroma.cjs index 332f83de..0769b043 100644 --- a/dist/chroma.cjs +++ b/dist/chroma.cjs @@ -132,6 +132,9 @@ var min$3 = Math.min; var max$3 = Math.max; + var rnd2 = function (a) { return Math.round(a * 100) / 100; }; + var rnd3 = function (a) { return Math.round(a * 100) / 100; }; + var TWOPI = PI$2 * 2; var PITHIRD = PI$2 / 3; var DEG2RAD = PI$2 / 180; @@ -192,7 +195,7 @@ }; // this gets updated automatically - var version = '3.0.0-0'; + var version = '3.0.0'; var chroma = function () { var args = [], len = arguments.length; @@ -270,8 +273,6 @@ } }); - var rnd$4 = function (a) { return Math.round(a * 100) / 100; }; - /* * supported arguments: * - hsl2css(h,s,l) @@ -286,9 +287,9 @@ var hsla = unpack(args, 'hsla'); var mode = last(args) || 'lsa'; - hsla[0] = rnd$4(hsla[0] || 0) + 'deg'; - hsla[1] = rnd$4(hsla[1] * 100) + '%'; - hsla[2] = rnd$4(hsla[2] * 100) + '%'; + hsla[0] = rnd2(hsla[0] || 0) + 'deg'; + hsla[1] = rnd2(hsla[1] * 100) + '%'; + hsla[2] = rnd2(hsla[2] * 100) + '%'; if (mode === 'hsla' || (hsla.length > 3 && hsla[3] < 1)) { hsla[3] = '/ ' + (hsla.length > 3 ? hsla[3] : 1); mode = 'hsla'; @@ -345,8 +346,6 @@ return [h, s, l]; }; - var rnd$3 = function (a) { return Math.round(a * 100) / 100; }; - /* * supported arguments: * - lab2css(l,a,b) @@ -360,9 +359,9 @@ var laba = unpack(args, 'lab'); var mode = last(args) || 'lab'; - laba[0] = rnd$3(laba[0]) + '%'; - laba[1] = rnd$3(laba[1]); - laba[2] = rnd$3(laba[2]); + laba[0] = rnd2(laba[0]) + '%'; + laba[1] = rnd2(laba[1]); + laba[2] = rnd2(laba[2]); if (mode === 'laba' || (laba.length > 3 && laba[3] < 1)) { laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1); } else { @@ -576,8 +575,6 @@ return [x, y, z]; }; - var rnd$2 = function (a) { return Math.round(a * 100) / 100; }; - /* * supported arguments: * - lab2css(l,a,b) @@ -591,9 +588,9 @@ var lcha = unpack(args, 'lch'); var mode = last(args) || 'lab'; - lcha[0] = rnd$2(lcha[0]) + '%'; - lcha[1] = rnd$2(lcha[1]); - lcha[2] = rnd$2(lcha[2]) + 'deg'; // add deg unit to hue + lcha[0] = rnd2(lcha[0]) + '%'; + lcha[1] = rnd2(lcha[1]); + lcha[2] = rnd2(lcha[2]) + 'deg'; // add deg unit to hue if (mode === 'lcha' || (lcha.length > 3 && lcha[3] < 1)) { lcha[3] = '/ ' + (lcha.length > 3 ? lcha[3] : 1); } else { @@ -640,58 +637,89 @@ return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); }; - var cbrt = Math.cbrt; - var pow$8 = Math.pow; - var sign$1 = Math.sign; + // from https://www.w3.org/TR/css-color-4/multiply-matrices.js + function multiplyMatrices(A, B) { + var m = A.length; + + if (!Array.isArray(A[0])) { + // A is vector, convert to [[a, b, c, ...]] + A = [A]; + } + + if (!Array.isArray(B[0])) { + // B is vector, convert to [[a], [b], [c], ...]] + B = B.map(function (x) { return [x]; }); + } + + var p = B[0].length; + var B_cols = B[0].map(function (_, i) { return B.map(function (x) { return x[i]; }); }); // transpose B + var product = A.map(function (row) { return B_cols.map(function (col) { + if (!Array.isArray(row)) { + return col.reduce(function (a, c) { return a + c * row; }, 0); + } + + return row.reduce(function (a, c, i) { return a + c * (col[i] || 0); }, 0); + }); } + ); + + if (m === 1) { + product = product[0]; // Avoid [[a, b, c, ...]] + } + + if (p === 1) { + return product.map(function (x) { return x[0]; }); // Avoid [[a], [b], [c], ...]] + } + + return product; + } var rgb2oklab = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; - // OKLab color space implementation taken from - // https://bottosson.github.io/posts/oklab/ var ref = unpack(args, 'rgb'); var r = ref[0]; var g = ref[1]; var b = ref[2]; var rest = ref.slice(3); - var ref$1 = [ - rgb2lrgb(r / 255), - rgb2lrgb(g / 255), - rgb2lrgb(b / 255) + var xyz = rgb2xyz(r, g, b); + var oklab = XYZ_to_OKLab(xyz); + return oklab.concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); + }; + + // from https://www.w3.org/TR/css-color-4/#color-conversion-code + function XYZ_to_OKLab(XYZ) { + // Given XYZ relative to D65, convert to OKLab + var XYZtoLMS = [ + [0.819022437996703, 0.3619062600528904, -0.1288737815209879], + [0.0329836539323885, 0.9292868615863434, 0.0361446663506424], + [0.0481771893596242, 0.2642395317527308, 0.6335478284694309] + ]; + var LMStoOKLab = [ + [0.210454268309314, 0.7936177747023054, -0.0040720430116193], + [1.9779985324311684, -2.4285922420485799, 0.450593709617411], + [0.0259040424655478, 0.7827717124575296, -0.8086757549230774] ]; - var lr = ref$1[0]; - var lg = ref$1[1]; - var lb = ref$1[2]; - var l = cbrt(0.4122214708 * lr + 0.5363325363 * lg + 0.0514459929 * lb); - var m = cbrt(0.2119034982 * lr + 0.6806995451 * lg + 0.1073969566 * lb); - var s = cbrt(0.0883024619 * lr + 0.2817188376 * lg + 0.6299787005 * lb); - return [ - 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, - 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, - 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : []) + var LMS = multiplyMatrices(XYZtoLMS, XYZ); + // JavaScript Math.cbrt returns a sign-matched cube root + // beware if porting to other languages + // especially if tempted to use a general power function + return multiplyMatrices( + LMStoOKLab, + LMS.map(function (c) { return Math.cbrt(c); }) ); - }; - - function rgb2lrgb(c) { - var abs = Math.abs(c); - if (abs < 0.04045) { - return c / 12.92; - } - return (sign$1(c) || 1) * pow$8((abs + 0.055) / 1.055, 2.4); + // L in range [0,1]. For use in CSS, multiply by 100 and add a percent } - var rnd$1 = function (a) { return Math.round(a * 100) / 100; }; - var oklab2css$1 = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var laba = unpack(args, 'lab'); - laba[0] = rnd$1(laba[0] * 100) + '%'; - laba[1] = rnd$1(laba[1]); - laba[2] = rnd$1(laba[2]); + laba[0] = rnd2(laba[0] * 100) + '%'; + laba[1] = rnd3(laba[1]); + laba[2] = rnd3(laba[2]); if (laba.length > 3 && laba[3] < 1) { laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1); } else { @@ -720,16 +748,14 @@ return [L, c, h ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); }; - var rnd = function (a) { return Math.round(a * 100) / 100; }; - var oklab2css = function () { var args = [], len = arguments.length; while ( len-- ) args[ len ] = arguments[ len ]; var laba = unpack(args, 'lab'); - laba[0] = rnd(laba[0] * 100) + '%'; - laba[1] = rnd(laba[1]); - laba[2] = rnd(laba[2]) + 'deg'; + laba[0] = rnd2(laba[0] * 100) + '%'; + laba[1] = rnd3(laba[1]); + laba[2] = rnd2(laba[2]) + 'deg'; if (laba.length > 3 && laba[3] < 1) { laba[3] = '/ ' + (laba.length > 3 ? laba[3] : 1); } else { @@ -986,6 +1012,67 @@ return [r, g, b, args.length > 3 ? args[3] : 1]; }; + var oklab2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack(args, 'lab'); + var L = args[0]; + var a = args[1]; + var b = args[2]; + var rest = args.slice(3); + var ref = OKLab_to_XYZ([L, a, b]); + var X = ref[0]; + var Y = ref[1]; + var Z = ref[2]; + var ref$1 = xyz2rgb(X, Y, Z); + var r = ref$1[0]; + var g = ref$1[1]; + var b_ = ref$1[2]; + return [r, g, b_ ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); + }; + + // from https://www.w3.org/TR/css-color-4/#color-conversion-code + function OKLab_to_XYZ(OKLab) { + // Given OKLab, convert to XYZ relative to D65 + var LMStoXYZ = [ + [1.2268798758459243, -0.5578149944602171, 0.2813910456659647], + [-0.0405757452148008, 1.112286803280317, -0.0717110580655164], + [-0.0763729366746601, -0.4214933324022432, 1.5869240198367816] + ]; + var OKLabtoLMS = [ + [1.0, 0.3963377773761749, 0.2158037573099136], + [1.0, -0.1055613458156586, -0.0638541728258133], + [1.0, -0.0894841775298119, -1.2914855480194092] + ]; + + var LMSnl = multiplyMatrices(OKLabtoLMS, OKLab); + return multiplyMatrices( + LMStoXYZ, + LMSnl.map(function (c) { return Math.pow( c, 3 ); }) + ); + } + + var oklch2rgb = function () { + var args = [], len = arguments.length; + while ( len-- ) args[ len ] = arguments[ len ]; + + args = unpack(args, 'lch'); + var l = args[0]; + var c = args[1]; + var h = args[2]; + var rest = args.slice(3); + var ref = lch2lab(l, c, h); + var L = ref[0]; + var a = ref[1]; + var b_ = ref[2]; + var ref$1 = oklab2rgb(L, a, b_); + var r = ref$1[0]; + var g = ref$1[1]; + var b = ref$1[2]; + return [r, g, b ].concat( (rest.length > 0 && rest[0] < 1 ? [rest[0]] : [])); + }; + var RE_RGB = /^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/; var RE_RGB_LEGACY = /^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/; @@ -1017,9 +1104,11 @@ var RE_LAB = /^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; var RE_LCH = - /^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; - // const RE_OKLAB = - // /^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; + /^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; + var RE_OKLAB = + /^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; + var RE_OKLCH = + /^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/; var round$3 = Math.round; @@ -1032,8 +1121,8 @@ if ( max === void 0 ) max = 100; if ( signed === void 0 ) signed = false; - if (pct.endsWith('%')) { - pct = parseFloat(pct.substr(0, pct.length - 1)) / 100; + if (typeof pct === 'string' && pct.endsWith('%')) { + pct = parseFloat(pct.substring(0, pct.length - 1)) / 100; if (signed) { // signed percentages are in the range -100% to 100% pct = min + (pct + 1) * 0.5 * (max - min); @@ -1129,7 +1218,12 @@ lab[0] = percentToAbsolute(lab[0], 0, 100); lab[1] = percentToAbsolute(lab[1], -125, 125, true); lab[2] = percentToAbsolute(lab[2], -125, 125, true); + // convert to D50 Lab whitepoint + var wp = getLabWhitePoint(); + setLabWhitePoint('d50'); var rgb$6 = roundRGB(lab2rgb(lab)); + // convert back to original Lab whitepoint + setLabWhitePoint(wp); rgb$6[3] = m[4] !== undefined ? +m[4] : 1; return rgb$6; } @@ -1139,20 +1233,35 @@ lch[0] = percentToAbsolute(lch[0], 0, 100); lch[1] = percentToAbsolute(noneToValue(lch[1], 0), 0, 150, false); lch[2] = +noneToValue(lch[2].replace('deg', ''), 0); + // convert to D50 Lab whitepoint + var wp$1 = getLabWhitePoint(); + setLabWhitePoint('d50'); var rgb$7 = roundRGB(lch2rgb(lch)); + // convert back to original Lab whitepoint + setLabWhitePoint(wp$1); rgb$7[3] = m[4] !== undefined ? +m[4] : 1; return rgb$7; } - // if ((m = css.match(RE_OKLAB))) { - // const oklab = m.slice(1, 4); - // oklab[0] = percentToAbsolute(oklab[0], 0, 1); - // oklab[1] = percentToAbsolute(oklab[1], -0.4, 0.4, true); - // oklab[2] = percentToAbsolute(oklab[2], -0.4, 0.4, true); - // const rgb = roundRGB(oklab2rgb(oklab)); - // rgb[3] = m[4] !== undefined ? +m[4] : 1; - // return rgb; - // } + if ((m = css.match(RE_OKLAB))) { + var oklab = m.slice(1, 4); + oklab[0] = percentToAbsolute(oklab[0], 0, 1); + oklab[1] = percentToAbsolute(oklab[1], -0.4, 0.4, true); + oklab[2] = percentToAbsolute(oklab[2], -0.4, 0.4, true); + var rgb$8 = roundRGB(oklab2rgb(oklab)); + rgb$8[3] = m[4] !== undefined ? +m[4] : 1; + return rgb$8; + } + + if ((m = css.match(RE_OKLCH))) { + var oklch = m.slice(1, 4); + oklch[0] = percentToAbsolute(oklch[0], 0, 1); + oklch[1] = percentToAbsolute(noneToValue(oklch[1], 0), 0, 0.4, false); + oklch[2] = +noneToValue(oklch[2].replace('deg', ''), 0); + var rgb$9 = roundRGB(oklch2rgb(oklch)); + rgb$9[3] = m[4] !== undefined ? +m[4] : 1; + return rgb$9; + } }; css2rgb.test = function (s) { @@ -1165,7 +1274,9 @@ RE_HSL.test(s) || RE_HSLA.test(s) || RE_LAB.test(s) || - // RE_OKLAB.test(s) || + RE_LCH.test(s) || + RE_OKLAB.test(s) || + RE_OKLCH.test(s) || // legacy RE_RGB_LEGACY.test(s) || RE_RGBA_LEGACY.test(s) || @@ -1977,43 +2088,6 @@ input.format.temperature = temperature2rgb; - var pow$7 = Math.pow; - var sign = Math.sign; - - /* - * L* [0..100] - * a [-100..100] - * b [-100..100] - */ - var oklab2rgb = function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - args = unpack(args, 'lab'); - var L = args[0]; - var a = args[1]; - var b = args[2]; - - var l = pow$7(L + 0.3963377774 * a + 0.2158037573 * b, 3); - var m = pow$7(L - 0.1055613458 * a - 0.0638541728 * b, 3); - var s = pow$7(L - 0.0894841775 * a - 1.291485548 * b, 3); - - return [ - 255 * lrgb2rgb(+4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s), - 255 * lrgb2rgb(-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s), - 255 * lrgb2rgb(-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s), - args.length > 3 ? args[3] : 1 - ]; - }; - - function lrgb2rgb(c) { - var abs = Math.abs(c); - if (abs > 0.0031308) { - return (sign(c) || 1) * (1.055 * pow$7(abs, 1 / 2.4) - 0.055); - } - return c * 12.92; - } - Color.prototype.oklab = function () { return rgb2oklab(this._rgb); }; @@ -2041,25 +2115,6 @@ } }); - var oklch2rgb = function () { - var args = [], len = arguments.length; - while ( len-- ) args[ len ] = arguments[ len ]; - - args = unpack(args, 'lch'); - var l = args[0]; - var c = args[1]; - var h = args[2]; - var ref = lch2lab(l, c, h); - var L = ref[0]; - var a = ref[1]; - var b_ = ref[2]; - var ref$1 = oklab2rgb(L, a, b_); - var r = ref$1[0]; - var g = ref$1[1]; - var b = ref$1[2]; - return [r, g, b, args.length > 3 ? args[3] : 1]; - }; - Color.prototype.oklch = function () { return rgb2oklch(this._rgb); }; diff --git a/dist/chroma.min.cjs b/dist/chroma.min.cjs index e567f2c5..4fa5f456 100644 --- a/dist/chroma.min.cjs +++ b/dist/chroma.min.cjs @@ -55,4 +55,4 @@ * @preserve */ -!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=t()}(this,(function(){"use strict";function r(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),l(h(t,r),n)}function t(t){t._clipped=!1,t._unclipped=t.slice(0);for(var n=0;n<=3;n++)n<3?((t[n]<0||t[n]>255)&&(t._clipped=!0),t[n]=r(t[n],0,255)):3===n&&(t[n]=r(t[n],0,1));return t}for(var n={},e=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];e=3?Array.prototype.slice.call(r):"object"==o(r[0])&&t?t.split("").filter((function(t){return void 0!==r[0][t]})).map((function(t){return r[0][t]})):r[0].slice(0)}function c(r){if(r.length<2)return null;var t=r.length-1;return"string"==o(r[t])?r[t].toLowerCase():null}var i=Math.PI,l=Math.min,h=Math.max,s=2*i,d=i/3,b=i/180,g=180/i,v={format:{},autodetect:[]},p=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=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,v.sorted||(v.autodetect=v.autodetect.sort((function(r,t){return t.p-r.p})),v.sorted=!0);for(var u=0,i=v.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[n>=1?0:255*(1-n)*(1-f),e>=1?0:255*(1-e)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var k=function(r){return Math.round(100*r)/100},M=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,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),s=(i+c)/2;return i===c?(n=0,e=Number.NaN):n=s<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?e=(f-o)/(i-c):f==i?e=2+(o-a)/(i-c):o==i&&(e=4+(a-f)/(i-c)),(e*=60)<0&&(e+=360),r.length>3&&void 0!==r[3]?[e,n,s,r[3]]:[e,n,s]},N=function(r){return Math.round(100*r)/100},_={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},x=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function A(r){var t=x.get(String(r).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+r);_.labWhitePoint=r,_.Xn=t[0],_.Zn=t[1]}function j(){return _.labWhitePoint}var E=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=F(e,a,f),i=function(r,t,n){var e=_.Xn,a=_.Yn,f=_.Zn,o=_.kE,u=_.kK,c=r/e,i=t/a,l=n/f,h=c>o?Math.pow(c,1/3):(u*c+16)/116,s=i>o?Math.pow(i,1/3):(u*i+16)/116,d=l>o?Math.pow(l,1/3):(u*l+16)/116;return[116*s-16,500*(h-s),200*(s-d)]}(c[0],c[1],c[2]);return[i[0],i[1],i[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function O(r){var t=Math.sign(r);return((r=Math.abs(r))<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4))*t}var F=function(r,t,n){r=O(r/255),t=O(t/255),n=O(n/255);var e=_.MtxRGB2XYZ,a=_.MtxAdaptMa,f=_.MtxAdaptMaI,o=_.Xn,u=_.Yn,c=_.Zn,i=_.As,l=_.Bs,h=_.Cs,s=r*e.m00+t*e.m10+n*e.m20,d=r*e.m01+t*e.m11+n*e.m21,b=r*e.m02+t*e.m12+n*e.m22,g=o*a.m00+u*a.m10+c*a.m20,v=o*a.m01+u*a.m11+c*a.m21,p=o*a.m02+u*a.m12+c*a.m22,m=s*a.m00+d*a.m10+b*a.m20,y=s*a.m01+d*a.m11+b*a.m21,w=s*a.m02+d*a.m12+b*a.m22;return y*=v/l,w*=p/h,[s=(m*=g/i)*f.m00+y*f.m10+w*f.m20,d=m*f.m01+y*f.m11+w*f.m21,b=m*f.m02+y*f.m12+w*f.m22]},L=function(r){return Math.round(100*r)/100},P=Math.sqrt,B=Math.atan2,G=Math.round,R=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=n[0],a=n[1],f=n[2],o=P(a*a+f*f),c=(B(f,a)*g+360)%360;return 0===G(1e4*o)&&(c=Number.NaN),[e,o,c]},Y=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=E(e,a,f),i=c[0],l=c[1],h=c[2],s=R(i,l,h);return[s[0],s[1],s[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},q=Math.cbrt,X=Math.pow,$=Math.sign,C=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=[Z(e/255),Z(a/255),Z(f/255)],i=c[0],l=c[1],h=c[2],s=q(.4122214708*i+.5363325363*l+.0514459929*h),d=q(.2119034982*i+.6806995451*l+.1073969566*h),b=q(.0883024619*i+.2817188376*l+.6299787005*h);return[.2104542553*s+.793617785*d-.0040720468*b,1.9779984951*s-2.428592205*d+.4505937099*b,.0259040371*s+.7827717662*d-.808675766*b].concat(o.length>0&&o[0]<1?[o[0]]:[])};function Z(r){var t=Math.abs(r);return t<.04045?r/12.92:($(r)||1)*X((t+.055)/1.055,2.4)}var S=function(r){return Math.round(100*r)/100},W=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=C(e,a,f),i=c[0],l=c[1],h=c[2],s=R(i,l,h);return[s[0],s[1],s[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},I=function(r){return Math.round(100*r)/100},K=Math.round,z=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=c(r)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hsla"),e=c(r)||"lsa";return n[0]=k(n[0]||0)+"deg",n[1]=k(100*n[1])+"%",n[2]=k(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.substr(0,3)+"("+n.join(" ")+")"}(M(n),e);if("lab"===e.substr(0,3)){var a=j();A("d50");var f=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=c(r)||"lab";return n[0]=N(n[0])+"%",n[1]=N(n[1]),n[2]=N(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(E(n),e);return A(a),f}if("lch"===e.substr(0,3)){var o=j();A("d50");var i=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=c(r)||"lab";return n[0]=L(n[0])+"%",n[1]=L(n[1]),n[2]=L(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(Y(n),e);return A(o),i}return"oklab"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=S(100*n[0])+"%",n[1]=S(n[1]),n[2]=S(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}(C(n)):"oklch"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=I(100*n[0])+"%",n[1]=I(n[1]),n[2]=I(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(W(n)):(n[0]=K(n[0]),n[1]=K(n[1]),n[2]=K(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},U=function(){for(var r,t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsl"))[0],c=t[1],i=t[2];if(0===c)e=a=f=255*i;else{var l=[0,0,0],h=[0,0,0],s=i<.5?i*(1+c):i+c-i*c,d=2*i-s,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]=d+6*(s-d)*l[g]:2*l[g]<1?h[g]=s:3*l[g]<2?h[g]=d+(s-d)*(2/3-l[g])*6:h[g]=d;e=(r=[255*h[0],255*h[1],255*h[2]])[0],a=r[1],f=r[2]}return t.length>3?[e,a,f,t[3]]:[e,a,f,1]},V=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lab"))[0],e=r[1],a=r[2],f=D(n,e,a),o=f[0],c=f[1],i=f[2],l=H(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},D=function(r,t,n){var e=_.kE,a=_.kK,f=_.kKE,o=_.Xn,u=_.Yn,c=_.Zn,i=(r+16)/116,l=.002*t+i,h=i-.005*n,s=l*l*l,d=h*h*h;return[(s>e?s:(116*l-16)/a)*o,(r>f?Math.pow((r+16)/116,3):r/a)*u,(d>e?d:(116*h-16)/a)*c]},T=function(r){var t=Math.sign(r);return((r=Math.abs(r))<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)*t},H=function(r,t,n){var e=_.MtxAdaptMa,a=_.MtxAdaptMaI,f=_.MtxXYZ2RGB,o=_.RefWhiteRGB,u=_.Xn,c=_.Yn,i=_.Zn,l=u*e.m00+c*e.m10+i*e.m20,h=u*e.m01+c*e.m11+i*e.m21,s=u*e.m02+c*e.m12+i*e.m22,d=o.X*e.m00+o.Y*e.m10+o.Z*e.m20,b=o.X*e.m01+o.Y*e.m11+o.Z*e.m21,g=o.X*e.m02+o.Y*e.m12+o.Z*e.m22,v=(r*e.m00+t*e.m10+n*e.m20)*(d/l),p=(r*e.m01+t*e.m11+n*e.m21)*(b/h),m=(r*e.m02+t*e.m12+n*e.m22)*(g/s),y=v*a.m00+p*a.m10+m*a.m20,w=v*a.m01+p*a.m11+m*a.m21,k=v*a.m02+p*a.m12+m*a.m22;return[255*T(y*f.m00+w*f.m10+k*f.m20),255*T(y*f.m01+w*f.m11+k*f.m21),255*T(y*f.m02+w*f.m12+k*f.m22)]},J=Math.sin,Q=Math.cos,rr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=n[0],a=n[1],f=n[2];return isNaN(f)&&(f=0),[e,Q(f*=b)*a,J(f)*a]},tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=rr(n,e,a),o=f[0],c=f[1],i=f[2],l=V(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},nr=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,er=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,ar=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,fr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,or=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,ur=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,cr=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,ir=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,lr=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,hr=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,sr=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,dr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,br=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,gr=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,vr=Math.round,pr=function(t){return t.map((function(t,n){return n<=2?r(vr(t),0,255):t}))},mr=function(r,t,n,e){return void 0===t&&(t=0),void 0===n&&(n=100),void 0===e&&(e=!1),r.endsWith("%")&&(r=parseFloat(r.substr(0,r.length-1))/100,r=e?t+.5*(r+1)*(n-t):t+r*(n-t)),+r},yr=function(r,t){return"none"===r?t:r},wr=function(r){var t;if(r=r.toLowerCase().trim(),v.format.named)try{return v.format.named(r)}catch(r){}if((t=r.match(nr))||(t=r.match(er))){for(var n=t.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((t=r.match(ar))||(t=r.match(fr))){for(var a=t.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if((t=r.match(or))||(t=r.match(ur))){for(var o=t.slice(1,4),u=0;u<3;u++)o[u]=vr(2.55*o[u]);return o[3]=1,o}if((t=r.match(cr))||(t=r.match(ir))){for(var c=t.slice(1,5),i=0;i<3;i++)c[i]=vr(2.55*c[i]);return c[3]=+c[3],c}if((t=r.match(lr))||(t=r.match(hr))){var l=t.slice(1,4);l[1]*=.01,l[2]*=.01;for(var h=U(l),s=0;s<3;s++)h[s]=vr(h[s]);return h[3]=1,h}if((t=r.match(sr))||(t=r.match(dr))){var d=t.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=U(d),g=0;g<3;g++)b[g]=vr(b[g]);return b[3]=+t[4],b}if(t=r.match(br)){var p=t.slice(1,4);p[0]=mr(p[0],0,100),p[1]=mr(p[1],-125,125,!0),p[2]=mr(p[2],-125,125,!0);var m=pr(V(p));return m[3]=void 0!==t[4]?+t[4]:1,m}if(t=r.match(gr)){var y=t.slice(1,4);y[0]=mr(y[0],0,100),y[1]=mr(yr(y[1],0),0,150,!1),y[2]=+yr(y[2].replace("deg",""),0);var w=pr(tr(y));return w[3]=void 0!==t[4]?+t[4]:1,w}};wr.test=function(r){return nr.test(r)||ar.test(r)||or.test(r)||cr.test(r)||lr.test(r)||sr.test(r)||br.test(r)||er.test(r)||fr.test(r)||ur.test(r)||ir.test(r)||hr.test(r)||dr.test(r)},p.prototype.css=function(r){return z(this._rgb,r)};var kr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["css"])))};m.css=kr,v.format.css=wr,v.autodetect.push({p:5,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&wr.test(r))return"css"}}),v.format.gl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return n[0]*=255,n[1]*=255,n[2]*=255,n};var Mr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["gl"])))};m.gl=Mr,p.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var Nr=Math.floor;p.prototype.hcg=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=l(a,f,o),i=h(a,f,o),s=i-c,d=100*s/255,b=c/(255-s)*100;return 0===s?n=Number.NaN:(a===i&&(n=(f-o)/s),f===i&&(n=2+(o-a)/s),o===i&&(n=4+(a-f)/s),(n*=60)<0&&(n+=360)),[n,d,b]}(this._rgb)};var _r=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["hcg"])))};m.hcg=_r,v.format.hcg=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,s=(o=u(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)i=l=h=b;else{360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360);var v=Nr(s/=60),p=s-v,m=b*(1-d),y=m+g*(1-p),w=m+g*p,k=m+g;switch(v){case 0:i=(r=[k,w,m])[0],l=r[1],h=r[2];break;case 1:i=(t=[y,k,m])[0],l=t[1],h=t[2];break;case 2:i=(n=[m,k,w])[0],l=n[1],h=n[2];break;case 3:i=(e=[m,y,k])[0],l=e[1],h=e[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]},v.autodetect.push({p:1,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var xr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Ar=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,jr=function(r){if(r.match(xr)){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 t=parseInt(r,16);return[t>>16,t>>8&255,255&t,1]}if(r.match(Ar)){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 n=parseInt(r,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+r)},Er=Math.round,Or=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=n[0],a=n[1],f=n[2],o=n[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((e=Er(e))<<16|(a=Er(a))<<8|(f=Er(f))).toString(16);l=l.substr(l.length-6);var h="0"+Er(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}};p.prototype.hex=function(r){return Or(this._rgb,r)};var Fr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["hex"])))};m.hex=Fr,v.format.hex=jr,v.autodetect.push({p:4,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Lr=Math.cos,Pr=Math.min,Br=Math.sqrt,Gr=Math.acos;p.prototype.hsi=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=Pr(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?n=NaN:(n=(a-f+(a-o))/2,n/=Br((a-f)*(a-f)+(a-o)*(f-o)),n=Gr(n),o>f&&(n=s-n),n/=s),[360*n,l,i]}(this._rgb)};var Rr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["hsi"])))};m.hsi=Rr,v.format.hsi=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsi"))[0],c=t[1],i=t[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)+(e=(1+c*Lr(s*o)/Lr(d-s*o))/3)):o<2/3?f=1-((e=(1-c)/3)+(a=(1+c*Lr(s*(o-=1/3))/Lr(d-s*o))/3)):e=1-((a=(1-c)/3)+(f=(1+c*Lr(s*(o-=2/3))/Lr(d-s*o))/3)),[255*(e=r(i*e*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),t.length>3?t[3]:1]},v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),p.prototype.hsl=function(){return M(this._rgb)};var Yr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["hsl"])))};m.hsl=Yr,v.format.hsl=U,v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var qr=Math.floor,Xr=Math.min,$r=Math.max;p.prototype.hsv=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=Xr(f,o,c),l=$r(f,o,c),h=l-i;return a=l/255,0===l?(n=Number.NaN,e=0):(e=h/l,f===l&&(n=(o-c)/h),o===l&&(n=2+(c-f)/h),c===l&&(n=4+(f-o)/h),(n*=60)<0&&(n+=360)),[n,e,a]}(this._rgb)};var Cr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["hsv"])))};m.hsv=Cr,v.format.hsv=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,h,s=(o=u(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)i=l=h=b;else{360===s&&(s=0),s>360&&(s-=360),s<0&&(s+=360);var g=qr(s/=60),v=s-g,p=b*(1-d),m=b*(1-d*v),y=b*(1-d*(1-v));switch(g){case 0:i=(r=[b,y,p])[0],l=r[1],h=r[2];break;case 1:i=(t=[m,b,p])[0],l=t[1],h=t[2];break;case 2:i=(n=[p,b,y])[0],l=n[1],h=n[2];break;case 3:i=(e=[p,m,b])[0],l=e[1],h=e[2];break;case 4:i=(a=[y,p,b])[0],l=a[1],h=a[2];break;case 5:i=(f=[b,p,m])[0],l=f[1],h=f[2]}}return[i,l,h,o.length>3?o[3]:1]},v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}}),p.prototype.lab=function(){return E(this._rgb)};var Zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["lab"])))};Object.assign(m,{lab:Zr,getLabWhitePoint:j,setLabWhitePoint:A}),v.format.lab=V,v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});p.prototype.lch=function(){return Y(this._rgb)},p.prototype.hcl=function(){return Y(this._rgb).reverse()};var Sr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["lch"])))},Wr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["hcl"])))};Object.assign(m,{lch:Sr,hcl:Wr}),v.format.lch=tr,v.format.hcl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hcl").reverse();return tr.apply(void 0,n)},["lch","hcl"].forEach((function(r){return v.autodetect.push({p:2,test:function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];if("array"===o(t=u(t,r))&&3===t.length)return r}})}));p.prototype.num=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb");return(n[0]<<16)+(n[1]<<8)+n[2]}(this._rgb)};var Ir=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["num"])))};Object.assign(m,{num:Ir}),v.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)},v.autodetect.push({p:5,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var Kr=Math.round;p.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Kr)},p.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(t,n){return n<3?!1===r?t:Kr(t):t}))};var zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["rgb"])))};Object.assign(m,{rgb:zr}),v.format.rgb=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return void 0===n[3]&&(n[3]=1),n},v.autodetect.push({p:3,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];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 Ur=Math.log,Vr=function(r){var t,n,e,a=r/100;return a<66?(t=255,n=a<6?0:-155.25485562709179-.44596950469579133*(n=a-2)+104.49216199393888*Ur(n),e=a<20?0:.8274096064007395*(e=a-10)-254.76935184120902+115.67994401066147*Ur(e)):(t=351.97690566805693+.114206453784165*(t=a-55)-40.25366309332127*Ur(t),n=325.4494125711974+.07943456536662342*(n=a-50)-28.0852963507957*Ur(n),e=255),[t,n,e,1]},Dr=Math.round;p.prototype.temp=p.prototype.kelvin=p.prototype.temperature=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];for(var n,e=u(r,"rgb"),a=e[0],f=e[2],o=1e3,c=4e4;c-o>.4;){var i=Vr(n=.5*(c+o));i[2]/i[0]>=f/a?c=n:o=n}return Dr(n)}(this._rgb)};var Tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["temp"])))};Object.assign(m,{temp:Tr,kelvin:Tr,temperature:Tr}),v.format.temp=v.format.kelvin=v.format.temperature=Vr;var Hr=Math.pow,Jr=Math.sign,Qr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lab"))[0],e=r[1],a=r[2],f=Hr(n+.3963377774*e+.2158037573*a,3),o=Hr(n-.1055613458*e-.0638541728*a,3),c=Hr(n-.0894841775*e-1.291485548*a,3);return[255*rt(4.0767416621*f-3.3077115913*o+.2309699292*c),255*rt(-1.2684380046*f+2.6097574011*o-.3413193965*c),255*rt(-.0041960863*f-.7034186147*o+1.707614701*c),r.length>3?r[3]:1]};function rt(r){var t=Math.abs(r);return t>.0031308?(Jr(r)||1)*(1.055*Hr(t,1/2.4)-.055):12.92*r}p.prototype.oklab=function(){return C(this._rgb)};var tt=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["oklab"])))};Object.assign(m,{oklab:tt}),v.format.oklab=Qr,v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}});p.prototype.oklch=function(){return W(this._rgb)};var nt=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(p,[null].concat(r,["oklch"])))};Object.assign(m,{oklch:nt}),v.format.oklch=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=rr(n,e,a),o=f[0],c=f[1],i=f[2],l=Qr(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},v.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}});var et={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"};p.prototype.name=function(){for(var r=Or(this._rgb,"rgb"),t=0,n=Object.keys(et);t0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&et[r.toLowerCase()])return"named"}}),p.prototype.alpha=function(r,t){return void 0===t&&(t=!1),void 0!==r&&"number"===o(r)?t?(this._rgb[3]=r,this):new p([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},p.prototype.clipped=function(){return this._rgb._clipped||!1},p.prototype.darken=function(r){void 0===r&&(r=1);var t=this.lab();return t[0]-=_.Kn*r,new p(t,"lab").alpha(this.alpha(),!0)},p.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},p.prototype.darker=p.prototype.darken,p.prototype.brighter=p.prototype.brighten,p.prototype.get=function(r){var t=r.split("."),n=t[0],e=t[1],a=this[n]();if(e){var f=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+e+" in mode "+n)}return a};var at=Math.pow;p.prototype.luminance=function(r,t){if(void 0===t&&(t="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new p([0,0,0,this._rgb[3]],"rgb");if(1===r)return new p([255,255,255,this._rgb[3]],"rgb");var n=this.luminance(),e=20,a=function(n,f){var o=n.interpolate(f,.5,t),u=o.luminance();return Math.abs(r-u)<1e-7||!e--?o:u>r?a(n,o):a(o,f)},f=(n>r?a(new p([0,0,0]),this):a(this,new p([255,255,255]))).rgb();return new p(f.concat([this._rgb[3]]))}return ft.apply(void 0,this._rgb.slice(0,3))};var ft=function(r,t,n){return.2126*(r=ot(r))+.7152*(t=ot(t))+.0722*(n=ot(n))},ot=function(r){return(r/=255)<=.03928?r/12.92:at((r+.055)/1.055,2.4)},ut={};function ct(r,t,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var f=e[0]||"lrgb";if(ut[f]||e.length||(f=Object.keys(ut)[0]),!ut[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new p(r)),"object"!==o(t)&&(t=new p(t)),ut[f](r,t,n).alpha(r.alpha()+n*(t.alpha()-r.alpha()))}p.prototype.mix=p.prototype.interpolate=function(r,t){void 0===t&&(t=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return ct.apply(void 0,[this,r,t].concat(n))},p.prototype.premultiply=function(r){void 0===r&&(r=!1);var t=this._rgb,n=t[3];return r?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new p([t[0]*n,t[1]*n,t[2]*n,n],"rgb")},p.prototype.saturate=function(r){void 0===r&&(r=1);var t=this.lch();return t[1]+=_.Kn*r,t[1]<0&&(t[1]=0),new p(t,"lch").alpha(this.alpha(),!0)},p.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},p.prototype.set=function(r,t,n){void 0===n&&(n=!1);var e=r.split("."),a=e[0],f=e[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(t))switch(t.charAt(0)){case"+":case"-":u[c]+=+t;break;case"*":u[c]*=+t.substr(1);break;case"/":u[c]/=+t.substr(1);break;default:u[c]=+t}else{if("number"!==o(t))throw new Error("unsupported value for Color.set");u[c]=t}var i=new p(u,a);return n?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},p.prototype.tint=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return ct.apply(void 0,[this,"white",r].concat(t))},p.prototype.shade=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return ct.apply(void 0,[this,"black",r].concat(t))};ut.rgb=function(r,t,n){var e=r._rgb,a=t._rgb;return new p(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"rgb")};var it=Math.sqrt,lt=Math.pow;ut.lrgb=function(r,t,n){var e=r._rgb,a=e[0],f=e[1],o=e[2],u=t._rgb,c=u[0],i=u[1],l=u[2];return new p(it(lt(a,2)*(1-n)+lt(c,2)*n),it(lt(f,2)*(1-n)+lt(i,2)*n),it(lt(o,2)*(1-n)+lt(l,2)*n),"rgb")};function ht(r,t,n,e){var a,f,o,u,c,i,l,h,s,d,b,g,v;return"hsl"===e?(o=r.hsl(),u=t.hsl()):"hsv"===e?(o=r.hsv(),u=t.hsv()):"hcg"===e?(o=r.hcg(),u=t.hcg()):"hsi"===e?(o=r.hsi(),u=t.hsi()):"lch"===e||"hcl"===e?(e="hcl",o=r.hcl(),u=t.hcl()):"oklch"===e&&(o=r.oklch().reverse(),u=t.oklch().reverse()),"h"!==e.substr(0,1)&&"oklch"!==e||(c=(a=o)[0],l=a[1],s=a[2],i=(f=u)[0],h=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=s&&0!=s||"hsv"==e||(b=h)):(g=c,1!=d&&0!=d||"hsv"==e||(b=l)):g=c+n*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+n*(h-l)),v=s+n*(d-s),new p("oklch"===e?[v,b,g]:[g,b,v],e)}ut.lab=function(r,t,n){var e=r.lab(),a=t.lab();return new p(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"lab")};var st=function(r,t,n){return ht(r,t,n,"lch")};ut.lch=st,ut.hcl=st;ut.num=function(r,t,n){var e=r.num(),a=t.num();return new p(e+n*(a-e),"num")};ut.hcg=function(r,t,n){return ht(r,t,n,"hcg")};ut.hsi=function(r,t,n){return ht(r,t,n,"hsi")};ut.hsl=function(r,t,n){return ht(r,t,n,"hsl")};ut.hsv=function(r,t,n){return ht(r,t,n,"hsv")};ut.oklab=function(r,t,n){var e=r.oklab(),a=t.oklab();return new p(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")};ut.oklch=function(r,t,n){return ht(r,t,n,"oklch")};var dt=Math.pow,bt=Math.sqrt,gt=Math.PI,vt=Math.cos,pt=Math.sin,mt=Math.atan2;var yt=function(r,n){for(var e=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new p(t(a))},wt=Math.pow;function kt(t){var n="rgb",e=m("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],h=!1,s=0,d=1,b=!1,g={},v=!0,p=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 t=0;t2){var b=function(r){if(null!=i){for(var t=i.length-1,n=0;n=i[n];)n++;return n-1}return 0}(t);h=b/(i.length-2)}else h=d!==s?(t-s)/(d-s):1;h=k(h),a||(h=w(h)),1!==p&&(h=wt(h,p)),h=r(h=c[0]+h*(1-c[0]-c[1]),0,1);var y=Math.floor(1e4*h);if(v&&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(t,n){return n/(r.length-1)})),i=r.map((function(r){return(r-s)/(d-s)}));i.every((function(r,t){return c[t]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var t=0;r>=i[t+1];)t++;var n=(r-i[t])/(i[t+1]-i[t]);return c[t]+n*(c[t+1]-c[t])})}}return f=[s,d],_},_.mode=function(r){return arguments.length?(n=r,N(),_):n},_.range=function(r,t){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 t=M(0,!0).lab()[0],n=M(1,!0).lab()[0],e=t>n,a=M(r,!0).lab()[0],f=t+(n-t)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)e&&(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,n){arguments.length<2&&(n="hex");var e=[];if(0===arguments.length)e=l.slice(0);else if(1===r)e=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;e=function(r,t){for(var n=[],e=ra;e?f++:f--)n.push(f);return n}(0,r).map((function(t){return _(a+t/(r-1)*o)}))}else{t=[];var u=[];if(i&&i.length>2)for(var c=1,h=i.length,s=1<=h;s?ch;s?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;e=u.map((function(r){return _(r)}))}return m[n]&&(e=e.map((function(r){return r[n]()}))),e},_.cache=function(r){return null!=r?(v=r,_):v},_.gamma=function(r){return null!=r?(p=r,_):p},_.nodata=function(r){return null!=r?(e=m(r),_):e},_}var Mt=function(r,t,n){if(!Mt[n])throw new Error("unknown blend mode "+n);return Mt[n](r,t)},Nt=function(r){return function(t,n){var e=m(n).rgb(),a=m(t).rgb();return m.rgb(r(e,a))}},_t=function(r){return function(t,n){var e=[];return e[0]=r(t[0],n[0]),e[1]=r(t[1],n[1]),e[2]=r(t[2],n[2]),e}};Mt.normal=Nt(_t((function(r){return r}))),Mt.multiply=Nt(_t((function(r,t){return r*t/255}))),Mt.screen=Nt(_t((function(r,t){return 255*(1-(1-r/255)*(1-t/255))}))),Mt.overlay=Nt(_t((function(r,t){return t<128?2*r*t/255:255*(1-2*(1-r/255)*(1-t/255))}))),Mt.darken=Nt(_t((function(r,t){return r>t?t:r}))),Mt.lighten=Nt(_t((function(r,t){return r>t?r:t}))),Mt.dodge=Nt(_t((function(r,t){return 255===r||(r=t/255*255/(1-r/255))>255?255:r}))),Mt.burn=Nt(_t((function(r,t){return 255*(1-(1-t/255)/(r/255))})));var xt=Math.pow,At=Math.sin,jt=Math.cos;var Et=Math.floor,Ot=Math.random;var Ft=Math.log,Lt=Math.pow,Pt=Math.floor,Bt=Math.abs;function Gt(r,t){void 0===t&&(t=null);var n={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){t&&"object"===o(r)&&(r=r[t]),null==r||isNaN(r)||(n.values.push(r),n.sum+=r,rn.max&&(n.max=r),n.count+=1)})),n.domain=[n.min,n.max],n.limits=function(r,t){return Rt(n,r,t)},n}function Rt(r,t,n){void 0===t&&(t="equal"),void 0===n&&(n=7),"array"==o(r)&&(r=Gt(r));var e=r.min,a=r.max,f=r.values.sort((function(r,t){return r-t}));if(1===n)return[e,a];var u=[];if("c"===t.substr(0,1)&&(u.push(e),u.push(a)),"e"===t.substr(0,1)){u.push(e);for(var c=1;c 0");var i=Math.LOG10E*Ft(e),l=Math.LOG10E*Ft(a);u.push(e);for(var h=1;h200&&(w=!1)}for(var Y={},q=0;q=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return s/=e,new p(o,t).alpha(s>.99999?1:s,!0)},bezier:function(r){var t=function(r){var t,n,e,a,f,o,u;if(2===(r=r.map((function(r){return new p(r)}))).length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],a=function(r){var t=[0,1,2].map((function(t){return f[t]+r*(o[t]-f[t])}));return new p(t,"lab")};else if(3===r.length)n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*f[t]+2*(1-r)*r*o[t]+r*r*u[t]}));return new p(t,"lab")};else if(4===r.length){var c;e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],u=e[2],c=e[3],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*(1-r)*f[t]+3*(1-r)*(1-r)*r*o[t]+3*(1-r)*r*r*u[t]+r*r*r*c[t]}));return new p(t,"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 t=[1,1],n=1;ne?(n+.05)/(e+.05):(e+.05)/(n+.05)},cubehelix:function(r,n,e,a,f){void 0===r&&(r=300),void 0===n&&(n=-1.5),void 0===e&&(e=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var u,c=0;"array"===o(f)?u=f[1]-f[0]:(u=0,f=[f,f]);var i=function(o){var i=s*((r+120)/360+n*o),l=xt(f[0]+u*o,a),h=(0!==c?e[0]+o*c:e)*l*(1-l)/2,d=jt(i),b=At(i);return m(t([255*(l+h*(-.14861*d+1.78277*b)),255*(l+h*(-.29227*d-.90649*b)),255*(l+h*(1.97294*d)),1]))};return i.start=function(t){return null==t?r:(r=t,i)},i.rotations=function(r){return null==r?n:(n=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?e:("array"===o(e=r)?0===(c=e[1]-e[0])&&(e=e[1]):c=0,i)},i.lightness=function(r){return null==r?f:("array"===o(r)?(f=r,u=r[1]-r[0]):(f=[r,r],u=0),i)},i.scale=function(){return m.scale(i)},i.hue(e),i},deltaE:function(r,t,n,e,a){void 0===n&&(n=1),void 0===e&&(e=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*Kt)},o=function(r){return 2*Kt*r/360};r=new p(r),t=new p(t);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],h=Array.from(t.lab()),s=h[0],d=h[1],b=h[2],g=(c+s)/2,v=(Yt(qt(i,2)+qt(l,2))+Yt(qt(d,2)+qt(b,2)))/2,m=.5*(1-Yt(qt(v,7)/(qt(v,7)+qt(25,7)))),y=i*(1+m),w=d*(1+m),k=Yt(qt(y,2)+qt(l,2)),M=Yt(qt(w,2)+qt(b,2)),N=(k+M)/2,_=f(Ct(l,y)),x=f(Ct(b,w)),A=_>=0?_:_+360,j=x>=0?x:x+360,E=Zt(A-j)>180?(A+j+360)/2:(A+j)/2,O=1-.17*St(o(E-30))+.24*St(o(2*E))+.32*St(o(3*E+6))-.2*St(o(4*E-63)),F=j-A;F=Zt(F)<=180?F:j<=A?F+360:F-360,F=2*Yt(k*M)*Wt(o(F)/2);var L=s-c,P=M-k,B=1+.015*qt(g-50,2)/Yt(20+qt(g-50,2)),G=1+.045*N,R=1+.015*N*O,Y=30*It(-qt((E-275)/25,2)),q=-(2*Yt(qt(N,7)/(qt(N,7)+qt(25,7))))*Wt(2*o(Y)),X=Yt(qt(L/(n*B),2)+qt(P/(e*G),2)+qt(F/(a*R),2)+q*(P/(e*G))*(F/(a*R)));return $t(0,Xt(100,X))},distance:function(r,t,n){void 0===n&&(n="lab"),r=new p(r),t=new p(t);var e=r.get(n),a=t.get(n),f=0;for(var o in e){var u=(e[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},input:v,interpolate:ct,limits:Rt,mix:ct,random:function(){for(var r="#",t=0;t<6;t++)r+="0123456789abcdef".charAt(Et(16*Ot()));return new p(r,"hex")},scale:kt,scales:zt,valid:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];try{return new(Function.prototype.bind.apply(p,[null].concat(r))),!0}catch(r){return!1}},cmyk:w,css:kr,gl:Mr,hcg:_r,hex:Fr,hsi:Rr,hsl:Yr,hsv:Cr,lab:Zr,lch:Sr,hcl:Wr,num:Ir,rgb:zr,temp:Tr,kelvin:Tr,temperature:Tr,oklab:tt,oklch:nt,getLabWhitePoint:j,setLabWhitePoint:A}),m})); +!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(r="undefined"!=typeof globalThis?globalThis:r||self).chroma=t()}(this,(function(){"use strict";function r(r,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),l(s(t,r),n)}function t(t){t._clipped=!1,t._unclipped=t.slice(0);for(var n=0;n<=3;n++)n<3?((t[n]<0||t[n]>255)&&(t._clipped=!0),t[n]=r(t[n],0,255)):3===n&&(t[n]=r(t[n],0,1));return t}for(var n={},e=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];e=3?Array.prototype.slice.call(r):"object"==o(r[0])&&t?t.split("").filter((function(t){return void 0!==r[0][t]})).map((function(t){return r[0][t]})):r[0].slice(0)}function c(r){if(r.length<2)return null;var t=r.length-1;return"string"==o(r[t])?r[t].toLowerCase():null}var i=Math.PI,l=Math.min,s=Math.max,h=function(r){return Math.round(100*r)/100},d=function(r){return Math.round(100*r)/100},b=2*i,g=i/3,v=i/180,p=180/i,m={format:{},autodetect:[]},y=function(){for(var r=[],n=arguments.length;n--;)r[n]=arguments[n];var e=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,m.sorted||(m.autodetect=m.autodetect.sort((function(r,t){return t.p-r.p})),m.sorted=!0);for(var u=0,i=m.autodetect;u4?r[4]:1;return 1===f?[0,0,0,o]:[n>=1?0:255*(1-n)*(1-f),e>=1?0:255*(1-e)*(1-f),a>=1?0:255*(1-a)*(1-f),o]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"cmyk"))&&4===r.length)return"cmyk"}});var N=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=(r=u(r,"rgba"))[0],f=r[1],o=r[2],c=l(a/=255,f/=255,o/=255),i=s(a,f,o),h=(i+c)/2;return i===c?(n=0,e=Number.NaN):n=h<.5?(i-c)/(i+c):(i-c)/(2-i-c),a==i?e=(f-o)/(i-c):f==i?e=2+(o-a)/(i-c):o==i&&(e=4+(a-f)/(i-c)),(e*=60)<0&&(e+=360),r.length>3&&void 0!==r[3]?[e,n,h,r[3]]:[e,n,h]},_={Kn:18,labWhitePoint:"d65",Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},x=new Map([["a",[1.0985,.35585]],["b",[1.0985,.35585]],["c",[.98074,1.18232]],["d50",[.96422,.82521]],["d55",[.95682,.92149]],["d65",[.95047,1.08883]],["e",[1,1,1]],["f2",[.99186,.67393]],["f7",[.95041,1.08747]],["f11",[1.00962,.6435]],["icc",[.96422,.82521]]]);function A(r){var t=x.get(String(r).toLowerCase());if(!t)throw new Error("unknown Lab illuminant "+r);_.labWhitePoint=r,_.Xn=t[0],_.Zn=t[1]}function j(){return _.labWhitePoint}var E=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=F(e,a,f),i=function(r,t,n){var e=_.Xn,a=_.Yn,f=_.Zn,o=_.kE,u=_.kK,c=r/e,i=t/a,l=n/f,s=c>o?Math.pow(c,1/3):(u*c+16)/116,h=i>o?Math.pow(i,1/3):(u*i+16)/116,d=l>o?Math.pow(l,1/3):(u*l+16)/116;return[116*h-16,500*(s-h),200*(h-d)]}(c[0],c[1],c[2]);return[i[0],i[1],i[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function O(r){var t=Math.sign(r);return((r=Math.abs(r))<=.04045?r/12.92:Math.pow((r+.055)/1.055,2.4))*t}var F=function(r,t,n){r=O(r/255),t=O(t/255),n=O(n/255);var e=_.MtxRGB2XYZ,a=_.MtxAdaptMa,f=_.MtxAdaptMaI,o=_.Xn,u=_.Yn,c=_.Zn,i=_.As,l=_.Bs,s=_.Cs,h=r*e.m00+t*e.m10+n*e.m20,d=r*e.m01+t*e.m11+n*e.m21,b=r*e.m02+t*e.m12+n*e.m22,g=o*a.m00+u*a.m10+c*a.m20,v=o*a.m01+u*a.m11+c*a.m21,p=o*a.m02+u*a.m12+c*a.m22,m=h*a.m00+d*a.m10+b*a.m20,y=h*a.m01+d*a.m11+b*a.m21,w=h*a.m02+d*a.m12+b*a.m22;return y*=v/l,w*=p/s,[h=(m*=g/i)*f.m00+y*f.m10+w*f.m20,d=m*f.m01+y*f.m11+w*f.m21,b=m*f.m02+y*f.m12+w*f.m22]},L=Math.sqrt,P=Math.atan2,B=Math.round,G=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=n[0],a=n[1],f=n[2],o=L(a*a+f*f),c=(P(f,a)*p+360)%360;return 0===B(1e4*o)&&(c=Number.NaN),[e,o,c]},R=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=E(e,a,f),i=c[0],l=c[1],s=c[2],h=G(i,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])};function Y(r,t){var n=r.length;Array.isArray(r[0])||(r=[r]),Array.isArray(t[0])||(t=t.map((function(r){return[r]})));var e=t[0].length,a=t[0].map((function(r,n){return t.map((function(r){return r[n]}))})),f=r.map((function(r){return a.map((function(t){return Array.isArray(r)?r.reduce((function(r,n,e){return r+n*(t[e]||0)}),0):t.reduce((function(t,n){return t+n*r}),0)}))}));return 1===n&&(f=f[0]),1===e?f.map((function(r){return r[0]})):f}var $=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=u(r,"rgb"),f=a[0],o=a[1],c=a[2],i=a.slice(3),l=F(f,o,c);return(n=[[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],e=Y([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],l),Y(n,e.map((function(r){return Math.cbrt(r)})))).concat(i.length>0&&i[0]<1?[i[0]]:[])};var q=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb"),e=n[0],a=n[1],f=n[2],o=n.slice(3),c=$(e,a,f),i=c[0],l=c[1],s=c[2],h=G(i,l,s);return[h[0],h[1],h[2]].concat(o.length>0&&o[0]<1?[o[0]]:[])},X=Math.round,C=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=c(r)||"rgb";if("hsl"===e.substr(0,3))return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hsla"),e=c(r)||"lsa";return n[0]=h(n[0]||0)+"deg",n[1]=h(100*n[1])+"%",n[2]=h(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.substr(0,3)+"("+n.join(" ")+")"}(N(n),e);if("lab"===e.substr(0,3)){var a=j();A("d50");var f=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab"),e=c(r)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2]),"laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"}(E(n),e);return A(a),f}if("lch"===e.substr(0,3)){var o=j();A("d50");var i=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=c(r)||"lab";return n[0]=h(n[0])+"%",n[1]=h(n[1]),n[2]=h(n[2])+"deg","lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"}(R(n),e);return A(o),i}return"oklab"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=h(100*n[0])+"%",n[1]=d(n[1]),n[2]=d(n[2]),n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"}($(n)):"oklch"===e.substr(0,5)?function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lab");return n[0]=h(100*n[0])+"%",n[1]=d(n[1]),n[2]=h(n[2])+"deg",n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"}(q(n)):(n[0]=X(n[0]),n[1]=X(n[1]),n[2]=X(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]="/ "+(n.length>3?n[3]:1),e="rgba"),e.substr(0,3)+"("+n.slice(0,"rgb"===e?3:4).join(" ")+")")},Z=function(){for(var r,t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsl"))[0],c=t[1],i=t[2];if(0===c)e=a=f=255*i;else{var l=[0,0,0],s=[0,0,0],h=i<.5?i*(1+c):i+c-i*c,d=2*i-h,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?s[g]=d+6*(h-d)*l[g]:2*l[g]<1?s[g]=h:3*l[g]<2?s[g]=d+(h-d)*(2/3-l[g])*6:s[g]=d;e=(r=[255*s[0],255*s[1],255*s[2]])[0],a=r[1],f=r[2]}return t.length>3?[e,a,f,t[3]]:[e,a,f,1]},S=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lab"))[0],e=r[1],a=r[2],f=W(n,e,a),o=f[0],c=f[1],i=f[2],l=K(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},W=function(r,t,n){var e=_.kE,a=_.kK,f=_.kKE,o=_.Xn,u=_.Yn,c=_.Zn,i=(r+16)/116,l=.002*t+i,s=i-.005*n,h=l*l*l,d=s*s*s;return[(h>e?h:(116*l-16)/a)*o,(r>f?Math.pow((r+16)/116,3):r/a)*u,(d>e?d:(116*s-16)/a)*c]},I=function(r){var t=Math.sign(r);return((r=Math.abs(r))<=.0031308?12.92*r:1.055*Math.pow(r,1/2.4)-.055)*t},K=function(r,t,n){var e=_.MtxAdaptMa,a=_.MtxAdaptMaI,f=_.MtxXYZ2RGB,o=_.RefWhiteRGB,u=_.Xn,c=_.Yn,i=_.Zn,l=u*e.m00+c*e.m10+i*e.m20,s=u*e.m01+c*e.m11+i*e.m21,h=u*e.m02+c*e.m12+i*e.m22,d=o.X*e.m00+o.Y*e.m10+o.Z*e.m20,b=o.X*e.m01+o.Y*e.m11+o.Z*e.m21,g=o.X*e.m02+o.Y*e.m12+o.Z*e.m22,v=(r*e.m00+t*e.m10+n*e.m20)*(d/l),p=(r*e.m01+t*e.m11+n*e.m21)*(b/s),m=(r*e.m02+t*e.m12+n*e.m22)*(g/h),y=v*a.m00+p*a.m10+m*a.m20,w=v*a.m01+p*a.m11+m*a.m21,k=v*a.m02+p*a.m12+m*a.m22;return[255*I(y*f.m00+w*f.m10+k*f.m20),255*I(y*f.m01+w*f.m11+k*f.m21),255*I(y*f.m02+w*f.m12+k*f.m22)]},z=Math.sin,U=Math.cos,V=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"lch"),e=n[0],a=n[1],f=n[2];return isNaN(f)&&(f=0),[e,U(f*=v)*a,z(f)*a]},D=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=V(n,e,a),o=f[0],c=f[1],i=f[2],l=S(o,c,i);return[l[0],l[1],l[2],r.length>3?r[3]:1]},T=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a=(r=u(r,"lab"))[0],f=r[1],o=r[2],c=r.slice(3),i=(n=[[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],e=Y([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],[a,f,o]),Y(n,e.map((function(r){return Math.pow(r,3)})))),l=i[0],s=i[1],h=i[2],d=K(l,s,h);return[d[0],d[1],d[2]].concat(c.length>0&&c[0]<1?[c[0]]:[])};var H=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=(r=u(r,"lch"))[0],e=r[1],a=r[2],f=r.slice(3),o=V(n,e,a),c=o[0],i=o[1],l=o[2],s=T(c,i,l);return[s[0],s[1],s[2]].concat(f.length>0&&f[0]<1?[f[0]]:[])},J=/^rgb\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\)$/,Q=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,rr=/^rgba?\(\s*(-?\d+) \s*(-?\d+)\s* \s*(-?\d+)\s*\/\s*([01]|[01]?\.\d+)\)$/,tr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,nr=/^rgb\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,er=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,ar=/^rgba?\(\s*(-?\d+(?:\.\d+)?)% \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,fr=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,or=/^hsl\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\)$/,ur=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,cr=/^hsla?\(\s*(-?\d+(?:\.\d+)?)deg \s*(-?\d+(?:\.\d+)?)%\s* \s*(-?\d+(?:\.\d+)?)%\s*\/\s*([01]|[01]?\.\d+)\)$/,ir=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,lr=/^lab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,sr=/^lch\(\s*(-?\d+(?:\.\d+)?%?) \s*((?:-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,hr=/^oklab\(\s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?) \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,dr=/^oklch\(\s*(-?\d+(?:\.\d+)?%?) \s*(?:(-?\d+(?:\.\d+)?%?)|none) \s*(-?\d+(?:\.\d+)?(?:deg)?|none)\s*(?:\/\s*(\d+(?:\.\d+)?))?\)?$/,br=Math.round,gr=function(t){return t.map((function(t,n){return n<=2?r(br(t),0,255):t}))},vr=function(r,t,n,e){return void 0===t&&(t=0),void 0===n&&(n=100),void 0===e&&(e=!1),"string"==typeof r&&r.endsWith("%")&&(r=parseFloat(r.substring(0,r.length-1))/100,r=e?t+.5*(r+1)*(n-t):t+r*(n-t)),+r},pr=function(r,t){return"none"===r?t:r},mr=function(r){var t;if(r=r.toLowerCase().trim(),m.format.named)try{return m.format.named(r)}catch(r){}if((t=r.match(J))||(t=r.match(Q))){for(var n=t.slice(1,4),e=0;e<3;e++)n[e]=+n[e];return n[3]=1,n}if((t=r.match(rr))||(t=r.match(tr))){for(var a=t.slice(1,5),f=0;f<4;f++)a[f]=+a[f];return a}if((t=r.match(nr))||(t=r.match(er))){for(var o=t.slice(1,4),u=0;u<3;u++)o[u]=br(2.55*o[u]);return o[3]=1,o}if((t=r.match(ar))||(t=r.match(fr))){for(var c=t.slice(1,5),i=0;i<3;i++)c[i]=br(2.55*c[i]);return c[3]=+c[3],c}if((t=r.match(or))||(t=r.match(ur))){var l=t.slice(1,4);l[1]*=.01,l[2]*=.01;for(var s=Z(l),h=0;h<3;h++)s[h]=br(s[h]);return s[3]=1,s}if((t=r.match(cr))||(t=r.match(ir))){var d=t.slice(1,4);d[1]*=.01,d[2]*=.01;for(var b=Z(d),g=0;g<3;g++)b[g]=br(b[g]);return b[3]=+t[4],b}if(t=r.match(lr)){var v=t.slice(1,4);v[0]=vr(v[0],0,100),v[1]=vr(v[1],-125,125,!0),v[2]=vr(v[2],-125,125,!0);var p=j();A("d50");var y=gr(S(v));return A(p),y[3]=void 0!==t[4]?+t[4]:1,y}if(t=r.match(sr)){var w=t.slice(1,4);w[0]=vr(w[0],0,100),w[1]=vr(pr(w[1],0),0,150,!1),w[2]=+pr(w[2].replace("deg",""),0);var k=j();A("d50");var M=gr(D(w));return A(k),M[3]=void 0!==t[4]?+t[4]:1,M}if(t=r.match(hr)){var N=t.slice(1,4);N[0]=vr(N[0],0,1),N[1]=vr(N[1],-.4,.4,!0),N[2]=vr(N[2],-.4,.4,!0);var _=gr(T(N));return _[3]=void 0!==t[4]?+t[4]:1,_}if(t=r.match(dr)){var x=t.slice(1,4);x[0]=vr(x[0],0,1),x[1]=vr(pr(x[1],0),0,.4,!1),x[2]=+pr(x[2].replace("deg",""),0);var E=gr(H(x));return E[3]=void 0!==t[4]?+t[4]:1,E}};mr.test=function(r){return J.test(r)||rr.test(r)||nr.test(r)||ar.test(r)||or.test(r)||cr.test(r)||lr.test(r)||sr.test(r)||hr.test(r)||dr.test(r)||Q.test(r)||tr.test(r)||er.test(r)||fr.test(r)||ur.test(r)||ir.test(r)},y.prototype.css=function(r){return C(this._rgb,r)};var yr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["css"])))};w.css=yr,m.format.css=mr,m.autodetect.push({p:5,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&mr.test(r))return"css"}}),m.format.gl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return n[0]*=255,n[1]*=255,n[2]*=255,n};var wr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["gl"])))};w.gl=wr,y.prototype.gl=function(){var r=this._rgb;return[r[0]/255,r[1]/255,r[2]/255,r[3]]};var kr=Math.floor;y.prototype.hcg=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=l(a,f,o),i=s(a,f,o),h=i-c,d=100*h/255,b=c/(255-h)*100;return 0===h?n=Number.NaN:(a===i&&(n=(f-o)/h),f===i&&(n=2+(o-a)/h),o===i&&(n=4+(a-f)/h),(n*=60)<0&&(n+=360)),[n,d,b]}(this._rgb)};var Mr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hcg"])))};w.hcg=Mr,m.format.hcg=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,s,h=(o=u(o,"hcg"))[0],d=o[1],b=o[2];b*=255;var g=255*d;if(0===d)i=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var v=kr(h/=60),p=h-v,m=b*(1-d),y=m+g*(1-p),w=m+g*p,k=m+g;switch(v){case 0:i=(r=[k,w,m])[0],l=r[1],s=r[2];break;case 1:i=(t=[y,k,m])[0],l=t[1],s=t[2];break;case 2:i=(n=[m,k,w])[0],l=n[1],s=n[2];break;case 3:i=(e=[m,y,k])[0],l=e[1],s=e[2];break;case 4:i=(a=[w,m,k])[0],l=a[1],s=a[2];break;case 5:i=(f=[k,m,y])[0],l=f[1],s=f[2]}}return[i,l,s,o.length>3?o[3]:1]},m.autodetect.push({p:1,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hcg"))&&3===r.length)return"hcg"}});var Nr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,_r=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,xr=function(r){if(r.match(Nr)){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 t=parseInt(r,16);return[t>>16,t>>8&255,255&t,1]}if(r.match(_r)){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 n=parseInt(r,16);return[n>>24&255,n>>16&255,n>>8&255,Math.round((255&n)/255*100)/100]}throw new Error("unknown hex color: "+r)},Ar=Math.round,jr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba"),e=n[0],a=n[1],f=n[2],o=n[3],i=c(r)||"auto";void 0===o&&(o=1),"auto"===i&&(i=o<1?"rgba":"rgb");var l="000000"+((e=Ar(e))<<16|(a=Ar(a))<<8|(f=Ar(f))).toString(16);l=l.substr(l.length-6);var s="0"+Ar(255*o).toString(16);switch(s=s.substr(s.length-2),i.toLowerCase()){case"rgba":return"#"+l+s;case"argb":return"#"+s+l;default:return"#"+l}};y.prototype.hex=function(r){return jr(this._rgb,r)};var Er=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hex"])))};w.hex=Er,m.format.hex=xr,m.autodetect.push({p:4,test:function(r){for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&[3,4,5,6,7,8,9].indexOf(r.length)>=0)return"hex"}});var Or=Math.cos,Fr=Math.min,Lr=Math.sqrt,Pr=Math.acos;y.prototype.hsi=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e=u(r,"rgb"),a=e[0],f=e[1],o=e[2],c=Fr(a/=255,f/=255,o/=255),i=(a+f+o)/3,l=i>0?1-c/i:0;return 0===l?n=NaN:(n=(a-f+(a-o))/2,n/=Lr((a-f)*(a-f)+(a-o)*(f-o)),n=Pr(n),o>f&&(n=b-n),n/=b),[360*n,l,i]}(this._rgb)};var Br=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsi"])))};w.hsi=Br,m.format.hsi=function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];var e,a,f,o=(t=u(t,"hsi"))[0],c=t[1],i=t[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)+(e=(1+c*Or(b*o)/Or(g-b*o))/3)):o<2/3?f=1-((e=(1-c)/3)+(a=(1+c*Or(b*(o-=1/3))/Or(g-b*o))/3)):e=1-((a=(1-c)/3)+(f=(1+c*Or(b*(o-=2/3))/Or(g-b*o))/3)),[255*(e=r(i*e*3)),255*(a=r(i*a*3)),255*(f=r(i*f*3)),t.length>3?t[3]:1]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsi"))&&3===r.length)return"hsi"}}),y.prototype.hsl=function(){return N(this._rgb)};var Gr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsl"])))};w.hsl=Gr,m.format.hsl=Z,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsl"))&&3===r.length)return"hsl"}});var Rr=Math.floor,Yr=Math.min,$r=Math.max;y.prototype.hsv=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n,e,a,f=(r=u(r,"rgb"))[0],o=r[1],c=r[2],i=Yr(f,o,c),l=$r(f,o,c),s=l-i;return a=l/255,0===l?(n=Number.NaN,e=0):(e=s/l,f===l&&(n=(o-c)/s),o===l&&(n=2+(c-f)/s),c===l&&(n=4+(f-o)/s),(n*=60)<0&&(n+=360)),[n,e,a]}(this._rgb)};var qr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hsv"])))};w.hsv=qr,m.format.hsv=function(){for(var r,t,n,e,a,f,o=[],c=arguments.length;c--;)o[c]=arguments[c];var i,l,s,h=(o=u(o,"hsv"))[0],d=o[1],b=o[2];if(b*=255,0===d)i=l=s=b;else{360===h&&(h=0),h>360&&(h-=360),h<0&&(h+=360);var g=Rr(h/=60),v=h-g,p=b*(1-d),m=b*(1-d*v),y=b*(1-d*(1-v));switch(g){case 0:i=(r=[b,y,p])[0],l=r[1],s=r[2];break;case 1:i=(t=[m,b,p])[0],l=t[1],s=t[2];break;case 2:i=(n=[p,b,y])[0],l=n[1],s=n[2];break;case 3:i=(e=[p,m,b])[0],l=e[1],s=e[2];break;case 4:i=(a=[y,p,b])[0],l=a[1],s=a[2];break;case 5:i=(f=[b,p,m])[0],l=f[1],s=f[2]}}return[i,l,s,o.length>3?o[3]:1]},m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"hsv"))&&3===r.length)return"hsv"}}),y.prototype.lab=function(){return E(this._rgb)};var Xr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["lab"])))};Object.assign(w,{lab:Xr,getLabWhitePoint:j,setLabWhitePoint:A}),m.format.lab=S,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"lab"))&&3===r.length)return"lab"}});y.prototype.lch=function(){return R(this._rgb)},y.prototype.hcl=function(){return R(this._rgb).reverse()};var Cr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["lch"])))},Zr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["hcl"])))};Object.assign(w,{lch:Cr,hcl:Zr}),m.format.lch=D,m.format.hcl=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"hcl").reverse();return D.apply(void 0,n)},["lch","hcl"].forEach((function(r){return m.autodetect.push({p:2,test:function(){for(var t=[],n=arguments.length;n--;)t[n]=arguments[n];if("array"===o(t=u(t,r))&&3===t.length)return r}})}));y.prototype.num=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgb");return(n[0]<<16)+(n[1]<<8)+n[2]}(this._rgb)};var Sr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["num"])))};Object.assign(w,{num:Sr}),m.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)},m.autodetect.push({p:5,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if(1===r.length&&"number"===o(r[0])&&r[0]>=0&&r[0]<=16777215)return"num"}});var Wr=Math.round;y.prototype.rgb=function(r){return void 0===r&&(r=!0),!1===r?this._rgb.slice(0,3):this._rgb.slice(0,3).map(Wr)},y.prototype.rgba=function(r){return void 0===r&&(r=!0),this._rgb.slice(0,4).map((function(t,n){return n<3?!1===r?t:Wr(t):t}))};var Ir=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["rgb"])))};Object.assign(w,{rgb:Ir}),m.format.rgb=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];var n=u(r,"rgba");return void 0===n[3]&&(n[3]=1),n},m.autodetect.push({p:3,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];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,zr=function(r){var t,n,e,a=r/100;return a<66?(t=255,n=a<6?0:-155.25485562709179-.44596950469579133*(n=a-2)+104.49216199393888*Kr(n),e=a<20?0:.8274096064007395*(e=a-10)-254.76935184120902+115.67994401066147*Kr(e)):(t=351.97690566805693+.114206453784165*(t=a-55)-40.25366309332127*Kr(t),n=325.4494125711974+.07943456536662342*(n=a-50)-28.0852963507957*Kr(n),e=255),[t,n,e,1]},Ur=Math.round;y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];for(var n,e=u(r,"rgb"),a=e[0],f=e[2],o=1e3,c=4e4;c-o>.4;){var i=zr(n=.5*(c+o));i[2]/i[0]>=f/a?c=n:o=n}return Ur(n)}(this._rgb)};var Vr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["temp"])))};Object.assign(w,{temp:Vr,kelvin:Vr,temperature:Vr}),m.format.temp=m.format.kelvin=m.format.temperature=zr,y.prototype.oklab=function(){return $(this._rgb)};var Dr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["oklab"])))};Object.assign(w,{oklab:Dr}),m.format.oklab=T,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklab"))&&3===r.length)return"oklab"}}),y.prototype.oklch=function(){return q(this._rgb)};var Tr=function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];return new(Function.prototype.bind.apply(y,[null].concat(r,["oklch"])))};Object.assign(w,{oklch:Tr}),m.format.oklch=H,m.autodetect.push({p:2,test:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];if("array"===o(r=u(r,"oklch"))&&3===r.length)return"oklch"}});var Hr={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"};y.prototype.name=function(){for(var r=jr(this._rgb,"rgb"),t=0,n=Object.keys(Hr);t0;)t[n]=arguments[n+1];if(!t.length&&"string"===o(r)&&Hr[r.toLowerCase()])return"named"}}),y.prototype.alpha=function(r,t){return void 0===t&&(t=!1),void 0!==r&&"number"===o(r)?t?(this._rgb[3]=r,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],r],"rgb"):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1},y.prototype.darken=function(r){void 0===r&&(r=1);var t=this.lab();return t[0]-=_.Kn*r,new y(t,"lab").alpha(this.alpha(),!0)},y.prototype.brighten=function(r){return void 0===r&&(r=1),this.darken(-r)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(r){var t=r.split("."),n=t[0],e=t[1],a=this[n]();if(e){var f=n.indexOf(e)-("ok"===n.substr(0,2)?2:0);if(f>-1)return a[f];throw new Error("unknown channel "+e+" in mode "+n)}return a};var Jr=Math.pow;y.prototype.luminance=function(r,t){if(void 0===t&&(t="rgb"),void 0!==r&&"number"===o(r)){if(0===r)return new y([0,0,0,this._rgb[3]],"rgb");if(1===r)return new y([255,255,255,this._rgb[3]],"rgb");var n=this.luminance(),e=20,a=function(n,f){var o=n.interpolate(f,.5,t),u=o.luminance();return Math.abs(r-u)<1e-7||!e--?o:u>r?a(n,o):a(o,f)},f=(n>r?a(new y([0,0,0]),this):a(this,new y([255,255,255]))).rgb();return new y(f.concat([this._rgb[3]]))}return Qr.apply(void 0,this._rgb.slice(0,3))};var Qr=function(r,t,n){return.2126*(r=rt(r))+.7152*(t=rt(t))+.0722*(n=rt(n))},rt=function(r){return(r/=255)<=.03928?r/12.92:Jr((r+.055)/1.055,2.4)},tt={};function nt(r,t,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var f=e[0]||"lrgb";if(tt[f]||e.length||(f=Object.keys(tt)[0]),!tt[f])throw new Error("interpolation mode "+f+" is not defined");return"object"!==o(r)&&(r=new y(r)),"object"!==o(t)&&(t=new y(t)),tt[f](r,t,n).alpha(r.alpha()+n*(t.alpha()-r.alpha()))}y.prototype.mix=y.prototype.interpolate=function(r,t){void 0===t&&(t=.5);for(var n=[],e=arguments.length-2;e-- >0;)n[e]=arguments[e+2];return nt.apply(void 0,[this,r,t].concat(n))},y.prototype.premultiply=function(r){void 0===r&&(r=!1);var t=this._rgb,n=t[3];return r?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new y([t[0]*n,t[1]*n,t[2]*n,n],"rgb")},y.prototype.saturate=function(r){void 0===r&&(r=1);var t=this.lch();return t[1]+=_.Kn*r,t[1]<0&&(t[1]=0),new y(t,"lch").alpha(this.alpha(),!0)},y.prototype.desaturate=function(r){return void 0===r&&(r=1),this.saturate(-r)},y.prototype.set=function(r,t,n){void 0===n&&(n=!1);var e=r.split("."),a=e[0],f=e[1],u=this[a]();if(f){var c=a.indexOf(f)-("ok"===a.substr(0,2)?2:0);if(c>-1){if("string"==o(t))switch(t.charAt(0)){case"+":case"-":u[c]+=+t;break;case"*":u[c]*=+t.substr(1);break;case"/":u[c]/=+t.substr(1);break;default:u[c]=+t}else{if("number"!==o(t))throw new Error("unsupported value for Color.set");u[c]=t}var i=new y(u,a);return n?(this._rgb=i._rgb,this):i}throw new Error("unknown channel "+f+" in mode "+a)}return u},y.prototype.tint=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return nt.apply(void 0,[this,"white",r].concat(t))},y.prototype.shade=function(r){void 0===r&&(r=.5);for(var t=[],n=arguments.length-1;n-- >0;)t[n]=arguments[n+1];return nt.apply(void 0,[this,"black",r].concat(t))};tt.rgb=function(r,t,n){var e=r._rgb,a=t._rgb;return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"rgb")};var et=Math.sqrt,at=Math.pow;tt.lrgb=function(r,t,n){var e=r._rgb,a=e[0],f=e[1],o=e[2],u=t._rgb,c=u[0],i=u[1],l=u[2];return new y(et(at(a,2)*(1-n)+at(c,2)*n),et(at(f,2)*(1-n)+at(i,2)*n),et(at(o,2)*(1-n)+at(l,2)*n),"rgb")};function ft(r,t,n,e){var a,f,o,u,c,i,l,s,h,d,b,g,v;return"hsl"===e?(o=r.hsl(),u=t.hsl()):"hsv"===e?(o=r.hsv(),u=t.hsv()):"hcg"===e?(o=r.hcg(),u=t.hcg()):"hsi"===e?(o=r.hsi(),u=t.hsi()):"lch"===e||"hcl"===e?(e="hcl",o=r.hcl(),u=t.hcl()):"oklch"===e&&(o=r.oklch().reverse(),u=t.oklch().reverse()),"h"!==e.substr(0,1)&&"oklch"!==e||(c=(a=o)[0],l=a[1],h=a[2],i=(f=u)[0],s=f[1],d=f[2]),isNaN(c)||isNaN(i)?isNaN(c)?isNaN(i)?g=Number.NaN:(g=i,1!=h&&0!=h||"hsv"==e||(b=s)):(g=c,1!=d&&0!=d||"hsv"==e||(b=l)):g=c+n*(i>c&&i-c>180?i-(c+360):i180?i+360-c:i-c),void 0===b&&(b=l+n*(s-l)),v=h+n*(d-h),new y("oklch"===e?[v,b,g]:[g,b,v],e)}tt.lab=function(r,t,n){var e=r.lab(),a=t.lab();return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"lab")};var ot=function(r,t,n){return ft(r,t,n,"lch")};tt.lch=ot,tt.hcl=ot;tt.num=function(r,t,n){var e=r.num(),a=t.num();return new y(e+n*(a-e),"num")};tt.hcg=function(r,t,n){return ft(r,t,n,"hcg")};tt.hsi=function(r,t,n){return ft(r,t,n,"hsi")};tt.hsl=function(r,t,n){return ft(r,t,n,"hsl")};tt.hsv=function(r,t,n){return ft(r,t,n,"hsv")};tt.oklab=function(r,t,n){var e=r.oklab(),a=t.oklab();return new y(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")};tt.oklch=function(r,t,n){return ft(r,t,n,"oklch")};var ut=Math.pow,ct=Math.sqrt,it=Math.PI,lt=Math.cos,st=Math.sin,ht=Math.atan2;var dt=function(r,n){for(var e=r.length,a=[0,0,0,0],f=0;f.9999999&&(a[3]=1),new y(t(a))},bt=Math.pow;function gt(t){var n="rgb",e=w("#ccc"),a=0,f=[0,1],u=[],c=[0,0],i=!1,l=[],s=!1,h=0,d=1,b=!1,g={},v=!0,p=1,m=function(r){if((r=r||["#fff","#000"])&&"string"===o(r)&&w.brewer&&w.brewer[r.toLowerCase()]&&(r=w.brewer[r.toLowerCase()]),"array"===o(r)){1===r.length&&(r=[r[0],r[0]]),r=r.slice(0);for(var t=0;t2){var b=function(r){if(null!=i){for(var t=i.length-1,n=0;n=i[n];)n++;return n-1}return 0}(t);s=b/(i.length-2)}else s=d!==h?(t-h)/(d-h):1;s=k(s),a||(s=y(s)),1!==p&&(s=bt(s,p)),s=r(s=c[0]+s*(1-c[0]-c[1]),0,1);var m=Math.floor(1e4*s);if(v&&g[m])f=g[m];else{if("array"===o(l))for(var M=0;M=N&&M===u.length-1){f=l[M];break}if(s>N&&s2){var c=r.map((function(t,n){return n/(r.length-1)})),i=r.map((function(r){return(r-h)/(d-h)}));i.every((function(r,t){return c[t]===r}))||(k=function(r){if(r<=0||r>=1)return r;for(var t=0;r>=i[t+1];)t++;var n=(r-i[t])/(i[t+1]-i[t]);return c[t]+n*(c[t+1]-c[t])})}}return f=[h,d],_},_.mode=function(r){return arguments.length?(n=r,N(),_):n},_.range=function(r,t){return m(r),_},_.out=function(r){return s=r,_},_.spread=function(r){return arguments.length?(a=r,_):a},_.correctLightness=function(r){return null==r&&(r=!0),b=r,N(),y=b?function(r){for(var t=M(0,!0).lab()[0],n=M(1,!0).lab()[0],e=t>n,a=M(r,!0).lab()[0],f=t+(n-t)*r,o=a-f,u=0,c=1,i=20;Math.abs(o)>.01&&i-- >0;)e&&(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,n){arguments.length<2&&(n="hex");var e=[];if(0===arguments.length)e=l.slice(0);else if(1===r)e=[_(.5)];else if(r>1){var a=f[0],o=f[1]-a;e=function(r,t){for(var n=[],e=ra;e?f++:f--)n.push(f);return n}(0,r).map((function(t){return _(a+t/(r-1)*o)}))}else{t=[];var u=[];if(i&&i.length>2)for(var c=1,s=i.length,h=1<=s;h?cs;h?c++:c--)u.push(.5*(i[c-1]+i[c]));else u=f;e=u.map((function(r){return _(r)}))}return w[n]&&(e=e.map((function(r){return r[n]()}))),e},_.cache=function(r){return null!=r?(v=r,_):v},_.gamma=function(r){return null!=r?(p=r,_):p},_.nodata=function(r){return null!=r?(e=w(r),_):e},_}var vt=function(r,t,n){if(!vt[n])throw new Error("unknown blend mode "+n);return vt[n](r,t)},pt=function(r){return function(t,n){var e=w(n).rgb(),a=w(t).rgb();return w.rgb(r(e,a))}},mt=function(r){return function(t,n){var e=[];return e[0]=r(t[0],n[0]),e[1]=r(t[1],n[1]),e[2]=r(t[2],n[2]),e}};vt.normal=pt(mt((function(r){return r}))),vt.multiply=pt(mt((function(r,t){return r*t/255}))),vt.screen=pt(mt((function(r,t){return 255*(1-(1-r/255)*(1-t/255))}))),vt.overlay=pt(mt((function(r,t){return t<128?2*r*t/255:255*(1-2*(1-r/255)*(1-t/255))}))),vt.darken=pt(mt((function(r,t){return r>t?t:r}))),vt.lighten=pt(mt((function(r,t){return r>t?r:t}))),vt.dodge=pt(mt((function(r,t){return 255===r||(r=t/255*255/(1-r/255))>255?255:r}))),vt.burn=pt(mt((function(r,t){return 255*(1-(1-t/255)/(r/255))})));var yt=Math.pow,wt=Math.sin,kt=Math.cos;var Mt=Math.floor,Nt=Math.random;var _t=Math.log,xt=Math.pow,At=Math.floor,jt=Math.abs;function Et(r,t){void 0===t&&(t=null);var n={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){t&&"object"===o(r)&&(r=r[t]),null==r||isNaN(r)||(n.values.push(r),n.sum+=r,rn.max&&(n.max=r),n.count+=1)})),n.domain=[n.min,n.max],n.limits=function(r,t){return Ot(n,r,t)},n}function Ot(r,t,n){void 0===t&&(t="equal"),void 0===n&&(n=7),"array"==o(r)&&(r=Et(r));var e=r.min,a=r.max,f=r.values.sort((function(r,t){return r-t}));if(1===n)return[e,a];var u=[];if("c"===t.substr(0,1)&&(u.push(e),u.push(a)),"e"===t.substr(0,1)){u.push(e);for(var c=1;c 0");var i=Math.LOG10E*_t(e),l=Math.LOG10E*_t(a);u.push(e);for(var s=1;s200&&(w=!1)}for(var Y={},$=0;$=360;)b-=360;o[d]=b}else o[d]=o[d]/u[d];return h/=e,new y(o,t).alpha(h>.99999?1:h,!0)},bezier:function(r){var t=function(r){var t,n,e,a,f,o,u;if(2===(r=r.map((function(r){return new y(r)}))).length)t=r.map((function(r){return r.lab()})),f=t[0],o=t[1],a=function(r){var t=[0,1,2].map((function(t){return f[t]+r*(o[t]-f[t])}));return new y(t,"lab")};else if(3===r.length)n=r.map((function(r){return r.lab()})),f=n[0],o=n[1],u=n[2],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*f[t]+2*(1-r)*r*o[t]+r*r*u[t]}));return new y(t,"lab")};else if(4===r.length){var c;e=r.map((function(r){return r.lab()})),f=e[0],o=e[1],u=e[2],c=e[3],a=function(r){var t=[0,1,2].map((function(t){return(1-r)*(1-r)*(1-r)*f[t]+3*(1-r)*(1-r)*r*o[t]+3*(1-r)*r*r*u[t]+r*r*r*c[t]}));return new y(t,"lab")}}else{if(!(r.length>=5))throw new RangeError("No point in running bezier with only one color.");var i,l,s;i=r.map((function(r){return r.lab()})),s=r.length-1,l=function(r){for(var t=[1,1],n=1;ne?(n+.05)/(e+.05):(e+.05)/(n+.05)},cubehelix:function(r,n,e,a,f){void 0===r&&(r=300),void 0===n&&(n=-1.5),void 0===e&&(e=1),void 0===a&&(a=1),void 0===f&&(f=[0,1]);var u,c=0;"array"===o(f)?u=f[1]-f[0]:(u=0,f=[f,f]);var i=function(o){var i=b*((r+120)/360+n*o),l=yt(f[0]+u*o,a),s=(0!==c?e[0]+o*c:e)*l*(1-l)/2,h=kt(i),d=wt(i);return w(t([255*(l+s*(-.14861*h+1.78277*d)),255*(l+s*(-.29227*h-.90649*d)),255*(l+s*(1.97294*h)),1]))};return i.start=function(t){return null==t?r:(r=t,i)},i.rotations=function(r){return null==r?n:(n=r,i)},i.gamma=function(r){return null==r?a:(a=r,i)},i.hue=function(r){return null==r?e:("array"===o(e=r)?0===(c=e[1]-e[0])&&(e=e[1]):c=0,i)},i.lightness=function(r){return null==r?f:("array"===o(r)?(f=r,u=r[1]-r[0]):(f=[r,r],u=0),i)},i.scale=function(){return w.scale(i)},i.hue(e),i},deltaE:function(r,t,n,e,a){void 0===n&&(n=1),void 0===e&&(e=1),void 0===a&&(a=1);var f=function(r){return 360*r/(2*Xt)},o=function(r){return 2*Xt*r/360};r=new y(r),t=new y(t);var u=Array.from(r.lab()),c=u[0],i=u[1],l=u[2],s=Array.from(t.lab()),h=s[0],d=s[1],b=s[2],g=(c+h)/2,v=(Ft(Lt(i,2)+Lt(l,2))+Ft(Lt(d,2)+Lt(b,2)))/2,p=.5*(1-Ft(Lt(v,7)/(Lt(v,7)+Lt(25,7)))),m=i*(1+p),w=d*(1+p),k=Ft(Lt(m,2)+Lt(l,2)),M=Ft(Lt(w,2)+Lt(b,2)),N=(k+M)/2,_=f(Gt(l,m)),x=f(Gt(b,w)),A=_>=0?_:_+360,j=x>=0?x:x+360,E=Rt(A-j)>180?(A+j+360)/2:(A+j)/2,O=1-.17*Yt(o(E-30))+.24*Yt(o(2*E))+.32*Yt(o(3*E+6))-.2*Yt(o(4*E-63)),F=j-A;F=Rt(F)<=180?F:j<=A?F+360:F-360,F=2*Ft(k*M)*$t(o(F)/2);var L=h-c,P=M-k,B=1+.015*Lt(g-50,2)/Ft(20+Lt(g-50,2)),G=1+.045*N,R=1+.015*N*O,Y=30*qt(-Lt((E-275)/25,2)),$=-(2*Ft(Lt(N,7)/(Lt(N,7)+Lt(25,7))))*$t(2*o(Y)),q=Ft(Lt(L/(n*B),2)+Lt(P/(e*G),2)+Lt(F/(a*R),2)+$*(P/(e*G))*(F/(a*R)));return Bt(0,Pt(100,q))},distance:function(r,t,n){void 0===n&&(n="lab"),r=new y(r),t=new y(t);var e=r.get(n),a=t.get(n),f=0;for(var o in e){var u=(e[o]||0)-(a[o]||0);f+=u*u}return Math.sqrt(f)},input:m,interpolate:nt,limits:Ot,mix:nt,random:function(){for(var r="#",t=0;t<6;t++)r+="0123456789abcdef".charAt(Mt(16*Nt()));return new y(r,"hex")},scale:gt,scales:Ct,valid:function(){for(var r=[],t=arguments.length;t--;)r[t]=arguments[t];try{return new(Function.prototype.bind.apply(y,[null].concat(r))),!0}catch(r){return!1}},cmyk:M,css:yr,gl:wr,hcg:Mr,hex:Er,hsi:Br,hsl:Gr,hsv:qr,lab:Xr,lch:Cr,hcl:Zr,num:Sr,rgb:Ir,temp:Vr,kelvin:Vr,temperature:Vr,oklab:Dr,oklch:Tr,getLabWhitePoint:j,setLabWhitePoint:A}),w})); diff --git a/docs/index.html b/docs/index.html index 03b33570..e83ab43d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -4,8 +4,9 @@ chroma.js api docs! + -
+

chroma.js

chroma.js is a small-ish zero-dependency JavaScript library (13.5kB) for all kinds of color conversions and color scales.

Build Status

@@ -27,7 +28,7 @@

Quick-start

chroma('pink').darken().saturate(2).hex()
 

Aside from that, chroma.js can also help you generate nice colors using various methods, for instance to be used in color palette for maps or data visualization.

-
chroma.scale(['#fafa6e','#2A4858'])
+
chroma.scale(['#fafa6e', '#2A4858'])
     .mode('lch').colors(6)
 

chroma.js has a lot more to offer, but that's the gist of it.

@@ -73,10 +74,72 @@

chroma.hsv

(hue, saturation, value)

chroma.lab

(Lightness, a, b)

-

CIELAB color space

-
chroma.lab(40,-20,50);
-chroma.lab(50,-20,50);
-chroma.lab(80,-20,50);
+

CIE Lab color space. To calculate the lightness value of a color, the CIE Lab color space uses a reference white point. This reference white point defines what is considered to be "white" in the color space. By default chroma.js is using the D65 reference point.

+
chroma.lab(40, -20, 50);
+chroma.lab(50, -20, 50);
+chroma.lab(80, -20, 50);
+
+

chroma.setLabWhitePoint

+

(whitePoint)

+

Sets the current CIE Lab white reference point.

+

Possible values:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
D50Represents the color temperature of daylight at 5000K.
D55Represents mid-morning or mid-afternoon daylight at 5500K.
D65Represents average daylight at 6500K.
ARepresents the color temperature of a typical incandescent light bulb at approximately 2856K.
BRepresents noon daylight with a color temperature of approximately 4874K.
CRepresents average or north sky daylight; it's a theoretical construct, not often used in practical applications.
F2Represents cool white fluorescent light.
F7This is a broad-band fluorescent light source with a color temperature of approximately 6500K.
F11This is a narrow tri-band fluorescent light source with a color temperature of approximately 4000K.
ERepresents an equal energy white point, where all wavelengths in the visible spectrum are equally represented.
+
chroma('hotpink').lab();
+chroma.setLabWhitePoint('F2');
+chroma('hotpink').lab();
+
+

chroma.getLabWhitePoint

+

Returns the name of the currently set CIE Lab white reference point.

+
chroma.getLabWhitePoint();
 

chroma.oklab

(Lightness, a, b)

@@ -269,15 +332,15 @@

(targetcolor, ratio=0.5, mode='lr

color.shade

(ratio=0.5, mode='lrgb')

Produce a shade of the color. This is syntactic sugar for color.mix with a target color of black.

-
chroma('hotpink').shade();
-chroma('hotpink').shade(0.25);
+
chroma('hotpink').shade(0.25);
+chroma('hotpink').shade(0.5);
 chroma('hotpink').shade(0.75);
 

color.tint

(ratio=0.5, mode='lrgb')

Produce a tint of the color. This is syntactic sugar for color.mix with a target color of white.

-
chroma('hotpink').tint();
-chroma('hotpink').tint(0.25);
+
chroma('hotpink').tint(0.25);
+chroma('hotpink').tint(0.5);
 chroma('hotpink').tint(0.75);
 

color.set

@@ -338,10 +401,14 @@

color.name

chroma('#ffa505').name();

color.css

-

Returns a RGB() or HSL() string representation that can be used as CSS-color definition.

+

Returns a CSS string representation that can be used as CSS-color definition.

chroma('teal').css();
 chroma('teal').alpha(0.5).css();
-chroma('teal').css('hsl');
+
+

By default chroma is using the rgb() color space, but you can pass a color space name as first argument. Accepted color spaces are rgb, hsl, lab, lch, oklab, and oklch.

+
chroma('teal').css('hsl');
+chroma('teal').css('lab');
+chroma('teal').css('oklch');
 

color.rgb

(round=true)

@@ -424,7 +491,7 @@

color.clipped

color scales

chroma.scale

-

(colors=['white','black'])

+

(colors=['white', 'black'])

A color scale, created with chroma.scale, is a function that maps numeric values to a color palette. The default scale has the domain 0..1 and goes from white to black.

f = chroma.scale();
 f(0.25);
@@ -474,9 +541,9 @@ 

scale.gamma

scale.correctLightness

This makes sure the lightness range is spread evenly across a color scale. Especially useful when working with multi-hue color scales, where simple gamma correction can't help you very much.

-
chroma.scale(['black','red','yellow','white']);
+
chroma.scale(['black', 'red', 'yellow', 'white']);
 
-chroma.scale(['black','red','yellow','white'])
+chroma.scale(['black', 'red', 'yellow', 'white'])
     .correctLightness();
 

scale.cache

@@ -604,6 +671,35 @@

cubehelix.scale

.colors(5);

Changelog

+

3.0.0

+
    +
  • 🎉 NEW: Add support for modern CSS color spaces. This means you can now export and parse CSS colors in lab(), lch(), oklab(), oklch() space.
  • +
  • 🎉 NEW: you can now control the standard white reference point for the CIE Lab and CIE Lch color spaces via setLabWhitePoint.
  • +
  • Breaking: color.css() will no longer return legacy CSS colors like rgb(255, 255, 0) but use modern CSS colors like rgb(255 255 0) instead.
  • +
  • fix: you can now use chroma.js both via the default export as well as named exports in ES6.
  • +
  • fix: switch to W3C implementation of OKLab color space
  • +
+

2.6.0

+ +

2.5.0

+
    +
  • refactored code base to ES6 modules
  • +
+

2.4.0

+
    +
  • add support for Oklab and Oklch color spaces
  • +
+

2.3.0

+
    +
  • use binom of degree n in chroma.bezier
  • +
+

2.2.0

+
    +
  • use Delta e2000 for chroma.deltaE #269
  • +

2.0.3

  • hsl2rgb will, like other x2rgb conversions now set the default alpha to 1
  • @@ -697,6 +793,16 @@

    1.0.0