import { a as exponent_default } from "./defaultLocale-BpsHxBd7.js";
function ascending(e, n) {
  return e == null || n == null ? NaN : e < n ? -1 : e > n ? 1 : e >= n ? 0 : NaN;
}
function descending(e, n) {
  return e == null || n == null ? NaN : n < e ? -1 : n > e ? 1 : n >= e ? 0 : NaN;
}
function bisector(e) {
  let i, o, s;
  e.length === 2 ? (i = e === ascending || e === descending ? e : zero, o = e, s = e) : (i = ascending, o = (r, i2) => ascending(e(r), i2), s = (n, r) => e(n) - r);
  function c(e3, n, r = 0, a = e3.length) {
    if (r < a) {
      if (i(n, n) !== 0) return a;
      do {
        let i2 = r + a >>> 1;
        o(e3[i2], n) < 0 ? r = i2 + 1 : a = i2;
      } while (r < a);
    }
    return r;
  }
  function l(e3, n, r = 0, a = e3.length) {
    if (r < a) {
      if (i(n, n) !== 0) return a;
      do {
        let i2 = r + a >>> 1;
        o(e3[i2], n) <= 0 ? r = i2 + 1 : a = i2;
      } while (r < a);
    }
    return r;
  }
  function u(e3, n, r = 0, i2 = e3.length) {
    let a = c(e3, n, r, i2 - 1);
    return a > r && s(e3[a - 1], n) > -s(e3[a], n) ? a - 1 : a;
  }
  return {
    left: c,
    center: u,
    right: l
  };
}
function zero() {
  return 0;
}
var e10 = Math.sqrt(50), e5 = Math.sqrt(10), e2 = Math.sqrt(2);
function tickSpec(e, n, r) {
  let i = (n - e) / Math.max(0, r), a = Math.floor(Math.log10(i)), u = i / 10 ** a, d = u >= e10 ? 10 : u >= e5 ? 5 : u >= e2 ? 2 : 1, f, p, m;
  return a < 0 ? (m = 10 ** -a / d, f = Math.round(e * m), p = Math.round(n * m), f / m < e && ++f, p / m > n && --p, m = -m) : (m = 10 ** a * d, f = Math.round(e / m), p = Math.round(n / m), f * m < e && ++f, p * m > n && --p), p < f && 0.5 <= r && r < 2 ? tickSpec(e, n, r * 2) : [
    f,
    p,
    m
  ];
}
function ticks(e, n, r) {
  if (n = +n, e = +e, r = +r, !(r > 0)) return [];
  if (e === n) return [e];
  let i = n < e, [a, o, s] = i ? tickSpec(n, e, r) : tickSpec(e, n, r);
  if (!(o >= a)) return [];
  let c = o - a + 1, u = Array(c);
  if (i) if (s < 0) for (let e3 = 0; e3 < c; ++e3) u[e3] = (o - e3) / -s;
  else for (let e3 = 0; e3 < c; ++e3) u[e3] = (o - e3) * s;
  else if (s < 0) for (let e3 = 0; e3 < c; ++e3) u[e3] = (a + e3) / -s;
  else for (let e3 = 0; e3 < c; ++e3) u[e3] = (a + e3) * s;
  return u;
}
function tickIncrement(e, n, r) {
  return n = +n, e = +e, r = +r, tickSpec(e, n, r)[2];
}
function tickStep(e, n, r) {
  n = +n, e = +e, r = +r;
  let i = n < e, a = i ? tickIncrement(n, e, r) : tickIncrement(e, n, r);
  return (i ? -1 : 1) * (a < 0 ? 1 / -a : a);
}
function precisionFixed_default(n) {
  return Math.max(0, -exponent_default(Math.abs(n)));
}
function precisionPrefix_default(n, r) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(r) / 3))) * 3 - exponent_default(Math.abs(n)));
}
function precisionRound_default(n, r) {
  return n = Math.abs(n), r = Math.abs(r) - n, Math.max(0, exponent_default(r) - exponent_default(n)) + 1;
}
export {
  tickStep as a,
  ascending as c,
  tickIncrement as i,
  precisionPrefix_default as n,
  ticks as o,
  precisionFixed_default as r,
  bisector as s,
  precisionRound_default as t
};
