function parseBigInt(value, precision = 18n) {
  if (precision < 0n) throw new Error(`parseBigInt: precision must be positive, got ${precision}`);
  const cleanedValue = value.replace(/,/g, "").trim();
  if (cleanedValue === "" || cleanedValue === "-" || cleanedValue === "." || cleanedValue === "-.") return null;
  const [integerPart, decimalPart = "", somethingAfterDecimalPart] = cleanedValue.split(".");
  if (integerPart.trim() !== integerPart) return null;
  if (decimalPart.trim() !== decimalPart) return null;
  if (somethingAfterDecimalPart !== void 0) return null;
  try {
    const precisionNumber = Number(precision);
    return BigInt(`${integerPart}${decimalPart.slice(0, precisionNumber).padEnd(precisionNumber, "0")}`);
  } catch {
    return null;
  }
}
export {
  parseBigInt
};
