"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=[{value:"blues",label:"blues",startColor:"#f7fbff",endColor:"#08306b"},{value:"greens",label:"greens",startColor:"#f7fcf5",endColor:"#00441b"},{value:"greys",label:"greys",startColor:"#ffffff",endColor:"#000000"},{value:"oranges",label:"oranges",startColor:"#fff5eb",endColor:"#7f2704"},{value:"purples",label:"purples",startColor:"#fcfbfd",endColor:"#3f007d"},{value:"reds",label:"reds",startColor:"#fff5f0",endColor:"#67000d"},{value:"blue_green",label:"blue_green",startColor:"#f7fcfd",endColor:"#00441b"},{value:"blue_purple",label:"blue_purple",startColor:"#f7fcfd",endColor:"#4d004b"},{value:"green_blue",label:"green_blue",startColor:"#f7fcf0",endColor:"#084081"},{value:"orange_red",label:"orange_red",startColor:"#fff7ec",endColor:"#7f0000"},{value:"purple_blue_green",label:"purple_blue_green",startColor:"#fff7fb",endColor:"#014636"},{value:"purple_blue",label:"purple_blue",startColor:"#fff7fb",endColor:"#023858"},{value:"purple_red",label:"purple_red",startColor:"#f7f4f9",endColor:"#67001f"},{value:"red_purple",label:"red_purple",startColor:"#fff7f3",endColor:"#49006a"},{value:"yellow_green_blue",label:"yellow_green_blue",startColor:"#ffffd9",endColor:"#081d58"},{value:"yellow_green",label:"yellow_green",startColor:"#ffffe5",endColor:"#004529"},{value:"yellow_orange_brown",label:"yellow_orange_brown",startColor:"#ffffe5",endColor:"#662506"},{value:"yellow_orange_red",label:"yellow_orange_red",startColor:"#ffffcc",endColor:"#800026"}];class v{constructor(t){const{gradientScheme:r,gradientReverse:a,data:o=[],defaultFillColor:d,measure:f,gradientStartColor:C,gradientEndColor:u}=t;this.defaultFillColor=d,this.measure=f,this.gradientStartColor=C,this.gradientEndColor=u,this.valueColors=this.createGradient(r,o,a),this.getColor=this.getColor.bind(this)}createGradient(t,r,a){let o={startColor:this.gradientStartColor||"#ffffff",endColor:this.gradientEndColor||"#000000"};t!=="custom"&&(o=p.find(e=>e.value==t)||{startColor:"#ffffff",endColor:"#000000"});const d=r.slice().sort((e,l)=>e[this.measure]-l[this.measure]);function f(e){return e=e.replace(/^#/,""),e.length===3&&(e=e.split("").map(l=>l+l).join("")),{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16)}}function C({r:e,g:l,b:i}){const n=g=>g.toString(16).padStart(2,"0");return`#${n(e)}${n(l)}${n(i)}`}const u=a?o.endColor:o.startColor,c=a?o.startColor:o.endColor;this.startColor=u,this.endColor=c;const s=f(u),b=f(c),_=[];for(let e=0;e<r.length;e++){const l=r.length>1?e/(r.length-1):1,i=Math.round(s.r+(b.r-s.r)*l),n=Math.round(s.g+(b.g-s.g)*l),g=Math.round(s.b+(b.b-s.b)*l);_.push({value:d[e][this.measure],color:C({r:i,g:n,b:g})})}return _}getColor(t){if(this.valueColors.length>0){const r=this.valueColors.find(a=>a.value==t);return(r==null?void 0:r.color)||this.defaultFillColor}return this.defaultFillColor}getStartColor(){return this.startColor}getEndColor(){return this.endColor}}exports.default=v;
