@phun-ky/moebius 2.0.22 → 2.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/moebius.js CHANGED
@@ -2,7 +2,7 @@
2
2
  * @phun-ky/moebius
3
3
  * @phun-ky/moebius is a versatile JavaScript library that automatically generates visually pleasing and customizable color palettes from a given base color. Whether you're building data visualizations, UIs, or design systems, Möbius offers various harmony modes (analogous, complementary, triadic, and more), smooth interpolation, luminance shifts, and diverging palette generation - all with extensive color format support and intuitive API design.
4
4
  * @author Alexander Vassbotn Røyne-Helgesen <alexander+github.com@phun-ky.net>
5
- * @version 2.0.22
5
+ * @version 2.0.24
6
6
  * @license
7
7
  * Copyright (c) 2023 Alexander Vassbotn Røyne-Helgesen
8
8
  *
@@ -28,7 +28,7 @@
28
28
  * @phun-ky/typeof
29
29
  * A set of JavaScript helper functions to check for types
30
30
  * @author Alexander Vassbotn Røyne-Helgesen <alexander@phun-ky.net>
31
- * @version 1.2.27
31
+ * @version 2.0.1
32
32
  * @license
33
33
  * Copyright (c) 2024 Alexander Vassbotn Røyne-Helgesen
34
34
  *
@@ -64,5 +64,5 @@ const{min:t,max:e}=Math;var r=(r,n=0,o=1)=>t(e(n,r),o),n=t=>{t._clipped=!1,t._un
64
64
  * You can read more about the APCA Readability Criterion at
65
65
  * https://readtech.org/ARC/
66
66
  */
67
- const Gt=.022;function Dt(t,e,r){return.2126729*Math.pow(t/255,2.4)+.7151522*Math.pow(e/255,2.4)+.072175*Math.pow(r/255,2.4)}const{sqrt:Yt,pow:qt,min:It,max:Xt,atan2:Zt,abs:Kt,cos:Wt,sin:Ut,exp:Vt,PI:Tt}=Math;var Ht={cool:()=>Mt([x.hsl(180,1,.9),x.hsl(250,.7,.4)]),hot:()=>Mt(["#000","#f00","#ff0","#fff"]).mode("rgb")};const Jt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Qt=Object.keys(Jt),te=new Map(Qt.map((t=>[t.toLowerCase(),t]))),ee="function"==typeof Proxy?new Proxy(Jt,{get(t,e){const r=e.toLowerCase();if(te.has(r))return t[te.get(r)]},getOwnPropertyNames:()=>Object.getOwnPropertyNames(Qt)}):Jt,{max:re}=Math;y.prototype.cmyk=function(){return((...t)=>{let[e,r,n]=a(t,"rgb");e/=255,r/=255,n/=255;const o=1-re(e,re(r,n)),s=o<1?1/(1-o):0;return[(1-e-o)*s,(1-r-o)*s,(1-n-o)*s,o]})(this._rgb)};Object.assign(x,{cmyk:(...t)=>new y(...t,"cmyk")}),w.format.cmyk=(...t)=>{t=a(t,"cmyk");const[e,r,n,o]=t,s=t.length>4?t[4]:1;return 1===o?[0,0,0,s]:[e>=1?0:255*(1-e)*(1-o),r>=1?0:255*(1-r)*(1-o),n>=1?0:255*(1-n)*(1-o),s]},w.autodetect.push({p:2,test:(...t)=>{if("array"===s(t=a(t,"cmyk"))&&4===t.length)return"cmyk"}});const ne=(...t)=>{const[e,r,n,...o]=a(t,"rgb"),[s,c,i]=dt(e,r,n),[l,h,f]=T(s,c,i);return[l,h,f,...o.length>0&&o[0]<1?[o[0]]:[]]},{round:oe}=Math,se=(...t)=>{const e=a(t,"rgba");let r=c(t)||"rgb";if("hsl"===r.substr(0,3))return((...t)=>{const e=a(t,"hsla");let r=c(t)||"lsa";return e[0]=f(e[0]||0)+"deg",e[1]=f(100*e[1])+"%",e[2]=f(100*e[2])+"%","hsla"===r||e.length>3&&e[3]<1?(e[3]="/ "+(e.length>3?e[3]:1),r="hsla"):e.length=3,`${r.substr(0,3)}(${e.join(" ")})`})(it(e),r);if("lab"===r.substr(0,3)){const t=F();O("d50");const n=((...t)=>{const e=a(t,"lab");let r=c(t)||"lab";return e[0]=f(e[0])+"%",e[1]=f(e[1]),e[2]=f(e[2]),"laba"===r||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lab(${e.join(" ")})`})(R(e),r);return O(t),n}if("lch"===r.substr(0,3)){const t=F();O("d50");const n=((...t)=>{const e=a(t,"lch");let r=c(t)||"lab";return e[0]=f(e[0])+"%",e[1]=f(e[1]),e[2]=isNaN(e[2])?"none":f(e[2])+"deg","lcha"===r||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lch(${e.join(" ")})`})(H(e),r);return O(t),n}return"oklab"===r.substr(0,5)?((...t)=>{const e=a(t,"lab");return e[0]=f(100*e[0])+"%",e[1]=u(e[1]),e[2]=u(e[2]),e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklab(${e.join(" ")})`})(dt(e)):"oklch"===r.substr(0,5)?((...t)=>{const e=a(t,"lch");return e[0]=f(100*e[0])+"%",e[1]=u(e[1]),e[2]=isNaN(e[2])?"none":f(e[2])+"deg",e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklch(${e.join(" ")})`})(ne(e)):(e[0]=oe(e[0]),e[1]=oe(e[1]),e[2]=oe(e[2]),("rgba"===r||e.length>3&&e[3]<1)&&(e[3]="/ "+(e.length>3?e[3]:1),r="rgba"),`${r.substr(0,3)}(${e.slice(0,"rgb"===r?3:4).join(" ")})`)},ae=(...t)=>{t=a(t,"lch");const[e,r,n,...o]=t,[s,c,i]=Z(e,r,n),[l,h,f]=bt(s,c,i);return[l,h,f,...o.length>0&&o[0]<1?[o[0]]:[]]},ce=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,ie=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,le=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,he=/\s*/.source,fe=/\s+/.source,ue=/\s*,\s*/.source,be=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,de=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,me=new RegExp("^rgba?\\("+he+[ce,ce,ce].join(fe)+de+"\\)$"),ge=new RegExp("^rgb\\("+he+[ce,ce,ce].join(ue)+he+"\\)$"),pe=new RegExp("^rgba\\("+he+[ce,ce,ce,ie].join(ue)+he+"\\)$"),we=new RegExp("^hsla?\\("+he+[be,le,le].join(fe)+de+"\\)$"),ye=new RegExp("^hsl?\\("+he+[be,le,le].join(ue)+he+"\\)$"),xe=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ke=new RegExp("^lab\\("+he+[ie,ie,ie].join(fe)+de+"\\)$"),Ne=new RegExp("^lch\\("+he+[ie,ie,be].join(fe)+de+"\\)$"),Me=new RegExp("^oklab\\("+he+[ie,ie,ie].join(fe)+de+"\\)$"),ve=new RegExp("^oklch\\("+he+[ie,ie,be].join(fe)+de+"\\)$"),{round:$e}=Math,Se=t=>t.map(((t,e)=>e<=2?r($e(t),0,255):t)),Ae=(t,e=0,r=100,n=!1)=>("string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=n?e+.5*(t+1)*(r-e):e+t*(r-e)),+t),Ce=(t,e)=>"none"===t?e:t,Oe=t=>{if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];let e;if(w.format.named)try{return w.format.named(t)}catch(t){}if((e=t.match(me))||(e=t.match(ge))){let t=e.slice(1,4);for(let e=0;e<3;e++)t[e]=+Ae(Ce(t[e],0),0,255);t=Se(t);const r=void 0!==e[4]?+Ae(e[4],0,1):1;return t[3]=r,t}if(e=t.match(pe)){const t=e.slice(1,5);for(let e=0;e<4;e++)t[e]=+Ae(t[e],0,255);return t}if((e=t.match(we))||(e=t.match(ye))){const t=e.slice(1,4);t[0]=+Ce(t[0].replace("deg",""),0),t[1]=.01*+Ae(Ce(t[1],0),0,100),t[2]=.01*+Ae(Ce(t[2],0),0,100);const r=Se(ct(t)),n=void 0!==e[4]?+Ae(e[4],0,1):1;return r[3]=n,r}if(e=t.match(xe)){const t=e.slice(1,4);t[1]*=.01,t[2]*=.01;const r=ct(t);for(let t=0;t<3;t++)r[t]=$e(r[t]);return r[3]=+e[4],r}if(e=t.match(ke)){const t=e.slice(1,4);t[0]=Ae(Ce(t[0],0),0,100),t[1]=Ae(Ce(t[1],0),-125,125,!0),t[2]=Ae(Ce(t[2],0),-125,125,!0);const r=F();O("d50");const n=Se(L(t));O(r);const o=void 0!==e[4]?+Ae(e[4],0,1):1;return n[3]=o,n}if(e=t.match(Ne)){const t=e.slice(1,4);t[0]=Ae(t[0],0,100),t[1]=Ae(Ce(t[1],0),0,150,!1),t[2]=+Ce(t[2].replace("deg",""),0);const r=F();O("d50");const n=Se(K(t));O(r);const o=void 0!==e[4]?+Ae(e[4],0,1):1;return n[3]=o,n}if(e=t.match(Me)){const t=e.slice(1,4);t[0]=Ae(Ce(t[0],0),0,1),t[1]=Ae(Ce(t[1],0),-.4,.4,!0),t[2]=Ae(Ce(t[2],0),-.4,.4,!0);const r=Se(bt(t)),n=void 0!==e[4]?+Ae(e[4],0,1):1;return r[3]=n,r}if(e=t.match(ve)){const t=e.slice(1,4);t[0]=Ae(Ce(t[0],0),0,1),t[1]=Ae(Ce(t[1],0),0,.4,!1),t[2]=+Ce(t[2].replace("deg",""),0);const r=Se(ae(t)),n=void 0!==e[4]?+Ae(e[4],0,1):1;return r[3]=n,r}};Oe.test=t=>me.test(t)||we.test(t)||ke.test(t)||Ne.test(t)||Me.test(t)||ve.test(t)||ge.test(t)||pe.test(t)||ye.test(t)||xe.test(t)||"transparent"===t,y.prototype.css=function(t){return se(this._rgb,t)};x.css=(...t)=>new y(...t,"css"),w.format.css=Oe,w.autodetect.push({p:5,test:(t,...e)=>{if(!e.length&&"string"===s(t)&&Oe.test(t))return"css"}}),w.format.gl=(...t)=>{const e=a(t,"rgba");return e[0]*=255,e[1]*=255,e[2]*=255,e};x.gl=(...t)=>new y(...t,"gl"),y.prototype.gl=function(){const t=this._rgb;return[t[0]/255,t[1]/255,t[2]/255,t[3]]},y.prototype.hex=function(t){return S(this._rgb,t)};x.hex=(...t)=>new y(...t,"hex"),w.format.hex=v,w.autodetect.push({p:4,test:(t,...e)=>{if(!e.length&&"string"===s(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}});const{log:Fe}=Math,Le=t=>{const e=t/100;let r,n,o;return e<66?(r=255,n=e<6?0:-155.25485562709179-.44596950469579133*(n=e-2)+104.49216199393888*Fe(n),o=e<20?0:.8274096064007395*(o=e-10)-254.76935184120902+115.67994401066147*Fe(o)):(r=351.97690566805693+.114206453784165*(r=e-55)-40.25366309332127*Fe(r),n=325.4494125711974+.07943456536662342*(n=e-50)-28.0852963507957*Fe(n),o=255),[r,n,o,1]},{round:_e}=Math;y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return((...t)=>{const e=a(t,"rgb"),r=e[0],n=e[2];let o,s=1e3,c=4e4;for(;c-s>.4;){o=.5*(c+s);const t=Le(o);t[2]/t[0]>=n/r?c=o:s=o}return _e(o)})(this._rgb)};const Ee=(...t)=>new y(...t,"temp");Object.assign(x,{temp:Ee,kelvin:Ee,temperature:Ee}),w.format.temp=w.format.kelvin=w.format.temperature=Le,y.prototype.oklch=function(){return ne(this._rgb)};function je(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(x,{oklch:(...t)=>new y(...t,"oklch")}),w.format.oklch=ae,w.autodetect.push({p:2,test:(...t)=>{if("array"===s(t=a(t,"oklch"))&&3===t.length)return"oklch"}}),Object.assign(x,{analyze:zt,average:(t,e="lrgb",r=null)=>{const n=t.length;r||(r=Array.from(new Array(n)).map((()=>1)));const o=n/r.reduce((function(t,e){return t+e}));if(r.forEach(((t,e)=>{r[e]*=o})),t=t.map((t=>new y(t))),"lrgb"===e)return kt(t,r);const s=t.shift(),a=s.get(e),c=[];let i=0,l=0;for(let t=0;t<a.length;t++)if(a[t]=(a[t]||0)*r[0],c.push(isNaN(a[t])?0:r[0]),"h"===e.charAt(t)&&!isNaN(a[t])){const e=a[t]/180*pt;i+=wt(e)*r[0],l+=yt(e)*r[0]}let h=s.alpha()*r[0];t.forEach(((t,n)=>{const o=t.get(e);h+=t.alpha()*r[n+1];for(let t=0;t<a.length;t++)if(!isNaN(o[t]))if(c[t]+=r[n+1],"h"===e.charAt(t)){const e=o[t]/180*pt;i+=wt(e)*r[n+1],l+=yt(e)*r[n+1]}else a[t]+=o[t]*r[n+1]}));for(let t=0;t<a.length;t++)if("h"===e.charAt(t)){let e=xt(l/c[t],i/c[t])/pt*180;for(;e<0;)e+=360;for(;e>=360;)e-=360;a[t]=e}else a[t]=a[t]/c[t];return h/=n,new y(a,e).alpha(h>.99999?1:h,!0)},bezier:t=>{const e=function(t){let e,r,n,o;if(2===(t=t.map((t=>new y(t)))).length)[r,n]=t.map((t=>t.lab())),e=function(t){const e=[0,1,2].map((e=>r[e]+t*(n[e]-r[e])));return new y(e,"lab")};else if(3===t.length)[r,n,o]=t.map((t=>t.lab())),e=function(t){const e=[0,1,2].map((e=>(1-t)*(1-t)*r[e]+2*(1-t)*t*n[e]+t*t*o[e]));return new y(e,"lab")};else if(4===t.length){let s;[r,n,o,s]=t.map((t=>t.lab())),e=function(t){const e=[0,1,2].map((e=>(1-t)*(1-t)*(1-t)*r[e]+3*(1-t)*(1-t)*t*n[e]+3*(1-t)*t*t*o[e]+t*t*t*s[e]));return new y(e,"lab")}}else{if(!(t.length>=5))throw new RangeError("No point in running bezier with only one color.");{let r,n,o;r=t.map((t=>t.lab())),o=t.length-1,n=function(t){let e=[1,1];for(let r=1;r<t;r++){let t=[1];for(let r=1;r<=e.length;r++)t[r]=(e[r]||0)+e[r-1];e=t}return e}(o),e=function(t){const e=1-t,s=[0,1,2].map((s=>r.reduce(((r,a,c)=>r+n[c]*e**(o-c)*t**c*a[s]),0)));return new y(s,"lab")}}}return e}(t);return e.scale=()=>Mt(e),e},blend:$t,brewer:ee,Color:y,colors:k,contrast:(t,e)=>{t=new y(t),e=new y(e);const r=t.luminance(),n=e.luminance();return r>n?(r+.05)/(n+.05):(n+.05)/(r+.05)},contrastAPCA:(t,e)=>{t=new y(t),e=new y(e),t.alpha()<1&&(t=q(e,t,t.alpha(),"rgb"));const r=Dt(...t.rgb()),n=Dt(...e.rgb()),o=r>=Gt?r:r+Math.pow(Gt-r,1.414),s=n>=Gt?n:n+Math.pow(Gt-n,1.414),a=Math.pow(s,.56)-Math.pow(o,.57),c=Math.pow(s,.65)-Math.pow(o,.62),i=Math.abs(s-o)<5e-4?0:o<s?1.14*a:1.14*c;return 100*(Math.abs(i)<.1?0:i>0?i-.027:i+.027)},cubehelix:function(t=300,e=-1.5,r=1,o=1,a=[0,1]){let c,i=0;"array"===s(a)?c=a[1]-a[0]:(c=0,a=[a,a]);const l=function(s){const l=b*((t+120)/360+e*s),h=Ct(a[0]+c*s,o),f=(0!==i?r[0]+s*i:r)*h*(1-h)/2,u=Ft(l),d=Ot(l);return x(n([255*(h+f*(-.14861*u+1.78277*d)),255*(h+f*(-.29227*u-.90649*d)),255*(h+f*(1.97294*u)),1]))};return l.start=function(e){return null==e?t:(t=e,l)},l.rotations=function(t){return null==t?e:(e=t,l)},l.gamma=function(t){return null==t?o:(o=t,l)},l.hue=function(t){return null==t?r:("array"===s(r=t)?(i=r[1]-r[0],0===i&&(r=r[1])):i=0,l)},l.lightness=function(t){return null==t?a:("array"===s(t)?(a=t,c=t[1]-t[0]):(a=[t,t],c=0),l)},l.scale=()=>x.scale(l),l.hue(r),l},deltaE:function(t,e,r=1,n=1,o=1){var s=function(t){return 360*t/(2*Tt)},a=function(t){return 2*Tt*t/360};t=new y(t),e=new y(e);const[c,i,l]=Array.from(t.lab()),[h,f,u]=Array.from(e.lab()),b=(c+h)/2,d=(Yt(qt(i,2)+qt(l,2))+Yt(qt(f,2)+qt(u,2)))/2,m=.5*(1-Yt(qt(d,7)/(qt(d,7)+qt(25,7)))),g=i*(1+m),p=f*(1+m),w=Yt(qt(g,2)+qt(l,2)),x=Yt(qt(p,2)+qt(u,2)),k=(w+x)/2,N=s(Zt(l,g)),M=s(Zt(u,p)),v=N>=0?N:N+360,$=M>=0?M:M+360,S=Kt(v-$)>180?(v+$+360)/2:(v+$)/2,A=1-.17*Wt(a(S-30))+.24*Wt(a(2*S))+.32*Wt(a(3*S+6))-.2*Wt(a(4*S-63));let C=$-v;C=Kt(C)<=180?C:$<=v?C+360:C-360,C=2*Yt(w*x)*Ut(a(C)/2);const O=h-c,F=x-w,L=1+.015*qt(b-50,2)/Yt(20+qt(b-50,2)),_=1+.045*k,E=1+.015*k*A,j=30*Vt(-qt((S-275)/25,2)),R=-(2*Yt(qt(k,7)/(qt(k,7)+qt(25,7))))*Ut(2*a(j)),P=Yt(qt(O/(r*L),2)+qt(F/(n*_),2)+qt(C/(o*E),2)+R*(F/(n*_))*(C/(o*E)));return Xt(0,It(100,P))},distance:function(t,e,r="lab"){t=new y(t),e=new y(e);const n=t.get(r),o=e.get(r);let s=0;for(let t in n){const e=(n[t]||0)-(o[t]||0);s+=e*e}return Math.sqrt(s)},input:w,interpolate:q,limits:Bt,mix:q,random:()=>{let t="#";for(let e=0;e<6;e++)t+="0123456789abcdef".charAt(Lt(16*_t()));return new y(t,"hex")},scale:Mt,scales:Ht,valid:(...t)=>{try{return new y(...t),!0}catch(t){return!1}}});var Re,Pe={exports:{}};var ze,Be=(Re||(Re=1,ze=Pe,function(t){function e(t,r){if(!(t=n(t)))return null;var o,s,a,c=1/0;r||(r=e.DEFAULT_COLORS);for(var i=0;i<r.length;++i)s=r[i].rgb,(o=Math.pow(t.r-s.r,2)+Math.pow(t.g-s.g,2)+Math.pow(t.b-s.b,2))<c&&(c=o,a=r[i]);return a.name?{name:a.name,value:a.source,rgb:a.rgb,distance:Math.sqrt(c)}:a.source}function r(t){return t instanceof Array?t.map((function(t){return o(t)})):Object.keys(t).map((function(e){return o(t[e],e)}))}function n(t){if("object"==typeof t)return t;if(t in e.STANDARD_COLORS)return n(e.STANDARD_COLORS[t]);var r=t.match(/^#?((?:[0-9a-f]{3}){1,2})$/i);if(r)return r=3===(r=r[1]).length?[r.charAt(0)+r.charAt(0),r.charAt(1)+r.charAt(1),r.charAt(2)+r.charAt(2)]:[r.substring(0,2),r.substring(2,4),r.substring(4,6)],{r:parseInt(r[0],16),g:parseInt(r[1],16),b:parseInt(r[2],16)};var o=t.match(/^rgb\(\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?)\s*\)$/i);if(o)return{r:s(o[1]),g:s(o[2]),b:s(o[3])};throw Error('"'+t+'" is not a valid color')}function o(t,e){var r={};if(e&&(r.name=e),"string"==typeof t)r.source=t,r.rgb=n(t);else if("object"==typeof t){if(t.source)return o(t.source,t.name);r.rgb=t,r.source=function(t){return"#"+a(t.r.toString(16))+a(t.g.toString(16))+a(t.b.toString(16))}(t)}return r}function s(t){return"%"===t.charAt(t.length-1)?Math.round(255*parseInt(t,10)/100):Number(t)}function a(t){return 1===t.length&&(t="0"+t),t}e.from=function t(n){var o=r(n),s=e,a=function(t){return s(t,o)};return a.from=t,a.or=function(t){var n=o.concat(r(t));return e.from(n)},a},e.STANDARD_COLORS={aqua:"#0ff",black:"#000",blue:"#00f",fuchsia:"#f0f",gray:"#808080",green:"#008000",lime:"#0f0",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#ffa500",purple:"#800080",red:"#f00",silver:"#c0c0c0",teal:"#008080",white:"#fff",yellow:"#ff0"},e.DEFAULT_COLORS=r(["#f00","#f80","#ff0","#0f0","#00f","#008","#808"]),e.VERSION="0.4.4",ze&&ze.exports?ze.exports=e:t.nearestColor=e}(Pe.exports)),Pe.exports),Ge=je(Be);class De{h;s;l;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(0)),this.s=Number((100*e).toFixed(0)),this.l=Number((100*r).toFixed(0))}toString(){return`hsl(${this.h}, ${this.s}%, ${this.l}%)`}}class Ye{h;s;l;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(0)),this.s=Number(e.toFixed(2)),this.l=Number(r.toFixed(2))}toString(){return`${this.h}, ${this.s}, ${this.l}`}}class qe{x;y;z;constructor({x:t,y:e,z:r}){this.x=t,this.y=e,this.z=r}toString(){return`${this.x}, ${this.y}, ${this.z}`}}class Ie{c;m;y;k;constructor({c:t,m:e,y:r,k:n}){this.c=t,this.m=e,this.y=r,this.k=n}toString(){return`${this.c}, ${this.m}, ${this.y}, ${this.k}`}}class Xe{r;g;b;constructor({r:t,g:e,b:r}){this.r=t,this.g=e,this.b=r}toString(){return`${this.r}, ${this.g}, ${this.b}`}}class Ze{h;w;b;constructor({h:t,w:e,b:r}){this.h=t,this.w=e,this.b=r}toString(){return`${this.h}, ${this.w}, ${this.b}`}}class Ke{l;a;b;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.a=Number(e.toFixed(2)),this.b=Number(r.toFixed(2))}toString(){return`${this.l}, ${this.a}, ${this.b}`}}class We{l;a;b;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.a=Number(e.toFixed(2)),this.b=Number(r.toFixed(2))}toString(){return`${this.l}, ${this.a}, ${this.b}`}}class Ue{h;s;v;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(2)),this.s=Number(e.toFixed(2)),this.v=Number(r.toFixed(2))}toString(){return`${this.h}, ${this.s}, ${this.v}`}}class Ve{l;c;h;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.c=Number(e.toFixed(2)),this.h=Number(isNaN(r)?"0":r.toFixed(2))}toString(){return`${this.l}, ${this.c}, ${this.h}`}}class Te{l;c;h;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.c=Number(e.toFixed(2)),this.h=Number(isNaN(r)?"0":r.toFixed(2))}toString(){return`${this.l}, ${this.c}, ${this.h}`}}class He{h;s;i;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(2)),this.s=Number(e.toFixed(2)),this.i=Number(r.toFixed(2))}toString(){return`${this.h}, ${this.s}, ${this.i}`}}const Je=(t,e)=>{if("hsl"===e)return new Ye(x(t).hsl());const r=x(t).rgb();return new Xe({r:Number((r[0]/255).toFixed(2)),g:Number((r[1]/255).toFixed(2)),b:Number((r[2]/255).toFixed(2))})},Qe=t=>(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4),tr=t=>t>.008856452?Math.pow(t,1/3):t/.12841855+.137931034;class er{color;name;hex;rgb;hsl;hwb;hsv;lab;xyz;lch;oklch;hsi;oklab;cmyk;rgbFloat;hslFloat;constructor(t,e){this.color=t,this.name=e,this.hex=(t=>x(t).hex())(this.color),this.cmyk=(t=>{let[e,r,n]=x(t).rgb();e/=255,n/=255,r/=255;const o=+(1-Math.max(e,n,r)),s=+((1-n-o)/(1-o)||0),a=+((1-r-o)/(1-o)||0);return new Ie({c:Number((100*+((1-e-o)/(1-o)||0)).toFixed()),m:Number((100*s).toFixed()),y:Number((100*a).toFixed()),k:Number((100*o).toFixed())})})(this.color),this.xyz=(t=>{let[e,r,n]=x(t).rgb();e=Qe(e),n=Qe(n),r=Qe(r);const o=tr((.4124564*e+.3575761*n+.1804375*r)/.95047),s=tr((.2126729*e+.7151522*n+.072175*r)/1),a=tr((.0193339*e+.119192*n+.9503041*r)/1.08883);return new qe({x:Number(o.toFixed(2)),y:Number(s.toFixed(2)),z:Number(a.toFixed(2))})})(this.color),this.hsl=(t=>new De(x(t).hsl()))(this.color),this.hwb=(t=>{let[e,r,n]=x(t).rgb();e/=255,n/=255,r/=255;const o=Math.min(e,n,r),s=Math.max(e,n,r),a=1-s;return s===o?{h:0,w:o,b:a}:new Ze({h:Number((((e===o?3:n===o?5:1)-(e===o?n-r:n===o?r-e:e-n)/(s-o))/6).toFixed(2)),w:Number(o.toFixed(2)),b:Number(a.toFixed(2))})})(this.color),this.lab=(t=>new Ke(x(t).lab()))(this.color),this.oklab=(t=>new We(x(t).oklab()))(this.color),this.hsv=(t=>new Ue(x(t).hsv()))(this.color),this.lch=(t=>new Ve(x(t).lch()))(this.color),this.oklch=(t=>new Te(x(t).oklch()))(this.color),this.hsi=(t=>new He(x(t).hsi()))(this.color),this.rgb=(t=>{const[e,r,n]=x(t).rgb();return`rgb(${e}, ${r}, ${n})`})(this.color),this.rgbFloat=Je(this.color),this.hslFloat=Je(this.color,"hsl")}toObject(t){return((t,e)=>{if("hsl"===e){const[e,r,n]=x(t).hsl();return{h:Number(isNaN(e)?0:e.toFixed(0)),s:Number((100*r).toFixed()),l:Number((100*n).toFixed())}}const r=x(t).rgb();return{r:r[0],g:r[1],b:r[2]}})(this.color,t)}toFloat(t){return Je(this.color,t)}}const rr={diverging:!1,bezier:!1,randomOffset:!1,correctLightness:!1,noDuplicates:!0,colorScaleMode:"lch",reverseDirection:!1},nr=(t,e,r,n,o={})=>{const{noDuplicates:s=!0}=o,a=[x(t).hex()];let[c,i,l]=x(t).hsl();isNaN(c)&&(c=0),i=Number((100*i).toFixed()),l=Number((100*l).toFixed());for(let t=e;t<=r;t+=n){const e=Number(((c+t)%360).toFixed());a.push(x(`hsl(${e}, ${i}%, ${l}%)`).hex())}let h=a;return s&&(h=[...new Set(a)]),h},or=(t,e)=>Math.floor(Math.random()*(t-e+1))+e,sr=(t,e={})=>{const{numberOfColors:r=8,bezier:n=!1,randomOffset:o=!1,colorScaleMode:s,noDuplicates:a=!0,reverseDirection:c=!1,correctLightness:i=!0}=e;let[l,h,f]=x(t).hsl();isNaN(l)&&(l=0),l=Number(l.toFixed(0)),h=Number((100*h).toFixed(0)),f=Number((100*f).toFixed(0));const u=[];if(u.push(x(`hsl(${l}, ${h}%, ${f<0?0:f}%)`).hex()),o)for(let t=1;t<r;t++)c?(f+=or(0,10),l+=or(-5,5)):(f-=or(0,10),l-=or(-5,5)),l>359&&(l=359),l<0&&(l=0),u.push(x(`hsl(${l}, ${h}%, ${f<0?0:f}%)`).hex());else for(let t=1;t<r;t++)c?(f+=5,l+=5):(f-=5,l-=5),l>359&&(l=359),l<0&&(l=0),u.push(x(`hsl(${l}, ${h}%, ${f<0?0:f}%)`).hex());let b=u.map((t=>x(t).hex()));return a&&(b=[...new Set(b)]),n&&(b=b.length>1?x.bezier(b).scale().mode(s).correctLightness(i).colors(r):x.scale(b).mode(s).correctLightness(i).colors(r)),b},ar=(t,e={})=>{if(!t)throw Error("MoebiusPalettes: missing input `color`");const{diverging:r=!1,numberOfColors:n=7}=e,[o,s,a]=x(t).lab(),c=100*(.95-1/n),i=c/(n-1),l=.5*(100-c),h=((t,e,r)=>{const n=[];for(let o=t;o<e;o+=r)n.push(o);return n})(l,l+n*i,i);let f=0;if(!r){f=9999;for(let t=0;t<n;t++){const e=o-h[t];Math.abs(e)<Math.abs(f)&&(f=e)}}return h.map((t=>x.lab([t+f,s,a]).hex()))},cr=(t,e={})=>{const{numberOfColors:r,reverseDirection:n=!1,diverging:o=!1,divergentColor:s}=e;if(o){const e=ar(x(t).hex(),{numberOfColors:Math.ceil(r/2)}).concat(s);return n&&e.reverse(),e}return ar(t,{numberOfColors:r})},ir=(t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e;try{return x.bezier(t).scale().mode(n).correctLightness(o).colors(r)}catch{return[]}},lr=(t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e;try{return x.scale(t).mode(n).correctLightness(o).colors(r)}catch{return[]}};class hr{interpolate;luminanceShift;monochromatic;complement;split;triadic;tetradic;pentadic;hexadic;analogous;constructor(t,e){Object.keys(t).forEach((r=>{this[r]=t[r].map((t=>sr(t,{...e,numberOfColors:9})))}))}toArray(){return[...this.interpolate,...this.luminanceShift,...this.monochromatic,...this.complement,...this.split,...this.triadic,...this.tetradic,...this.pentadic,...this.hexadic,...this.analogous].flat()}}class fr{interpolate;luminanceShift;monochromatic;complement;split;triadic;tetradic;pentadic;hexadic;analogous;constructor(t){Object.keys(t).forEach((e=>{this[e]=t[e]}))}toArray(){return[...this.interpolate,...this.luminanceShift,...this.monochromatic,...this.complement,...this.split,...this.triadic,...this.tetradic,...this.pentadic,...this.hexadic,...this.analogous].flat()}}class ur{darkMode;constructor(t){Object.keys(t).forEach((e=>{this[e]=t[e]}))}}class br{baseColor;secondaryColor;colors={};themes={};defaultOptions={...rr,divergentColor:"#f5f5f5"};options;all=[];accents;constructor(t){this.options={...this.defaultOptions,...t},this.baseColor=this.options.baseColor,this.secondaryColor=this.options.secondaryColor,this.themes=new ur({darkMode:this.darkMode(this.baseColor.hex,this.secondaryColor.hex,{...this.options,reverseDirection:!this.options.reverseDirection})}),this.colors=new fr({interpolate:this.interpolate(this.baseColor.hex,this.secondaryColor.hex,this.options),luminanceShift:this.luminanceShift([this.baseColor.hex],[this.secondaryColor.hex],this.options),monochromatic:this.monochromatic(this.baseColor.hex),complement:this.complement(this.baseColor.hex),split:this.split(this.baseColor.hex),triadic:this.triadic(this.baseColor.hex),tetradic:this.tetradic(this.baseColor.hex),pentadic:this.pentadic(this.baseColor.hex),hexadic:this.hexadic(this.baseColor.hex),analogous:this.analogous(this.baseColor.hex)}),this.accents=new hr(this.colors,this.options),this.all=[...new Set([...this.accents.toArray(),...this.colors.toArray()].flat())]}complement(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,180,180,1);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}darkMode(t,e,r={}){return((t,e,r={})=>{const{bezier:n=!1,colorScaleMode:o,noDuplicates:s=!0}=r,a=sr(t,r),c=sr(e,r),i=c.map(((t,e)=>x.mix(a[e],t,.99-.02*e,o).hex())),l={primary:a,surface:c,mixed:i};return s&&(l.primary=[...new Set(a)],l.surface=[...new Set(c)],l.mixed=[...new Set(i)]),n&&(l.primary.length>1&&l.surface.length>1&&l.mixed.length>1?(l.primary=ir(l.primary,r),l.surface=ir(l.surface,r),l.mixed=ir(l.mixed,r)):(l.primary=lr(l.primary,r),l.surface=lr(l.surface,r),l.mixed=lr(l.mixed,r))),l})(t,e,{...this.options,...r})}split(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,150,210,60);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}triadic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,120,240,120);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}tetradic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,90,270,90);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}pentadic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,144,360,72);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}hexadic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,120,360,60);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}analogous(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,30,90,30);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}interpolate(t,e,r={}){return((t,e,r={})=>{const{numberOfColors:n=8,colorScaleMode:o,bezier:s=!1,correctLightness:a=!0}=r;let c=x.scale([t,e]).mode(o).correctLightness(a).colors(n);return s&&(c=x.bezier([t,e]).scale().mode(o).correctLightness(a).colors(n)),c})(t,e,{...this.options,...r})}luminanceShift(t,e=[],r={}){return((t,e=[],r={})=>{const{numberOfColors:n=8,diverging:o=!1,colorScaleMode:s,bezier:a=!1,divergentColor:c="#f5f5f5",correctLightness:i=!0}=r;e=0===e.length?[nr(t[0],90,270,90)[3]]:e;const l=n%2==0,h=o?Math.ceil(n/2)+(l?1:0):n,f=o?Math.ceil(n/2)+(l?1:0):0,u=1!==t.length?t:cr(t[0],{numberOfColors:h,divergentColor:c});let b=[];o&&(b=1!==e.length?e:cr(e[0],{numberOfColors:f,divergentColor:c,diverging:o}));let d=t.length?x.scale(u).mode(s).correctLightness(i).colors(h):[];a&&(d=t.length?x.bezier(u).scale().mode(s).correctLightness(i).colors(h):[]);let m=o&&e.length?x.scale(b).mode(s).correctLightness(i).colors(f):[];a&&(m=o&&e.length?x.bezier(b).scale().mode(s).correctLightness(i).colors(f):[]);let g=d;return g=(o?d.slice(0,d.length-(h%2!=0?0:1)):d).concat(m.reverse()),g})(t,e,{...this.options,...r})}monochromatic(t,e={}){const r={...this.options,...e};return sr(t,r)}harmonize(t,e,r,n,o={}){const s={...this.options,...o};return nr(t,e,r,n,s)}}class dr{xlmns="http://www.w3.org/2000/svg";getColorPiePaths(t,e=256){const r=document.createDocumentFragment(),n=document.createElementNS(this.xlmns,"defs"),o=document.createElementNS(this.xlmns,"mask"),s=document.createElementNS(this.xlmns,"rect"),a=document.createElementNS(this.xlmns,"g"),c=360/t.length,i="_"+Math.random().toString(36).substring(2,11);o.setAttributeNS(null,"id",i),s.setAttributeNS(null,"height","100%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"fill","white"),a.setAttributeNS(null,"mask",`url(#${i})`),o.appendChild(s);const l=360/t.length;var h,f;for(let e=(h=l/2,4===(f=t.length)||8===f||12===f?0:3===f||9===f?30:7===f?12:5===f?55:h);e<360;e+=l){const t=document.createElementNS(this.xlmns,"line");t.setAttributeNS(null,"x1","128"),t.setAttributeNS(null,"y1","128"),t.setAttributeNS(null,"x2","0"),t.setAttributeNS(null,"y2","128"),t.setAttributeNS(null,"stroke","black"),t.setAttributeNS(null,"stroke-width","6"),t.setAttributeNS(null,"transform",`rotate(${e} 128 128)`),o.appendChild(t)}let u=0;return t.forEach((t=>{const r=e/2/t.length;return u+=c,t.forEach(((t,n)=>{const o=e/2-n*r,s=document.createElementNS(this.xlmns,"path");s.setAttributeNS(null,"fill",t),s.setAttributeNS(null,"data-color-hex",t),s.setAttributeNS(null,"data-r",`${o}`),s.setAttributeNS(null,"d",((t,e,r,n=256)=>{const o=n/2,s=o;let a=t+e;if(t>a){const e=t;t=a,a=e}return`M ${o+r*Math.cos((90-t)*(Math.PI/180))} ${s+r*Math.sin((90-t)*(Math.PI/180))} A ${r} ${r} 0 ${a-t<=180?"0":"1"} 0 ${o+r*Math.cos((90-a)*(Math.PI/180))} ${s+r*Math.sin((90-a)*(Math.PI/180))} L ${o} ${s} Z`})(u,c,o)),a.appendChild(s)}))})),n.appendChild(o),r.appendChild(n),r.appendChild(a),r}}async function mr(){const t=await(async()=>{const t=await fetch("https://color-names.herokuapp.com/v1/"),e=(await t.json()).colors,r={};return e.forEach((t=>{r[t.name]=t.hex})),Ge.from(r)})();return{MoebiusColor:class extends er{constructor(e){super(x(e).hex(),(t=>"string"==typeof t)(t(e))?t(e):t(e).name)}},MoebiusPalettes:br,MoebiusSVGHelper:dr}}export{mr as default};
67
+ const Gt=.022;function Dt(t,e,r){return.2126729*Math.pow(t/255,2.4)+.7151522*Math.pow(e/255,2.4)+.072175*Math.pow(r/255,2.4)}const{sqrt:Yt,pow:qt,min:It,max:Xt,atan2:Zt,abs:Kt,cos:Wt,sin:Ut,exp:Vt,PI:Tt}=Math;var Ht={cool:()=>Mt([x.hsl(180,1,.9),x.hsl(250,.7,.4)]),hot:()=>Mt(["#000","#f00","#ff0","#fff"]).mode("rgb")};const Jt={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"],PuBu:["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"],BuPu:["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"],Oranges:["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"],BuGn:["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"],YlOrBr:["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"],YlGn:["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"],Reds:["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"],RdPu:["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"],Greens:["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"],YlGnBu:["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"],Purples:["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"],GnBu:["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"],Greys:["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"],YlOrRd:["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"],PuRd:["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"],Blues:["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"],PuBuGn:["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"],Viridis:["#440154","#482777","#3f4a8a","#31678e","#26838f","#1f9d8a","#6cce5a","#b6de2b","#fee825"],Spectral:["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],RdYlGn:["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],RdBu:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],PiYG:["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],PRGn:["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],RdYlBu:["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],BrBG:["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],RdGy:["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],PuOr:["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],Set2:["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"],Accent:["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"],Set1:["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"],Set3:["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"],Dark2:["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"],Paired:["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"],Pastel2:["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"],Pastel1:["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]},Qt=Object.keys(Jt),te=new Map(Qt.map((t=>[t.toLowerCase(),t]))),ee="function"==typeof Proxy?new Proxy(Jt,{get(t,e){const r=e.toLowerCase();if(te.has(r))return t[te.get(r)]},getOwnPropertyNames:()=>Object.getOwnPropertyNames(Qt)}):Jt,{max:re}=Math;y.prototype.cmyk=function(){return((...t)=>{let[e,r,n]=a(t,"rgb");e/=255,r/=255,n/=255;const o=1-re(e,re(r,n)),s=o<1?1/(1-o):0;return[(1-e-o)*s,(1-r-o)*s,(1-n-o)*s,o]})(this._rgb)};Object.assign(x,{cmyk:(...t)=>new y(...t,"cmyk")}),w.format.cmyk=(...t)=>{t=a(t,"cmyk");const[e,r,n,o]=t,s=t.length>4?t[4]:1;return 1===o?[0,0,0,s]:[e>=1?0:255*(1-e)*(1-o),r>=1?0:255*(1-r)*(1-o),n>=1?0:255*(1-n)*(1-o),s]},w.autodetect.push({p:2,test:(...t)=>{if("array"===s(t=a(t,"cmyk"))&&4===t.length)return"cmyk"}});const ne=(...t)=>{const[e,r,n,...o]=a(t,"rgb"),[s,c,i]=dt(e,r,n),[l,h,f]=T(s,c,i);return[l,h,f,...o.length>0&&o[0]<1?[o[0]]:[]]},{round:oe}=Math,se=(...t)=>{const e=a(t,"rgba");let r=c(t)||"rgb";if("hsl"===r.substr(0,3))return((...t)=>{const e=a(t,"hsla");let r=c(t)||"lsa";return e[0]=f(e[0]||0)+"deg",e[1]=f(100*e[1])+"%",e[2]=f(100*e[2])+"%","hsla"===r||e.length>3&&e[3]<1?(e[3]="/ "+(e.length>3?e[3]:1),r="hsla"):e.length=3,`${r.substr(0,3)}(${e.join(" ")})`})(it(e),r);if("lab"===r.substr(0,3)){const t=F();O("d50");const n=((...t)=>{const e=a(t,"lab");let r=c(t)||"lab";return e[0]=f(e[0])+"%",e[1]=f(e[1]),e[2]=f(e[2]),"laba"===r||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lab(${e.join(" ")})`})(R(e),r);return O(t),n}if("lch"===r.substr(0,3)){const t=F();O("d50");const n=((...t)=>{const e=a(t,"lch");let r=c(t)||"lab";return e[0]=f(e[0])+"%",e[1]=f(e[1]),e[2]=isNaN(e[2])?"none":f(e[2])+"deg","lcha"===r||e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`lch(${e.join(" ")})`})(H(e),r);return O(t),n}return"oklab"===r.substr(0,5)?((...t)=>{const e=a(t,"lab");return e[0]=f(100*e[0])+"%",e[1]=u(e[1]),e[2]=u(e[2]),e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklab(${e.join(" ")})`})(dt(e)):"oklch"===r.substr(0,5)?((...t)=>{const e=a(t,"lch");return e[0]=f(100*e[0])+"%",e[1]=u(e[1]),e[2]=isNaN(e[2])?"none":f(e[2])+"deg",e.length>3&&e[3]<1?e[3]="/ "+(e.length>3?e[3]:1):e.length=3,`oklch(${e.join(" ")})`})(ne(e)):(e[0]=oe(e[0]),e[1]=oe(e[1]),e[2]=oe(e[2]),("rgba"===r||e.length>3&&e[3]<1)&&(e[3]="/ "+(e.length>3?e[3]:1),r="rgba"),`${r.substr(0,3)}(${e.slice(0,"rgb"===r?3:4).join(" ")})`)},ae=(...t)=>{t=a(t,"lch");const[e,r,n,...o]=t,[s,c,i]=Z(e,r,n),[l,h,f]=bt(s,c,i);return[l,h,f,...o.length>0&&o[0]<1?[o[0]]:[]]},ce=/((?:-?\d+)|(?:-?\d+(?:\.\d+)?)%|none)/.source,ie=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%?)|none)/.source,le=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)%)|none)/.source,he=/\s*/.source,fe=/\s+/.source,ue=/\s*,\s*/.source,be=/((?:-?(?:\d+(?:\.\d*)?|\.\d+)(?:deg)?)|none)/.source,de=/\s*(?:\/\s*((?:[01]|[01]?\.\d+)|\d+(?:\.\d+)?%))?/.source,me=new RegExp("^rgba?\\("+he+[ce,ce,ce].join(fe)+de+"\\)$"),ge=new RegExp("^rgb\\("+he+[ce,ce,ce].join(ue)+he+"\\)$"),pe=new RegExp("^rgba\\("+he+[ce,ce,ce,ie].join(ue)+he+"\\)$"),we=new RegExp("^hsla?\\("+he+[be,le,le].join(fe)+de+"\\)$"),ye=new RegExp("^hsl?\\("+he+[be,le,le].join(ue)+he+"\\)$"),xe=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,ke=new RegExp("^lab\\("+he+[ie,ie,ie].join(fe)+de+"\\)$"),Ne=new RegExp("^lch\\("+he+[ie,ie,be].join(fe)+de+"\\)$"),Me=new RegExp("^oklab\\("+he+[ie,ie,ie].join(fe)+de+"\\)$"),ve=new RegExp("^oklch\\("+he+[ie,ie,be].join(fe)+de+"\\)$"),{round:$e}=Math,Se=t=>t.map(((t,e)=>e<=2?r($e(t),0,255):t)),Ae=(t,e=0,r=100,n=!1)=>("string"==typeof t&&t.endsWith("%")&&(t=parseFloat(t.substring(0,t.length-1))/100,t=n?e+.5*(t+1)*(r-e):e+t*(r-e)),+t),Ce=(t,e)=>"none"===t?e:t,Oe=t=>{if("transparent"===(t=t.toLowerCase().trim()))return[0,0,0,0];let e;if(w.format.named)try{return w.format.named(t)}catch(t){}if((e=t.match(me))||(e=t.match(ge))){let t=e.slice(1,4);for(let e=0;e<3;e++)t[e]=+Ae(Ce(t[e],0),0,255);t=Se(t);const r=void 0!==e[4]?+Ae(e[4],0,1):1;return t[3]=r,t}if(e=t.match(pe)){const t=e.slice(1,5);for(let e=0;e<4;e++)t[e]=+Ae(t[e],0,255);return t}if((e=t.match(we))||(e=t.match(ye))){const t=e.slice(1,4);t[0]=+Ce(t[0].replace("deg",""),0),t[1]=.01*+Ae(Ce(t[1],0),0,100),t[2]=.01*+Ae(Ce(t[2],0),0,100);const r=Se(ct(t)),n=void 0!==e[4]?+Ae(e[4],0,1):1;return r[3]=n,r}if(e=t.match(xe)){const t=e.slice(1,4);t[1]*=.01,t[2]*=.01;const r=ct(t);for(let t=0;t<3;t++)r[t]=$e(r[t]);return r[3]=+e[4],r}if(e=t.match(ke)){const t=e.slice(1,4);t[0]=Ae(Ce(t[0],0),0,100),t[1]=Ae(Ce(t[1],0),-125,125,!0),t[2]=Ae(Ce(t[2],0),-125,125,!0);const r=F();O("d50");const n=Se(L(t));O(r);const o=void 0!==e[4]?+Ae(e[4],0,1):1;return n[3]=o,n}if(e=t.match(Ne)){const t=e.slice(1,4);t[0]=Ae(t[0],0,100),t[1]=Ae(Ce(t[1],0),0,150,!1),t[2]=+Ce(t[2].replace("deg",""),0);const r=F();O("d50");const n=Se(K(t));O(r);const o=void 0!==e[4]?+Ae(e[4],0,1):1;return n[3]=o,n}if(e=t.match(Me)){const t=e.slice(1,4);t[0]=Ae(Ce(t[0],0),0,1),t[1]=Ae(Ce(t[1],0),-.4,.4,!0),t[2]=Ae(Ce(t[2],0),-.4,.4,!0);const r=Se(bt(t)),n=void 0!==e[4]?+Ae(e[4],0,1):1;return r[3]=n,r}if(e=t.match(ve)){const t=e.slice(1,4);t[0]=Ae(Ce(t[0],0),0,1),t[1]=Ae(Ce(t[1],0),0,.4,!1),t[2]=+Ce(t[2].replace("deg",""),0);const r=Se(ae(t)),n=void 0!==e[4]?+Ae(e[4],0,1):1;return r[3]=n,r}};Oe.test=t=>me.test(t)||we.test(t)||ke.test(t)||Ne.test(t)||Me.test(t)||ve.test(t)||ge.test(t)||pe.test(t)||ye.test(t)||xe.test(t)||"transparent"===t,y.prototype.css=function(t){return se(this._rgb,t)};x.css=(...t)=>new y(...t,"css"),w.format.css=Oe,w.autodetect.push({p:5,test:(t,...e)=>{if(!e.length&&"string"===s(t)&&Oe.test(t))return"css"}}),w.format.gl=(...t)=>{const e=a(t,"rgba");return e[0]*=255,e[1]*=255,e[2]*=255,e};x.gl=(...t)=>new y(...t,"gl"),y.prototype.gl=function(){const t=this._rgb;return[t[0]/255,t[1]/255,t[2]/255,t[3]]},y.prototype.hex=function(t){return S(this._rgb,t)};x.hex=(...t)=>new y(...t,"hex"),w.format.hex=v,w.autodetect.push({p:4,test:(t,...e)=>{if(!e.length&&"string"===s(t)&&[3,4,5,6,7,8,9].indexOf(t.length)>=0)return"hex"}});const{log:Fe}=Math,Le=t=>{const e=t/100;let r,n,o;return e<66?(r=255,n=e<6?0:-155.25485562709179-.44596950469579133*(n=e-2)+104.49216199393888*Fe(n),o=e<20?0:.8274096064007395*(o=e-10)-254.76935184120902+115.67994401066147*Fe(o)):(r=351.97690566805693+.114206453784165*(r=e-55)-40.25366309332127*Fe(r),n=325.4494125711974+.07943456536662342*(n=e-50)-28.0852963507957*Fe(n),o=255),[r,n,o,1]},{round:_e}=Math;y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return((...t)=>{const e=a(t,"rgb"),r=e[0],n=e[2];let o,s=1e3,c=4e4;for(;c-s>.4;){o=.5*(c+s);const t=Le(o);t[2]/t[0]>=n/r?c=o:s=o}return _e(o)})(this._rgb)};const Ee=(...t)=>new y(...t,"temp");Object.assign(x,{temp:Ee,kelvin:Ee,temperature:Ee}),w.format.temp=w.format.kelvin=w.format.temperature=Le,y.prototype.oklch=function(){return ne(this._rgb)};function je(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(x,{oklch:(...t)=>new y(...t,"oklch")}),w.format.oklch=ae,w.autodetect.push({p:2,test:(...t)=>{if("array"===s(t=a(t,"oklch"))&&3===t.length)return"oklch"}}),Object.assign(x,{analyze:zt,average:(t,e="lrgb",r=null)=>{const n=t.length;r||(r=Array.from(new Array(n)).map((()=>1)));const o=n/r.reduce((function(t,e){return t+e}));if(r.forEach(((t,e)=>{r[e]*=o})),t=t.map((t=>new y(t))),"lrgb"===e)return kt(t,r);const s=t.shift(),a=s.get(e),c=[];let i=0,l=0;for(let t=0;t<a.length;t++)if(a[t]=(a[t]||0)*r[0],c.push(isNaN(a[t])?0:r[0]),"h"===e.charAt(t)&&!isNaN(a[t])){const e=a[t]/180*pt;i+=wt(e)*r[0],l+=yt(e)*r[0]}let h=s.alpha()*r[0];t.forEach(((t,n)=>{const o=t.get(e);h+=t.alpha()*r[n+1];for(let t=0;t<a.length;t++)if(!isNaN(o[t]))if(c[t]+=r[n+1],"h"===e.charAt(t)){const e=o[t]/180*pt;i+=wt(e)*r[n+1],l+=yt(e)*r[n+1]}else a[t]+=o[t]*r[n+1]}));for(let t=0;t<a.length;t++)if("h"===e.charAt(t)){let e=xt(l/c[t],i/c[t])/pt*180;for(;e<0;)e+=360;for(;e>=360;)e-=360;a[t]=e}else a[t]=a[t]/c[t];return h/=n,new y(a,e).alpha(h>.99999?1:h,!0)},bezier:t=>{const e=function(t){let e,r,n,o;if(2===(t=t.map((t=>new y(t)))).length)[r,n]=t.map((t=>t.lab())),e=function(t){const e=[0,1,2].map((e=>r[e]+t*(n[e]-r[e])));return new y(e,"lab")};else if(3===t.length)[r,n,o]=t.map((t=>t.lab())),e=function(t){const e=[0,1,2].map((e=>(1-t)*(1-t)*r[e]+2*(1-t)*t*n[e]+t*t*o[e]));return new y(e,"lab")};else if(4===t.length){let s;[r,n,o,s]=t.map((t=>t.lab())),e=function(t){const e=[0,1,2].map((e=>(1-t)*(1-t)*(1-t)*r[e]+3*(1-t)*(1-t)*t*n[e]+3*(1-t)*t*t*o[e]+t*t*t*s[e]));return new y(e,"lab")}}else{if(!(t.length>=5))throw new RangeError("No point in running bezier with only one color.");{let r,n,o;r=t.map((t=>t.lab())),o=t.length-1,n=function(t){let e=[1,1];for(let r=1;r<t;r++){let t=[1];for(let r=1;r<=e.length;r++)t[r]=(e[r]||0)+e[r-1];e=t}return e}(o),e=function(t){const e=1-t,s=[0,1,2].map((s=>r.reduce(((r,a,c)=>r+n[c]*e**(o-c)*t**c*a[s]),0)));return new y(s,"lab")}}}return e}(t);return e.scale=()=>Mt(e),e},blend:$t,brewer:ee,Color:y,colors:k,contrast:(t,e)=>{t=new y(t),e=new y(e);const r=t.luminance(),n=e.luminance();return r>n?(r+.05)/(n+.05):(n+.05)/(r+.05)},contrastAPCA:(t,e)=>{t=new y(t),e=new y(e),t.alpha()<1&&(t=q(e,t,t.alpha(),"rgb"));const r=Dt(...t.rgb()),n=Dt(...e.rgb()),o=r>=Gt?r:r+Math.pow(Gt-r,1.414),s=n>=Gt?n:n+Math.pow(Gt-n,1.414),a=Math.pow(s,.56)-Math.pow(o,.57),c=Math.pow(s,.65)-Math.pow(o,.62),i=Math.abs(s-o)<5e-4?0:o<s?1.14*a:1.14*c;return 100*(Math.abs(i)<.1?0:i>0?i-.027:i+.027)},cubehelix:function(t=300,e=-1.5,r=1,o=1,a=[0,1]){let c,i=0;"array"===s(a)?c=a[1]-a[0]:(c=0,a=[a,a]);const l=function(s){const l=b*((t+120)/360+e*s),h=Ct(a[0]+c*s,o),f=(0!==i?r[0]+s*i:r)*h*(1-h)/2,u=Ft(l),d=Ot(l);return x(n([255*(h+f*(-.14861*u+1.78277*d)),255*(h+f*(-.29227*u-.90649*d)),255*(h+f*(1.97294*u)),1]))};return l.start=function(e){return null==e?t:(t=e,l)},l.rotations=function(t){return null==t?e:(e=t,l)},l.gamma=function(t){return null==t?o:(o=t,l)},l.hue=function(t){return null==t?r:("array"===s(r=t)?(i=r[1]-r[0],0===i&&(r=r[1])):i=0,l)},l.lightness=function(t){return null==t?a:("array"===s(t)?(a=t,c=t[1]-t[0]):(a=[t,t],c=0),l)},l.scale=()=>x.scale(l),l.hue(r),l},deltaE:function(t,e,r=1,n=1,o=1){var s=function(t){return 360*t/(2*Tt)},a=function(t){return 2*Tt*t/360};t=new y(t),e=new y(e);const[c,i,l]=Array.from(t.lab()),[h,f,u]=Array.from(e.lab()),b=(c+h)/2,d=(Yt(qt(i,2)+qt(l,2))+Yt(qt(f,2)+qt(u,2)))/2,m=.5*(1-Yt(qt(d,7)/(qt(d,7)+qt(25,7)))),g=i*(1+m),p=f*(1+m),w=Yt(qt(g,2)+qt(l,2)),x=Yt(qt(p,2)+qt(u,2)),k=(w+x)/2,N=s(Zt(l,g)),M=s(Zt(u,p)),v=N>=0?N:N+360,$=M>=0?M:M+360,S=Kt(v-$)>180?(v+$+360)/2:(v+$)/2,A=1-.17*Wt(a(S-30))+.24*Wt(a(2*S))+.32*Wt(a(3*S+6))-.2*Wt(a(4*S-63));let C=$-v;C=Kt(C)<=180?C:$<=v?C+360:C-360,C=2*Yt(w*x)*Ut(a(C)/2);const O=h-c,F=x-w,L=1+.015*qt(b-50,2)/Yt(20+qt(b-50,2)),_=1+.045*k,E=1+.015*k*A,j=30*Vt(-qt((S-275)/25,2)),R=-(2*Yt(qt(k,7)/(qt(k,7)+qt(25,7))))*Ut(2*a(j)),P=Yt(qt(O/(r*L),2)+qt(F/(n*_),2)+qt(C/(o*E),2)+R*(F/(n*_))*(C/(o*E)));return Xt(0,It(100,P))},distance:function(t,e,r="lab"){t=new y(t),e=new y(e);const n=t.get(r),o=e.get(r);let s=0;for(let t in n){const e=(n[t]||0)-(o[t]||0);s+=e*e}return Math.sqrt(s)},input:w,interpolate:q,limits:Bt,mix:q,random:()=>{let t="#";for(let e=0;e<6;e++)t+="0123456789abcdef".charAt(Lt(16*_t()));return new y(t,"hex")},scale:Mt,scales:Ht,valid:(...t)=>{try{return new y(...t),!0}catch(t){return!1}}});var Re,Pe={exports:{}};var ze,Be=(Re||(Re=1,ze=Pe,function(t){function e(t,r){if(!(t=n(t)))return null;var o,s,a,c=1/0;r||(r=e.DEFAULT_COLORS);for(var i=0;i<r.length;++i)s=r[i].rgb,(o=Math.pow(t.r-s.r,2)+Math.pow(t.g-s.g,2)+Math.pow(t.b-s.b,2))<c&&(c=o,a=r[i]);return a.name?{name:a.name,value:a.source,rgb:a.rgb,distance:Math.sqrt(c)}:a.source}function r(t){return t instanceof Array?t.map((function(t){return o(t)})):Object.keys(t).map((function(e){return o(t[e],e)}))}function n(t){if("object"==typeof t)return t;if(t in e.STANDARD_COLORS)return n(e.STANDARD_COLORS[t]);var r=t.match(/^#?((?:[0-9a-f]{3}){1,2})$/i);if(r)return r=3===(r=r[1]).length?[r.charAt(0)+r.charAt(0),r.charAt(1)+r.charAt(1),r.charAt(2)+r.charAt(2)]:[r.substring(0,2),r.substring(2,4),r.substring(4,6)],{r:parseInt(r[0],16),g:parseInt(r[1],16),b:parseInt(r[2],16)};var o=t.match(/^rgb\(\s*(\d{1,3}%?),\s*(\d{1,3}%?),\s*(\d{1,3}%?)\s*\)$/i);if(o)return{r:s(o[1]),g:s(o[2]),b:s(o[3])};throw Error('"'+t+'" is not a valid color')}function o(t,e){var r={};if(e&&(r.name=e),"string"==typeof t)r.source=t,r.rgb=n(t);else if("object"==typeof t){if(t.source)return o(t.source,t.name);r.rgb=t,r.source=function(t){return"#"+a(t.r.toString(16))+a(t.g.toString(16))+a(t.b.toString(16))}(t)}return r}function s(t){return"%"===t.charAt(t.length-1)?Math.round(255*parseInt(t,10)/100):Number(t)}function a(t){return 1===t.length&&(t="0"+t),t}e.from=function t(n){var o=r(n),s=e,a=function(t){return s(t,o)};return a.from=t,a.or=function(t){var n=o.concat(r(t));return e.from(n)},a},e.STANDARD_COLORS={aqua:"#0ff",black:"#000",blue:"#00f",fuchsia:"#f0f",gray:"#808080",green:"#008000",lime:"#0f0",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#ffa500",purple:"#800080",red:"#f00",silver:"#c0c0c0",teal:"#008080",white:"#fff",yellow:"#ff0"},e.DEFAULT_COLORS=r(["#f00","#f80","#ff0","#0f0","#00f","#008","#808"]),e.VERSION="0.4.4",ze&&ze.exports?ze.exports=e:t.nearestColor=e}(Pe.exports)),Pe.exports),Ge=je(Be);class De{h;s;l;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(0)),this.s=Number((100*e).toFixed(0)),this.l=Number((100*r).toFixed(0))}toString(){return`hsl(${this.h}, ${this.s}%, ${this.l}%)`}}class Ye{h;s;l;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(0)),this.s=Number(e.toFixed(2)),this.l=Number(r.toFixed(2))}toString(){return`${this.h}, ${this.s}, ${this.l}`}}class qe{x;y;z;constructor({x:t,y:e,z:r}){this.x=t,this.y=e,this.z=r}toString(){return`${this.x}, ${this.y}, ${this.z}`}}class Ie{c;m;y;k;constructor({c:t,m:e,y:r,k:n}){this.c=t,this.m=e,this.y=r,this.k=n}toString(){return`${this.c}, ${this.m}, ${this.y}, ${this.k}`}}class Xe{r;g;b;constructor({r:t,g:e,b:r}){this.r=t,this.g=e,this.b=r}toString(){return`${this.r}, ${this.g}, ${this.b}`}}class Ze{h;w;b;constructor({h:t,w:e,b:r}){this.h=t,this.w=e,this.b=r}toString(){return`${this.h}, ${this.w}, ${this.b}`}}class Ke{l;a;b;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.a=Number(e.toFixed(2)),this.b=Number(r.toFixed(2))}toString(){return`${this.l}, ${this.a}, ${this.b}`}}class We{l;a;b;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.a=Number(e.toFixed(2)),this.b=Number(r.toFixed(2))}toString(){return`${this.l}, ${this.a}, ${this.b}`}}class Ue{h;s;v;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(2)),this.s=Number(e.toFixed(2)),this.v=Number(r.toFixed(2))}toString(){return`${this.h}, ${this.s}, ${this.v}`}}class Ve{l;c;h;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.c=Number(e.toFixed(2)),this.h=Number(isNaN(r)?"0":r.toFixed(2))}toString(){return`${this.l}, ${this.c}, ${this.h}`}}class Te{l;c;h;constructor([t,e,r]){this.l=Number(t.toFixed(2)),this.c=Number(e.toFixed(2)),this.h=Number(isNaN(r)?"0":r.toFixed(2))}toString(){return`${this.l}, ${this.c}, ${this.h}`}}class He{h;s;i;constructor([t,e,r]){this.h=Number(isNaN(t)?"0":t.toFixed(2)),this.s=Number(e.toFixed(2)),this.i=Number(r.toFixed(2))}toString(){return`${this.h}, ${this.s}, ${this.i}`}}const Je=(t,e)=>{if("hsl"===e)return new Ye(x(t).hsl());const r=x(t).rgb();return new Xe({r:Number((r[0]/255).toFixed(2)),g:Number((r[1]/255).toFixed(2)),b:Number((r[2]/255).toFixed(2))})},Qe=t=>(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4),tr=t=>t>.008856452?Math.pow(t,1/3):t/.12841855+.137931034;class er{color;name;hex;rgb;hsl;hwb;hsv;lab;xyz;lch;oklch;hsi;oklab;cmyk;rgbFloat;hslFloat;constructor(t,e){this.color=t,this.name=e,this.hex=(t=>x(t).hex())(this.color),this.cmyk=(t=>{let[e,r,n]=x(t).rgb();e/=255,n/=255,r/=255;const o=+(1-Math.max(e,n,r)),s=+((1-n-o)/(1-o)||0),a=+((1-r-o)/(1-o)||0);return new Ie({c:Number((100*+((1-e-o)/(1-o)||0)).toFixed()),m:Number((100*s).toFixed()),y:Number((100*a).toFixed()),k:Number((100*o).toFixed())})})(this.color),this.xyz=(t=>{let[e,r,n]=x(t).rgb();e=Qe(e),n=Qe(n),r=Qe(r);const o=tr((.4124564*e+.3575761*n+.1804375*r)/.95047),s=tr((.2126729*e+.7151522*n+.072175*r)/1),a=tr((.0193339*e+.119192*n+.9503041*r)/1.08883);return new qe({x:Number(o.toFixed(2)),y:Number(s.toFixed(2)),z:Number(a.toFixed(2))})})(this.color),this.hsl=(t=>new De(x(t).hsl()))(this.color),this.hwb=(t=>{let[e,r,n]=x(t).rgb();e/=255,n/=255,r/=255;const o=Math.min(e,n,r),s=Math.max(e,n,r),a=1-s;return s===o?{h:0,w:o,b:a}:new Ze({h:Number((((e===o?3:n===o?5:1)-(e===o?n-r:n===o?r-e:e-n)/(s-o))/6).toFixed(2)),w:Number(o.toFixed(2)),b:Number(a.toFixed(2))})})(this.color),this.lab=(t=>new Ke(x(t).lab()))(this.color),this.oklab=(t=>new We(x(t).oklab()))(this.color),this.hsv=(t=>new Ue(x(t).hsv()))(this.color),this.lch=(t=>new Ve(x(t).lch()))(this.color),this.oklch=(t=>new Te(x(t).oklch()))(this.color),this.hsi=(t=>new He(x(t).hsi()))(this.color),this.rgb=(t=>{const[e,r,n]=x(t).rgb();return`rgb(${e}, ${r}, ${n})`})(this.color),this.rgbFloat=Je(this.color),this.hslFloat=Je(this.color,"hsl")}toObject(t){return((t,e)=>{if("hsl"===e){const[e,r,n]=x(t).hsl();return{h:Number(isNaN(e)?0:e.toFixed(0)),s:Number((100*r).toFixed()),l:Number((100*n).toFixed())}}const r=x(t).rgb();return{r:r[0],g:r[1],b:r[2]}})(this.color,t)}toFloat(t){return Je(this.color,t)}}const rr={diverging:!1,bezier:!1,randomOffset:!1,correctLightness:!1,noDuplicates:!0,colorScaleMode:"lch",reverseDirection:!1},nr=(t,e,r,n,o={})=>{const{noDuplicates:s=!0}=o,a=[x(t).hex()];let[c,i,l]=x(t).hsl();isNaN(c)&&(c=0),i=Number((100*i).toFixed()),l=Number((100*l).toFixed());for(let t=e;t<=r;t+=n){const e=Number(((c+t)%360).toFixed());a.push(x(`hsl(${e}, ${i}%, ${l}%)`).hex())}let h=a;return s&&(h=[...new Set(a)]),h},or=(t,e)=>Math.floor(Math.random()*(t-e+1))+e,sr=(t,e={})=>{const{numberOfColors:r=8,bezier:n=!1,randomOffset:o=!1,colorScaleMode:s,noDuplicates:a=!0,reverseDirection:c=!1,correctLightness:i=!0}=e;let[l,h,f]=x(t).hsl();isNaN(l)&&(l=0),l=Number(l.toFixed(0)),h=Number((100*h).toFixed(0)),f=Number((100*f).toFixed(0));const u=[];if(u.push(x(`hsl(${l}, ${h}%, ${f<0?0:f}%)`).hex()),o)for(let t=1;t<r;t++)c?(f+=or(0,10),l+=or(-5,5)):(f-=or(0,10),l-=or(-5,5)),l>359&&(l=359),l<0&&(l=0),u.push(x(`hsl(${l}, ${h}%, ${f<0?0:f}%)`).hex());else for(let t=1;t<r;t++)c?(f+=5,l+=5):(f-=5,l-=5),l>359&&(l=359),l<0&&(l=0),u.push(x(`hsl(${l}, ${h}%, ${f<0?0:f}%)`).hex());let b=u.map((t=>x(t).hex()));return a&&(b=[...new Set(b)]),n&&(b=b.length>1?x.bezier(b).scale().mode(s).correctLightness(i).colors(r):x.scale(b).mode(s).correctLightness(i).colors(r)),b},ar=(t,e={})=>{if(!t)throw Error("MoebiusPalettes: missing input `color`");const{diverging:r=!1,numberOfColors:n=7}=e,[o,s,a]=x(t).lab(),c=100*(.95-1/n),i=c/(n-1),l=.5*(100-c),h=((t,e,r)=>{const n=[];for(let o=t;o<e;o+=r)n.push(o);return n})(l,l+n*i,i);let f=0;if(!r){f=9999;for(let t=0;t<n;t++){const e=o-h[t];Math.abs(e)<Math.abs(f)&&(f=e)}}return h.map((t=>x.lab([t+f,s,a]).hex()))},cr=(t,e={})=>{const{numberOfColors:r,reverseDirection:n=!1,diverging:o=!1,divergentColor:s}=e;if(o){const e=ar(x(t).hex(),{numberOfColors:Math.ceil(r/2)}).concat(s);return n&&e.reverse(),e}return ar(t,{numberOfColors:r})},ir=(t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e;try{return x.bezier(t).scale().mode(n).correctLightness(o).colors(r)}catch{return[]}},lr=(t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e;try{return x.scale(t).mode(n).correctLightness(o).colors(r)}catch{return[]}};class hr{interpolate;luminanceShift;monochromatic;complement;split;triadic;tetradic;pentadic;hexadic;analogous;constructor(t,e){Object.keys(t).forEach((r=>{this[r]=t[r].map((t=>sr(t,{...e,numberOfColors:9})))}))}toArray(){return[...this.interpolate,...this.luminanceShift,...this.monochromatic,...this.complement,...this.split,...this.triadic,...this.tetradic,...this.pentadic,...this.hexadic,...this.analogous].flat()}}class fr{interpolate;luminanceShift;monochromatic;complement;split;triadic;tetradic;pentadic;hexadic;analogous;constructor(t){Object.keys(t).forEach((e=>{this[e]=t[e]}))}toArray(){return[...this.interpolate,...this.luminanceShift,...this.monochromatic,...this.complement,...this.split,...this.triadic,...this.tetradic,...this.pentadic,...this.hexadic,...this.analogous].flat()}}class ur{darkMode;constructor(t){Object.keys(t).forEach((e=>{this[e]=t[e]}))}}class br{baseColor;secondaryColor;colors={};themes={};defaultOptions={...rr,divergentColor:"#f5f5f5"};options;all=[];accents;constructor(t){this.options={...this.defaultOptions,...t},this.baseColor=this.options.baseColor,this.secondaryColor=this.options.secondaryColor,this.themes=new ur({darkMode:this.darkMode(this.baseColor.hex,this.secondaryColor.hex,{...this.options,reverseDirection:!this.options.reverseDirection})}),this.colors=new fr({interpolate:this.interpolate(this.baseColor.hex,this.secondaryColor.hex,this.options),luminanceShift:this.luminanceShift([this.baseColor.hex],[this.secondaryColor.hex],this.options),monochromatic:this.monochromatic(this.baseColor.hex),complement:this.complement(this.baseColor.hex),split:this.split(this.baseColor.hex),triadic:this.triadic(this.baseColor.hex),tetradic:this.tetradic(this.baseColor.hex),pentadic:this.pentadic(this.baseColor.hex),hexadic:this.hexadic(this.baseColor.hex),analogous:this.analogous(this.baseColor.hex)}),this.accents=new hr(this.colors,this.options),this.all=[...new Set([...this.accents.toArray(),...this.colors.toArray()].flat())]}complement(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,180,180,1);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}darkMode(t,e,r={}){return((t,e,r={})=>{const{bezier:n=!1,colorScaleMode:o,noDuplicates:s=!0}=r,a=sr(t,r),c=sr(e,r),i=c.map(((t,e)=>x.mix(a[e],t,.99-.02*e,o).hex())),l={primary:a,surface:c,mixed:i};return s&&(l.primary=[...new Set(a)],l.surface=[...new Set(c)],l.mixed=[...new Set(i)]),n&&(l.primary.length>1&&l.surface.length>1&&l.mixed.length>1?(l.primary=ir(l.primary,r),l.surface=ir(l.surface,r),l.mixed=ir(l.mixed,r)):(l.primary=lr(l.primary,r),l.surface=lr(l.surface,r),l.mixed=lr(l.mixed,r))),l})(t,e,{...this.options,...r})}split(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,150,210,60);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}triadic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,120,240,120);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}tetradic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,90,270,90);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}pentadic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,144,360,72);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}hexadic(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,120,360,60);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}analogous(t,e={}){return((t,e={})=>{const{numberOfColors:r=8,colorScaleMode:n,correctLightness:o=!0}=e,s=nr(t,30,90,30);return x.scale(s).mode(n).correctLightness(o).colors(r)})(t,{...this.options,...e})}interpolate(t,e,r={}){return((t,e,r={})=>{const{numberOfColors:n=8,colorScaleMode:o,bezier:s=!1,correctLightness:a=!0}=r;let c=x.scale([t,e]).mode(o).correctLightness(a).colors(n);return s&&(c=x.bezier([t,e]).scale().mode(o).correctLightness(a).colors(n)),c})(t,e,{...this.options,...r})}luminanceShift(t,e=[],r={}){return((t,e=[],r={})=>{const{numberOfColors:n=8,diverging:o=!1,colorScaleMode:s,bezier:a=!1,divergentColor:c="#f5f5f5",correctLightness:i=!0}=r;e=0===e.length?[nr(t[0],90,270,90)[3]]:e;const l=n%2==0,h=o?Math.ceil(n/2)+(l?1:0):n,f=o?Math.ceil(n/2)+(l?1:0):0,u=1!==t.length?t:cr(t[0],{numberOfColors:h,divergentColor:c});let b=[];o&&(b=1!==e.length?e:cr(e[0],{numberOfColors:f,divergentColor:c,diverging:o}));let d=t.length?x.scale(u).mode(s).correctLightness(i).colors(h):[];a&&(d=t.length?x.bezier(u).scale().mode(s).correctLightness(i).colors(h):[]);let m=o&&e.length?x.scale(b).mode(s).correctLightness(i).colors(f):[];a&&(m=o&&e.length?x.bezier(b).scale().mode(s).correctLightness(i).colors(f):[]);let g=d;return g=(o?d.slice(0,d.length-(h%2!=0?0:1)):d).concat(m.reverse()),g})(t,e,{...this.options,...r})}monochromatic(t,e={}){const r={...this.options,...e};return sr(t,r)}harmonize(t,e,r,n,o={}){const s={...this.options,...o};return nr(t,e,r,n,s)}}class dr{xlmns="http://www.w3.org/2000/svg";getColorPiePaths(t,e=256){const r=document.createDocumentFragment(),n=document.createElementNS(this.xlmns,"defs"),o=document.createElementNS(this.xlmns,"mask"),s=document.createElementNS(this.xlmns,"rect"),a=document.createElementNS(this.xlmns,"g"),c=360/t.length,i="_"+Math.random().toString(36).substring(2,11);o.setAttributeNS(null,"id",i),s.setAttributeNS(null,"height","100%"),s.setAttributeNS(null,"width","100%"),s.setAttributeNS(null,"fill","white"),a.setAttributeNS(null,"mask",`url(#${i})`),o.appendChild(s);const l=360/t.length;var h,f;for(let e=(h=l/2,4===(f=t.length)||8===f||12===f?0:3===f||9===f?30:7===f?12:5===f?55:h);e<360;e+=l){const t=document.createElementNS(this.xlmns,"line");t.setAttributeNS(null,"x1","128"),t.setAttributeNS(null,"y1","128"),t.setAttributeNS(null,"x2","0"),t.setAttributeNS(null,"y2","128"),t.setAttributeNS(null,"stroke","black"),t.setAttributeNS(null,"stroke-width","6"),t.setAttributeNS(null,"transform",`rotate(${e} 128 128)`),o.appendChild(t)}let u=0;return t.forEach((t=>{const r=e/2/t.length;return u+=c,t.forEach(((t,n)=>{const o=e/2-n*r,s=document.createElementNS(this.xlmns,"path");s.setAttributeNS(null,"fill",t),s.setAttributeNS(null,"data-color-hex",t),s.setAttributeNS(null,"data-r",`${o}`),s.setAttributeNS(null,"d",((t,e,r,n=256)=>{const o=n/2,s=o;let a=t+e;if(t>a){const e=t;t=a,a=e}return`M ${o+r*Math.cos((90-t)*(Math.PI/180))} ${s+r*Math.sin((90-t)*(Math.PI/180))} A ${r} ${r} 0 ${a-t<=180?"0":"1"} 0 ${o+r*Math.cos((90-a)*(Math.PI/180))} ${s+r*Math.sin((90-a)*(Math.PI/180))} L ${o} ${s} Z`})(u,c,o)),a.appendChild(s)}))})),n.appendChild(o),r.appendChild(n),r.appendChild(a),r}}async function mr(){const t=await(async()=>{const t=await fetch("https://color-names.herokuapp.com/v1/"),e=(await t.json()).colors,r={};return e.forEach((t=>{r[t.name]=t.hex})),Ge.from(r)})();return{MoebiusColor:class extends er{constructor(e){super(x(e).hex(),function(t){return"string"==typeof t}(t(e))?t(e):t(e).name)}},MoebiusPalettes:br,MoebiusSVGHelper:dr}}export{mr as default};
68
68
  //# sourceMappingURL=moebius.js.map