"use client";
import u from "./max.js";
import a from "./min.js";
import c from "./quickselect.js";
import b, { numbers as h } from "./number.js";
function g(r, t, o) {
  if (r = Float64Array.from(h(r)), !(!(n = r.length) || isNaN(t = +t))) {
    if (t <= 0 || n < 2) return a(r);
    if (t >= 1) return u(r);
    var n, f = (n - 1) * t, i = Math.floor(f), m = u(c(r, i).subarray(0, i + 1)), e = a(r.subarray(i + 1));
    return m + (e - m) * (f - i);
  }
}
function x(r, t, o = b) {
  if (!(!(n = r.length) || isNaN(t = +t))) {
    if (t <= 0 || n < 2) return +o(r[0], 0, r);
    if (t >= 1) return +o(r[n - 1], n - 1, r);
    var n, f = (n - 1) * t, i = Math.floor(f), m = +o(r[i], i, r), e = +o(r[i + 1], i + 1, r);
    return m + (e - m) * (f - i);
  }
}
export {
  g as default,
  x as quantileSorted
};
