import { P as v, S as $, V as d, X as A, _ as j } from "./index-CNUFa5l3.js";
import { o as q, y as D, v as V, n as M } from "./defaultLocale-mtMQ0U8A-D6jPixjH.js";
import { e as S } from "./init-8lPFe2y8-B2MlpiqM.js";
function g(n, r) {
  return n == null || r == null ? NaN : n < r ? -1 : n > r ? 1 : n >= r ? 0 : NaN;
}
function B(n, r) {
  return n == null || r == null ? NaN : r < n ? -1 : r > n ? 1 : r >= n ? 0 : NaN;
}
function x(n) {
  let r, a, t;
  n.length === 2 ? (r = n === g || n === B ? n : E, a = n, t = n) : (r = g, a = (e, c) => g(n(e), c), t = (e, c) => n(e) - c);
  function i(e, c, u = 0, h = e.length) {
    if (u < h) {
      if (r(c, c) !== 0) return h;
      do {
        let l = u + h >>> 1;
        a(e[l], c) < 0 ? u = l + 1 : h = l;
      } while (u < h);
    }
    return u;
  }
  function f(e, c, u = 0, h = e.length) {
    if (u < h) {
      if (r(c, c) !== 0) return h;
      do {
        let l = u + h >>> 1;
        a(e[l], c) <= 0 ? u = l + 1 : h = l;
      } while (u < h);
    }
    return u;
  }
  function o(e, c, u = 0, h = e.length) {
    let l = i(e, c, u, h - 1);
    return l > u && t(e[l - 1], c) > -t(e[l], c) ? l - 1 : l;
  }
  return {
    left: i,
    center: o,
    right: f
  };
}
function E() {
  return 0;
}
function F(n) {
  return n === null ? NaN : +n;
}
var I = x(g), O = I.right;
x(F).center;
var P = Math.sqrt(50), R = Math.sqrt(10), T = Math.sqrt(2);
function p(n, r, a) {
  let t = (r - n) / Math.max(0, a), i = Math.floor(Math.log10(t)), f = t / 10 ** i, o = f >= P ? 10 : f >= R ? 5 : f >= T ? 2 : 1, e, c, u;
  return i < 0 ? (u = 10 ** -i / o, e = Math.round(n * u), c = Math.round(r * u), e / u < n && ++e, c / u > r && --c, u = -u) : (u = 10 ** i * o, e = Math.round(n / u), c = Math.round(r / u), e * u < n && ++e, c * u > r && --c), c < e && 0.5 <= a && a < 2 ? p(n, r, a * 2) : [
    e,
    c,
    u
  ];
}
function U(n, r, a) {
  if (r = +r, n = +n, a = +a, !(a > 0)) return [];
  if (n === r) return [n];
  let t = r < n, [i, f, o] = t ? p(r, n, a) : p(n, r, a);
  if (!(f >= i)) return [];
  let e = f - i + 1, c = Array(e);
  if (t) if (o < 0) for (let u = 0; u < e; ++u) c[u] = (f - u) / -o;
  else for (let u = 0; u < e; ++u) c[u] = (f - u) * o;
  else if (o < 0) for (let u = 0; u < e; ++u) c[u] = (i + u) / -o;
  else for (let u = 0; u < e; ++u) c[u] = (i + u) * o;
  return c;
}
function N(n, r, a) {
  return r = +r, n = +n, a = +a, p(n, r, a)[2];
}
function W(n, r, a) {
  r = +r, n = +n, a = +a;
  let t = r < n, i = t ? N(r, n, a) : N(n, r, a);
  return (t ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function _(n, r) {
  r || (r = []);
  var a = n ? Math.min(r.length, n.length) : 0, t = r.slice(), i;
  return function(f) {
    for (i = 0; i < a; ++i) t[i] = n[i] * (1 - f) + r[i] * f;
    return t;
  };
}
function z(n) {
  return ArrayBuffer.isView(n) && !(n instanceof DataView);
}
function C(n, r) {
  var a = r ? r.length : 0, t = n ? Math.min(a, n.length) : 0, i = Array(t), f = Array(a), o;
  for (o = 0; o < t; ++o) i[o] = b(n[o], r[o]);
  for (; o < a; ++o) f[o] = r[o];
  return function(e) {
    for (o = 0; o < t; ++o) f[o] = i[o](e);
    return f;
  };
}
function G(n, r) {
  var a = /* @__PURE__ */ new Date();
  return n = +n, r = +r, function(t) {
    return a.setTime(n * (1 - t) + r * t), a;
  };
}
function H(n, r) {
  var a = {}, t = {}, i;
  for (i in (typeof n != "object" || !n) && (n = {}), (typeof r != "object" || !r) && (r = {}), r) i in n ? a[i] = b(n[i], r[i]) : t[i] = r[i];
  return function(f) {
    for (i in a) t[i] = a[i](f);
    return t;
  };
}
function b(n, r) {
  var a = typeof r, t;
  return r == null || a === "boolean" ? $(r) : (a === "number" ? v : a === "string" ? (t = d(r)) ? (r = t, A) : j : r instanceof d ? A : r instanceof Date ? G : z(r) ? _ : Array.isArray(r) ? C : typeof r.valueOf != "function" && typeof r.toString != "function" || isNaN(r) ? H : v)(n, r);
}
function K(n, r) {
  return n = +n, r = +r, function(a) {
    return Math.round(n * (1 - a) + r * a);
  };
}
function L(n) {
  return Math.max(0, -M(Math.abs(n)));
}
function X(n, r) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(M(r) / 3))) * 3 - M(Math.abs(n)));
}
function J(n, r) {
  return n = Math.abs(n), r = Math.abs(r) - n, Math.max(0, M(r) - M(n)) + 1;
}
function Q(n) {
  return function() {
    return n;
  };
}
function Y(n) {
  return +n;
}
var w = [0, 1];
function m(n) {
  return n;
}
function y(n, r) {
  return (r -= n = +n) ? function(a) {
    return (a - n) / r;
  } : Q(isNaN(r) ? NaN : 0.5);
}
function Z(n, r) {
  var a;
  return n > r && (a = n, n = r, r = a), function(t) {
    return Math.max(n, Math.min(r, t));
  };
}
function nn(n, r, a) {
  var t = n[0], i = n[1], f = r[0], o = r[1];
  return i < t ? (t = y(i, t), f = a(o, f)) : (t = y(t, i), f = a(f, o)), function(e) {
    return f(t(e));
  };
}
function rn(n, r, a) {
  var t = Math.min(n.length, r.length) - 1, i = Array(t), f = Array(t), o = -1;
  for (n[t] < n[0] && (n = n.slice().reverse(), r = r.slice().reverse()); ++o < t; ) i[o] = y(n[o], n[o + 1]), f[o] = a(r[o], r[o + 1]);
  return function(e) {
    var c = O(n, e, 1, t) - 1;
    return f[c](i[c](e));
  };
}
function tn(n, r) {
  return r.domain(n.domain()).range(n.range()).interpolate(n.interpolate()).clamp(n.clamp()).unknown(n.unknown());
}
function un() {
  var n = w, r = w, a = b, t, i, f, o = m, e, c, u;
  function h() {
    var s = Math.min(n.length, r.length);
    return o !== m && (o = Z(n[0], n[s - 1])), e = s > 2 ? rn : nn, c = u = null, l;
  }
  function l(s) {
    return s == null || isNaN(s = +s) ? f : (c || (c = e(n.map(t), r, a)))(t(o(s)));
  }
  return l.invert = function(s) {
    return o(i((u || (u = e(r, n.map(t), v)))(s)));
  }, l.domain = function(s) {
    return arguments.length ? (n = Array.from(s, Y), h()) : n.slice();
  }, l.range = function(s) {
    return arguments.length ? (r = Array.from(s), h()) : r.slice();
  }, l.rangeRound = function(s) {
    return r = Array.from(s), a = K, h();
  }, l.clamp = function(s) {
    return arguments.length ? (o = s ? !0 : m, h()) : o !== m;
  }, l.interpolate = function(s) {
    return arguments.length ? (a = s, h()) : a;
  }, l.unknown = function(s) {
    return arguments.length ? (f = s, l) : f;
  }, function(s, k) {
    return t = s, i = k, h();
  };
}
function an() {
  return un()(m, m);
}
function on(n, r, a, t) {
  var i = W(n, r, a), f;
  switch (t = q(t ?? ",f"), t.type) {
    case "s":
      var o = Math.max(Math.abs(n), Math.abs(r));
      return t.precision == null && !isNaN(f = X(i, o)) && (t.precision = f), D(t, o);
    case "":
    case "e":
    case "g":
    case "p":
    case "r":
      t.precision == null && !isNaN(f = J(i, Math.max(Math.abs(n), Math.abs(r)))) && (t.precision = f - (t.type === "e"));
      break;
    case "f":
    case "%":
      t.precision == null && !isNaN(f = L(i)) && (t.precision = f - (t.type === "%") * 2);
      break;
  }
  return V(t);
}
function en(n) {
  var r = n.domain;
  return n.ticks = function(a) {
    var t = r();
    return U(t[0], t[t.length - 1], a ?? 10);
  }, n.tickFormat = function(a, t) {
    var i = r();
    return on(i[0], i[i.length - 1], a ?? 10, t);
  }, n.nice = function(a) {
    a ?? (a = 10);
    var t = r(), i = 0, f = t.length - 1, o = t[i], e = t[f], c, u, h = 10;
    for (e < o && (u = o, o = e, e = u, u = i, i = f, f = u); h-- > 0; ) {
      if (u = N(o, e, a), u === c) return t[i] = o, t[f] = e, r(t);
      if (u > 0) o = Math.floor(o / u) * u, e = Math.ceil(e / u) * u;
      else if (u < 0) o = Math.ceil(o * u) / u, e = Math.floor(e * u) / u;
      else break;
      c = u;
    }
    return n;
  }, n;
}
function fn() {
  var n = an();
  return n.copy = function() {
    return tn(n, fn());
  }, S.apply(n, arguments), en(n);
}
export {
  W as C,
  tn as H,
  an as W,
  x as f,
  fn as q
};
