forked from gka/chroma.js
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathchroma-light.min.js
86 lines (85 loc) · 22.6 KB
/
chroma-light.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* chroma.js - JavaScript library for color conversions
*
* Copyright (c) 2023, Regorxxx
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Regorxxx may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
* Copyright (c) 2011-2019, Gregor Aisch
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. The name Gregor Aisch may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* -------------------------------------------------------
*
* chroma.js includes colors from colorbrewer2.org, which are released under
* the following license:
*
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
* and The Pennsylvania State University.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific
* language governing permissions and limitations under the License.
*
* ------------------------------------------------------
*
* Named colors are taken from X11 Color Names.
* http://www.w3.org/TR/css3-color/#svg-color
*
* @preserve
*/
!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";for(var t=function(t,r,n){return void 0===r&&(r=0),void 0===n&&(n=1),t<r?r:t>n?n:t},r=t,n={},e=0,a=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];e<a.length;e+=1){var o=a[e];n["[object "+o+"]"]=o.toLowerCase()}var u=function(t){return n[Object.prototype.toString.call(t)]||"object"},i=u,l=u,c=Math.PI,s={clip_rgb:function(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},limit:t,type:u,unpack:function(t,r){return void 0===r&&(r=null),t.length>=3?Array.prototype.slice.call(t):"object"==i(t[0])&&r?r.split("").filter((function(r){return void 0!==t[0][r]})).map((function(r){return t[0][r]})):t[0]},last:function(t){if(t.length<2)return null;var r=t.length-1;return"string"==l(t[r])?t[r].toLowerCase():null},PI:c,TWOPI:2*c,PITHIRD:c/3,DEG2RAD:c/180,RAD2DEG:180/c},h={format:{},autodetect:[]},f=s.last,p=s.clip_rgb,g=s.type,b=h,d=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=this;if("object"===g(t[0])&&t[0].constructor&&t[0].constructor===this.constructor)return t[0];"array"===g(t[0])&&1===t.length&&(t=[].concat(t[0]));var e=f(t),a=!1;if(!e){a=!0,b.sorted||(b.autodetect=b.autodetect.sort((function(t,r){return r.p-t.p})),b.sorted=!0);for(var o=0,u=b.autodetect;o<u.length;o+=1){var i=u[o];if(e=i.test.apply(i,t))break}}if(!b.format[e])throw new Error("unknown format: "+t);var l=b.format[e].apply(null,a?t:t.slice(0,-1));n._rgb=p(l),3===n._rgb.length&&n._rgb.push(1)};d.prototype.toString=function(){return"function"==g(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var v=d,m=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(m.Color,[null].concat(t)))};m.Color=v,m.version="2.7.0",m.hueNaN=!0;var y=m,k=s.unpack,w=s.last,N=function(t){return Math.round(100*t)/100},M=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=k(t,"hsla"),e=w(t)||"lsa";return n[0]=N(n[0]||0),n[1]=N(100*n[1])+"%",n[2]=N(100*n[2])+"%","hsla"===e||n.length>3&&n[3]<1?(n[3]=n.length>3?n[3]:1,e="hsla"):n.length=3,e+"("+n.join(",")+")"},_=s.unpack,x=y,j=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=_(t,"rgba"))[0],e=t[1],a=t[2];n/=255,e/=255,a/=255;var o,u,i=Math.min(n,e,a),l=Math.max(n,e,a),c=(l+i)/2;return l===i?(o=0,u=x.hueNaN?Number.NaN:0):o=c<.5?(l-i)/(l+i):(l-i)/(2-l-i),n==l?u=(e-a)/(l-i):e==l?u=2+(a-n)/(l-i):a==l&&(u=4+(n-e)/(l-i)),(u*=60)<0?u+=360:!x.hueNaN&&isNaN(u)&&(u=0),t.length>3&&void 0!==t[3]?[u,o,c,t[3]]:[u,o,c]},F=s.unpack,A=s.last,E=function(t){return Math.round(100*t)/100},$=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=F(t,"lch"),e=A(t)||"lch";return n[0]=E(n[0])+"%",n[1]=E(n[1])+"%",n[2]=E(n[2]||0),"lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lch("+n.join(" ")+")"},D={Kn:18,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452},C=D,I=s.unpack,O=Math.pow,R=function(t){return(t/=255)<=.04045?t/12.92:O((t+.055)/1.055,2.4)},S=function(t){return t>C.t3?O(t,1/3):t/C.t2+C.t0},G=function(t,r,n){return t=R(t),r=R(r),n=R(n),[S((.4124564*t+.3575761*r+.1804375*n)/C.Xn),S((.2126729*t+.7151522*r+.072175*n)/C.Yn),S((.0193339*t+.119192*r+.9503041*n)/C.Zn)]},L=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],u=G(e,a,o),i=u[0],l=u[1],c=116*l-16;return[c<0?0:c,500*(i-l),200*(l-u[2])]},P=s.unpack,T=s.RAD2DEG,Z=Math.sqrt,W=Math.atan2,X=Math.round,Y=y,q=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=P(t,"lab"),e=n[0],a=n[1],o=n[2],u=Z(a*a+o*o),i=(W(o,a)*T+360)%360;return 0===X(1e4*u)&&(i=Y.hueNaN?Number.NaN:0),[e,u,i]},H=s.unpack,K=L,B=q,U=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=H(t,"rgb"),e=n[0],a=n[1],o=n[2],u=K(e,a,o),i=u[0],l=u[1],c=u[2];return B(i,l,c)},z=s.unpack,J=s.last,Q=function(t){return Math.round(100*t)/100},V=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=z(t,"lab"),e=J(t)||"lab";return n[0]=Q(n[0])+"%",n[1]=Q(n[1])+"%",n[2]=Q(n[2])+"%","laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"lab("+n.join(" ")+")"},tt=s.unpack,rt=s.last,nt=function(t){return Math.round(100*t)/100},et=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=tt(t,"lab"),e=rt(t)||"lab";return n[0]=nt(100*n[0])+"%",n[1]=nt(100*n[1])+"%",n[2]=nt(100*n[2])+"%","laba"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklab("+n.join(" ")+")"},at=s.unpack,ot=Math.cbrt,ut=Math.pow,it=Math.sign,lt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=at(t,"rgb"),e=n[0],a=n[1],o=n[2],u=[ct(e/255),ct(a/255),ct(o/255)],i=u[0],l=u[1],c=u[2],s=ot(.4122214708*i+.5363325363*l+.0514459929*c),h=ot(.2119034982*i+.6806995451*l+.1073969566*c),f=ot(.0883024619*i+.2817188376*l+.6299787005*c);return[.2104542553*s+.793617785*h-.0040720468*f,1.9779984951*s-2.428592205*h+.4505937099*f,.0259040371*s+.7827717662*h-.808675766*f]};function ct(t){var r=Math.abs(t);return r<.04045?t/12.92:(it(t)||1)*ut((r+.055)/1.055,2.4)}var st=s.unpack,ht=s.last,ft=function(t){return Math.round(100*t)/100},pt=Math.min,gt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=st(t,"lch"),e=ht(t)||"lch";return n[0]=ft(100*n[0])+"%",n[1]=pt(ft(n[1]/.4*100),100)+"%",n[2]=ft(n[2]||0),"lcha"===e||n.length>3&&n[3]<1?n[3]="/ "+(n.length>3?n[3]:1):n.length=3,"oklch("+n.join(" ")+")"},bt=s.unpack,dt=lt,vt=q,mt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=bt(t,"rgb"),e=n[0],a=n[1],o=n[2],u=dt(e,a,o),i=u[0],l=u[1],c=u[2];return vt(i,l,c)},yt=s.unpack,kt=s.last,wt=M,Nt=j,Mt=$,_t=U,xt=V,jt=L,Ft=et,At=lt,Et=gt,$t=mt,Dt=Math.round,Ct=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=yt(t,"rgba"),e=kt(t)||"rgb";return"hsl"==e.substring(0,3)?wt(Nt(n),e):"lch"==e.substring(0,3)?Mt(_t(n),e):"lab"==e.substring(0,3)?xt(jt(n).concat([n.length>3?n[3]:1]),e):"oklab"==e.substring(0,5)?Ft(At(n).concat([n.length>3?n[3]:1]),"lab"):"oklch"==e.substring(0,5)?Et($t(n).concat([n.length>3?n[3]:1]),"lch"):(n[0]=Dt(n[0]),n[1]=Dt(n[1]),n[2]=Dt(n[2]),("rgba"===e||n.length>3&&n[3]<1)&&(n[3]=n.length>3?n[3]:1,e="rgba"),e+"("+n.slice(0,"rgb"===e?3:4).join(",")+")")},It=s.unpack,Ot=Math.round,Rt=function(){for(var t,r=[],n=arguments.length;n--;)r[n]=arguments[n];var e,a,o,u=(r=It(r,"hsl"))[0],i=r[1],l=r[2];if(0===i)e=a=o=255*l;else{var c=[0,0,0],s=[0,0,0],h=l<.5?l*(1+i):l+i-l*i,f=2*l-h,p=u/360;c[0]=p+1/3,c[1]=p,c[2]=p-1/3;for(var g=0;g<3;g++)c[g]<0&&(c[g]+=1),c[g]>1&&(c[g]-=1),6*c[g]<1?s[g]=f+6*(h-f)*c[g]:2*c[g]<1?s[g]=h:3*c[g]<2?s[g]=f+(h-f)*(2/3-c[g])*6:s[g]=f;e=(t=[Ot(255*s[0]),Ot(255*s[1]),Ot(255*s[2])])[0],a=t[1],o=t[2]}return r.length>3?[e,a,o,r[3]]:[e,a,o,1]},St=D,Gt=s.unpack,Lt=Math.pow,Pt=function(t){return 255*(t<=.00304?12.92*t:1.055*Lt(t,1/2.4)-.055)},Tt=function(t){return t>St.t1?t*t*t:St.t2*(t-St.t0)},Zt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n,e,a,o=(t=Gt(t,"lab"))[0],u=t[1],i=t[2];return e=(o+16)/116,n=isNaN(u)?e:e+u/500,a=isNaN(i)?e:e-i/200,e=St.Yn*Tt(e),n=St.Xn*Tt(n),a=St.Zn*Tt(a),[Pt(3.2404542*n-1.5371385*e-.4985314*a),Pt(-.969266*n+1.8760108*e+.041556*a),Pt(.0556434*n-.2040259*e+1.0572252*a),t.length>3?t[3]:1]},Wt=s.unpack,Xt=s.DEG2RAD,Yt=Math.sin,qt=Math.cos,Ht=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=Wt(t,"lch"),e=n[0],a=n[1],o=n[2];return isNaN(o)&&(o=0),[e,qt(o*=Xt)*a,Yt(o)*a]},Kt=s.unpack,Bt=Ht,Ut=Zt,zt=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=Kt(t,"lch"))[0],e=t[1],a=t[2],o=Bt(n,e,a),u=o[0],i=o[1],l=o[2],c=Ut(u,i,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},Jt=s.unpack,Qt=Math.pow,Vt=Math.sign,tr=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=Jt(t,"lab"))[0],e=t[1],a=t[2],o=Qt(n+.3963377774*e+.2158037573*a,3),u=Qt(n-.1055613458*e-.0638541728*a,3),i=Qt(n-.0894841775*e-1.291485548*a,3);return[255*rr(4.0767416621*o-3.3077115913*u+.2309699292*i),255*rr(-1.2684380046*o+2.6097574011*u-.3413193965*i),255*rr(-.0041960863*o-.7034186147*u+1.707614701*i),t.length>3?t[3]:1]};function rr(t){var r=Math.abs(t);return r>.0031308?(Vt(t)||1)*(1.055*Qt(r,1/2.4)-.055):12.92*t}var nr=s.unpack,er=Ht,ar=tr,or=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=(t=nr(t,"lch"))[0],e=t[1],a=t[2],o=er(n,e,a),u=o[0],i=o[1],l=o[2],c=ar(u,i,l);return[c[0],c[1],c[2],t.length>3?t[3]:1]},ur=Rt,ir=Zt,lr=zt,cr=tr,sr=or,hr=h,fr=/^rgb\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*\)$/,pr=/^rgba\(\s*(-?\d+),\s*(-?\d+)\s*,\s*(-?\d+)\s*,\s*([01]|[01]?\.\d+)\)$/,gr=/^rgb\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,br=/^rgba\(\s*(-?\d+(?:\.\d+)?)%,\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,dr=/^hsl\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*\)$/,vr=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,mr=/^lab\(\s*(\d+(?:\.\d+)?)%?\s* (-?\d+(?:\.\d+)?)%?\s* \s*(-?\d+(?:\.\d+)?)%?\s*(?:\/\s*([01]|[01]?\.\d+))?\)$/,yr=/^lch\(\s*(\d+(?:\.\d+)?)%?\s* (\d+(?:\.\d+)?)%?\s* \s*(-?\d+(?:\.\d+)?)\s*(?:\/\s*([01]|[01]?\.\d+))?\)$/,kr=/^oklab\(\s*(\d+(?:\.\d+)?%?)\s* (-?\d+(?:\.\d+)?%?)\s* \s*(-?\d+(?:\.\d+)?%?)\s*(?:\/\s*([01]|[01]?\.\d+))?\)$/,wr=/^oklch\(\s*(\d+(?:\.\d+)?%?)\s* (\d+(?:\.\d+)?%?)\s* \s*(-?\d+(?:\.\d+)?)\s*(?:\/\s*([01]|[01]?\.\d+))?\)$/,Nr=Math.round,Mr=Math.abs,_r=function(t){var r;if(t=t.toLowerCase().trim(),hr.format.named)try{return hr.format.named(t)}catch(t){}if(r=t.match(fr)){for(var n=r.slice(1,4),e=0;e<3;e++)n[e]=Number(n[e]);return n[3]=1,n}if(r=t.match(pr)){for(var a=r.slice(1,5),o=0;o<4;o++)a[o]=Number(a[o]);return a}if(r=t.match(gr)){for(var u=r.slice(1,4),i=0;i<3;i++)u[i]=Nr(2.55*Number(u[i]));return u[3]=1,u}if(r=t.match(br)){for(var l=r.slice(1,5),c=0;c<3;c++)l[c]=Nr(2.55*Number(l[c]));return l[3]=Number(l[3]),l}if(r=t.match(dr)){for(var s=r.slice(1,4),h=0;h<=2;h++)s[h]=Number(s[h]);s[1]*=.01,s[2]*=.01;var f=ur(s);return f[3]=1,f}if(r=t.match(vr)){for(var p=r.slice(1,4),g=0;g<=2;g++)p[g]=Number(p[g]);p[1]*=.01,p[2]*=.01;var b=ur(p);return b[3]=Number(r[4]),b}if(r=t.match(mr)){for(var d=r.slice(1,4),v=0;v<=2;v++)d[v]=Number(d[v]);var m=ir(d).map((function(t){return Mr(Nr(t))}));return m[3]=Number(r[4]),m[3]||0===m[3]||(m[3]=1),m}if(r=t.match(yr)){for(var y=r.slice(1,4),k=0;k<=2;k++)y[k]=Number(y[k]);var w=lr(y).map((function(t){return Mr(Nr(t))}));return w[3]=Number(r[4]),w[3]||0===w[3]||(w[3]=1),w}if(r=t.match(kr)){for(var N=r.slice(1,4),M=0;M<=2;M++)N[M].endsWith("%")?N[M]=.01*Number(N[M].replace("%","")):N[M]=Number(N[M]);var _=cr(N).map((function(t){return Mr(Nr(t))}));return _[3]=Number(r[4]),_[3]||0===_[3]||(_[3]=1),_}if(r=t.match(wr)){for(var x=r.slice(1,4),j=0;j<=1;j++)x[j].endsWith("%")?(x[j]=.01*Number(x[j].replace("%","")),1===j&&(x[j]*=.4)):x[j]=Number(x[j]);var F=sr(x).map((function(t){return Mr(Nr(t))}));return F[3]=Number(r[4]),F[3]||0===F[3]||(F[3]=1),F}};_r.test=function(t){return fr.test(t)||pr.test(t)||gr.test(t)||br.test(t)||dr.test(t)||vr.test(t)||mr.test(t)||yr.test(t)||kr.test(t)||wr.test(t)};var xr=y,jr=v,Fr=h,Ar=s.type,Er=Ct,$r=_r;jr.prototype.css=function(t){return Er(this._rgb,t)},xr.css=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(jr,[null].concat(t,["css"])))},Fr.format.css=$r,Fr.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"===Ar(t)&&$r.test(t))return"css"}});var Dr=s.unpack,Cr=s.last,Ir=Math.round,Or=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=Dr(t,"rgba"),e=n[0],a=n[1],o=n[2],u=n[3],i=Cr(t)||"auto";void 0===u&&(u=1),"auto"===i&&(i=u<1?"rgba":"rgb");var l="000000"+((e=Ir(e))<<16|(a=Ir(a))<<8|(o=Ir(o))).toString(16);l=l.substring(l.length-6);var c="0"+Ir(255*u).toString(16);switch(c=c.substring(c.length-2),i.toLowerCase()){case"rgba":return"#"+l+c;case"argb":return"#"+c+l;default:return"#"+l}},Rr=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,Sr=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,Gr=function(t){if(t.match(Rr)){4!==t.length&&7!==t.length||(t=t.substring(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(Sr)){5!==t.length&&9!==t.length||(t=t.substring(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)},Lr=y,Pr=v,Tr=s.type,Zr=h,Wr=Or;Pr.prototype.hex=function(t){return Wr(this._rgb,t)},Lr.hex=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(Pr,[null].concat(t,["hex"])))},Zr.format.hex=Gr,Zr.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"===Tr(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}});var Xr=s.unpack,Yr=s.type,qr=y,Hr=v,Kr=h,Br=j;Hr.prototype.hsl=function(){return Br(this._rgb)},qr.hsl=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(Hr,[null].concat(t,["hsl"])))},Kr.format.hsl=Rt,Kr.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if(t=Xr(t,"hsl"),"array"===Yr(t)&&3===t.length)return"hsl"}});var Ur=s.unpack,zr=s.type,Jr=y,Qr=v,Vr=h,tn=L;Qr.prototype.lab=function(){return tn(this._rgb)},Jr.lab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(Qr,[null].concat(t,["lab"])))},Vr.format.lab=Zt,Vr.autodetect.push({p:2,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if(t=Ur(t,"lab"),"array"===zr(t)&&3===t.length)return"lab"}});var rn=s.unpack,nn=s.type,en=y,an=v,on=h,un=lt;an.prototype.oklab=function(){return un(this._rgb)},en.oklab=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(an,[null].concat(t,["oklab"])))},on.format.oklab=tr,on.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if(t=rn(t,"oklab"),"array"===nn(t)&&3===t.length)return"oklab"}});var ln=y,cn=v,sn=h,hn=s.unpack,fn=s.type,pn=Math.round;cn.prototype.rgb=function(t){return void 0===t&&(t=!0),!1===t?this._rgb.slice(0,3):this._rgb.slice(0,3).map(pn)},cn.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:pn(r):r}))},ln.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(cn,[null].concat(t,["rgb"])))},sn.format.rgb=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=hn(t,"rgba");return void 0===n[3]&&(n[3]=1),n},sn.autodetect.push({p:3,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if(t=hn(t,"rgba"),"array"===fn(t)&&(3===t.length||4===t.length&&"number"==fn(t[3])&&t[3]>=0&&t[3]<=1))return"rgb"}});var gn=s.unpack,bn=s.last,dn=Math.round,vn=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];var n=gn(t,"rgba"),e=(1!==n[3]?bn(t):"rgb")||"rgb";return n[0]=dn(n[0]),n[1]=dn(n[1]),n[2]=dn(n[2]),("rgba"===e||n.length>3&&n[3]<1&&"rgb"!==bn(t))&&(n[3]=n.length>3?n[3]:1,e="rgba"),"rgba"===e?n[3]<<24|n[0]<<16|n[1]<<8|n[2]:4278190080|n[0]<<16|n[1]<<8|n[2]},mn=s.type,yn=function(t){if("number"==mn(t)){var r=(t>>24&255)/255;if(r>=0&&r<=1){var n=t-4278190080;return[n>>16&255,n>>8&255,255&n,r]}}throw new Error("unknown android color: "+t)},kn=y,wn=v,Nn=h,Mn=s.type,_n=vn;wn.prototype.android=function(t){return _n(this._rgb,t)},kn.android=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];return new(Function.prototype.bind.apply(wn,[null].concat(t,["android"])))},Nn.format.android=yn,Nn.autodetect.push({p:5,test:function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];if(1===t.length&&"number"===Mn(t[0])){var n=(t[0]>>24&255)/255;if(n>=0&&n<=1){var e=t[0]-4278190080;if([e>>16&255,e>>8&255,255&e].every((function(t){return t>=0&&t<=255})))return"android"}}}});var xn=v,jn=s.type;xn.prototype.alpha=function(t,r){return void 0===r&&(r=!1),void 0!==t&&"number"===jn(t)?r?(this._rgb[3]=t,this):new xn([this._rgb[0],this._rgb[1],this._rgb[2],t],"rgb"):this._rgb[3]};var Fn=v,An=D;Fn.prototype.darken=function(t){void 0===t&&(t=1);var r=this.lab();return r[0]-=An.Kn*t,new Fn(r,"lab").alpha(this.alpha(),!0)},Fn.prototype.brighten=function(t){return void 0===t&&(t=1),this.darken(-t)},Fn.prototype.darker=Fn.prototype.darken,Fn.prototype.brighter=Fn.prototype.brighten,v.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.substring(0,2)?2:0);if(o>-1)return a[o];throw new Error("unknown channel "+e+" in mode "+n)}return a};var En={},$n=v,Dn=s.type,Cn=En,In=function(t,r,n){void 0===n&&(n=.5);for(var e=[],a=arguments.length-3;a-- >0;)e[a]=arguments[a+3];var o=e[0]||"lrgb";if(Cn[o]||e.length||(o=Object.keys(Cn)[0]),!Cn[o])throw new Error("interpolation mode "+o+" is not defined");return"object"!==Dn(t)&&(t=new $n(t)),"object"!==Dn(r)&&(r=new $n(r)),Cn[o](t,r,n).alpha(t.alpha()+n*(r.alpha()-t.alpha()))},On=v,Rn=In;On.prototype.mix=On.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 Rn.apply(void 0,[this,t,r].concat(n))};var Sn=v,Gn=s.type;Sn.prototype.set=function(t,r,n){void 0===n&&(n=!1);var e=t.split("."),a=e[0],o=e[1],u=this[a]();if(o){var i=a.indexOf(o)-("ok"===a.substring(0,2)?2:0);if(i>-1){if("string"==Gn(r))switch(r.charAt(0)){case"+":case"-":u[i]+=+r;break;case"*":u[i]*=+r.substring(1);break;case"/":u[i]/=+r.substring(1);break;default:u[i]=+r}else{if("number"!==Gn(r))throw new Error("unsupported value for Color.set");u[i]=r}var l=new Sn(u,a);return n?(this._rgb=l._rgb,this):l}throw new Error("unknown channel "+o+" in mode "+a)}return u};var Ln=v,Pn=Math.sqrt,Tn=Math.pow;En.lrgb=function(t,r,n){var e=t._rgb,a=e[0],o=e[1],u=e[2],i=r._rgb,l=i[0],c=i[1],s=i[2];return new Ln(Pn(Tn(a,2)*(1-n)+Tn(l,2)*n),Pn(Tn(o,2)*(1-n)+Tn(c,2)*n),Pn(Tn(u,2)*(1-n)+Tn(s,2)*n),"rgb")};var Zn=v;En.oklab=function(t,r,n){var e=t.oklab(),a=r.oklab();return new Zn(e[0]+n*(a[0]-e[0]),e[1]+n*(a[1]-e[1]),e[2]+n*(a[2]-e[2]),"oklab")};var Wn=v,Xn=y,Yn=y;return Yn.mix=Yn.interpolate=In,Yn.valid=function(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];try{return new(Function.prototype.bind.apply(Wn,[null].concat(t))),!0}catch(t){return!1}},Yn.noHueAsZero=function(t){return void 0===t&&(t=!1),Xn.hueNaN=!t,!Xn.hueNaN},Yn}));