import { sequentialColorInterpolators as l } from "@nivo/colors";
import * as d from "d3";
import f from "./Colors.js";
class u extends f {
  constructor(t, i, e, s, r) {
    if (super(t, i, e, s, r), t === "index" && (this._domain = [0, this.data.length]), t === "id" && (this._domain = [0, this.keys.length]), t === "values") {
      const n = e.map((o) => s.map((h) => o[h])).flatMap((o) => o).filter((o) => o != null);
      this._domain = [Math.min(...n), Math.max(...n)];
    }
    const a = l[this.scheme];
    this._color = d.scaleSequential(a), this._color.domain(this._domain);
  }
  getColor(t, i) {
    if (this.colorBy === "index") {
      const e = this.data.map((s) => s[this.indexBy]);
      return this.color(e.indexOf(i[this.indexBy]));
    }
    if (this.colorBy === "id")
      return this.color(this.keys.indexOf(t));
    if (this.colorBy === "values")
      return this.color(i[t]);
  }
  getColorByIndex(t) {
    const i = this.data.map((e) => e[this.indexBy]);
    return this.color(i.indexOf(t));
  }
  getColorByKey(t) {
    return this.color(this.keys.indexOf(t));
  }
}
export {
  u as default
};
