import { supportBigInt as N } from "./supportUtil.mjs";
function l(t) {
  return !t && t !== 0 && !Number.isNaN(t) || !String(t).trim();
}
function S(t) {
  var r = t.trim(), e = r.startsWith("-");
  e && (r = r.slice(1)), r = r.replace(/(\.\d*[^0])0*$/, "$1").replace(/\.0*$/, "").replace(/^0+/, ""), r.startsWith(".") && (r = "0".concat(r));
  var i = r || "0", n = i.split("."), s = n[0] || "0", a = n[1] || "0";
  s === "0" && a === "0" && (e = !1);
  var u = e ? "-" : "";
  return {
    negative: e,
    negativeStr: u,
    trimStr: i,
    integerStr: s,
    decimalStr: a,
    fullStr: "".concat(u).concat(i)
  };
}
function f(t) {
  var r = String(t);
  return !Number.isNaN(Number(r)) && r.includes("e");
}
function g(t) {
  var r = String(t);
  if (f(t)) {
    var e = Number(r.slice(r.indexOf("e-") + 2)), i = r.match(/\.(\d+)/);
    return i != null && i[1] && (e += i[1].length), e;
  }
  return r.includes(".") && o(r) ? r.length - r.indexOf(".") - 1 : 0;
}
function v(t) {
  var r = String(t);
  if (f(t)) {
    if (t > Number.MAX_SAFE_INTEGER)
      return String(N() ? BigInt(t).toString() : Number.MAX_SAFE_INTEGER);
    if (t < Number.MIN_SAFE_INTEGER)
      return String(N() ? BigInt(t).toString() : Number.MIN_SAFE_INTEGER);
    r = t.toFixed(g(r));
  }
  return S(r).fullStr;
}
function o(t) {
  return typeof t == "number" ? !Number.isNaN(t) : t ? (
    // Normal type: 11.28
    /^\s*-?\d+(\.\d+)?\s*$/.test(t) || // Pre-number: 1.
    /^\s*-?\d+\.\s*$/.test(t) || // Post-number: .1
    /^\s*-?\.\d+\s*$/.test(t)
  ) : !1;
}
export {
  g as getNumberPrecision,
  f as isE,
  l as isEmpty,
  v as num2str,
  S as trimNumber,
  o as validateNumber
};
