import l from "./BigIntDecimal.mjs";
import d from "./NumberDecimal.mjs";
import { trimNumber as v } from "./numberUtil.mjs";
import { supportBigInt as b } from "./supportUtil.mjs";
function D(r) {
  return b() ? new l(r) : new d(r);
}
function S(r, n, t) {
  var i = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : !1;
  if (r === "")
    return "";
  var a = v(r), m = a.negativeStr, f = a.integerStr, c = a.decimalStr, o = "".concat(n).concat(c), e = "".concat(m).concat(f);
  if (t >= 0) {
    var u = Number(c[t]);
    if (u >= 5 && !i) {
      var g = D(r).add("".concat(m, "0.").concat("0".repeat(t)).concat(10 - u));
      return S(g.toString(), n, t, i);
    }
    return t === 0 ? e : "".concat(e).concat(n).concat(c.padEnd(t, "0").slice(0, t));
  }
  return o === ".0" ? e : "".concat(e).concat(o);
}
export {
  l as BigIntDecimal,
  d as NumberDecimal,
  D as default,
  S as toFixed
};
