import { w as o } from "./app-Bpb4394e.js";
import { F as l } from "./decimal-C219qGO5.js";
import "./dayjs.min-D5mIeZ1x.js";
function g(n, t) {
  return o.convertPrecision({
    value: n,
    precision: t
  });
}
function A(n, t) {
  return o.subtract([n, t]);
}
function j(n, t) {
  return o.add([n, t]);
}
function w(n, t) {
  return o.multiply([n, t]);
}
function P(n, t) {
  return o.multiply([n, t]);
}
function d(n, t) {
  const r = +s(n), e = +s(t);
  return r / e;
}
function F(n, t) {
  n = c(n), t = c(t);
  const r = d(n, t);
  return m(r);
}
function N(n, t) {
  return n.precision >= t ? n : o.convertPrecision({ value: n, precision: t });
}
function c(n) {
  if (n.amount === 0) return m(0);
  const t = f(n.amount), r = n.precision - t;
  return o.convertPrecision({ value: n, precision: Math.max(0, r) });
}
function s(n, t = !0) {
  return t ? Number(n.amount / Math.pow(10, n.precision)).toFixed(n.precision) : Number(n.amount / Math.pow(10, n.precision)).toString();
}
function x(n, t) {
  t = t ?? a(n);
  const r = t, e = n.toFixed(r), i = e.includes(".") ? e.replace(/0+$/, "") : e;
  return i.endsWith(".") ? i.slice(0, i.length - 1) : i;
}
function M(n, t = !1, r = 2) {
  const e = Number(n.amount / Math.pow(10, n.precision)), i = e.toFixed(
    Number.isInteger(e) ? 2 : Math.min(4, Math.max(2, r))
  );
  return t ? `${i} ${n.currency}` : n.currency === "MYR" ? `RM ${i}` : `${n.currency} ${i}`;
}
function y(n) {
  return {
    ...n,
    amount: Math.abs(n.amount)
  };
}
function a(n) {
  if (!isFinite(n)) return 0;
  let t = 1, r = 0;
  for (; Math.round(n * t) / t !== n; )
    t *= 10, r++;
  return r;
}
function m(n) {
  const t = a(n);
  return {
    precision: t,
    amount: n * 10 ** t
  };
}
function v(n, t = 0, r = !1) {
  let e = 0;
  return Number.isNaN(Number(n)) || (r || Number(n) >= 0) && (e = Number(n)), {
    amount: Number((e * 10 ** t).toFixed(0)),
    precision: t
  };
}
function f(n) {
  const t = `${n}`, r = t.replace(/0*$/g, "");
  return t.length - r.length;
}
function D(n, t) {
  if (!t)
    return n.precision;
  const r = f(t.conversion.amount);
  return n.precision - t.conversion.precision + r;
}
function $(n, t = {}) {
  if (n == null)
    throw new Error("Value cannot be null or undefined");
  const { minPrecision: r = 2, maxPrecision: e = 2, locale: i = "en-US" } = t;
  if (r > e)
    throw new Error("minPrecision cannot be greater than maxPrecision");
  let u = 0;
  switch (typeof n) {
    case "number": {
      u = n;
      break;
    }
    case "string": {
      u = Number(n);
      break;
    }
    case "object": {
      if (n.amount === void 0 || n.precision === void 0)
        throw new Error("Invalid AdjustmentAmount object");
      u = l.toDouble(n);
      break;
    }
    default:
      throw new Error("Invalid value type");
  }
  return u.toLocaleString(i, {
    minimumFractionDigits: r,
    maximumFractionDigits: e
  });
}
export {
  s as a,
  c as b,
  m as c,
  M as d,
  P as e,
  a as f,
  D as g,
  y as h,
  w as i,
  j,
  g as k,
  A as l,
  F as m,
  x as n,
  $ as o,
  v as t,
  N as u
};
