// SPDX-License-Identifier: Apache-2.0
import BigDecimal from "../../../domain/context/shared/BigDecimal";
/* eslint-disable @typescript-eslint/no-explicit-any */
export default class CheckNums {
    static isWithinRange(value, min, max) {
        return this.isLessOrEqualThan(value, max) && this.isGreaterOrEqualThan(value, min);
    }
    static isLessThan(value, max) {
        if (value instanceof BigDecimal && max instanceof BigDecimal)
            return value.isLowerThan(max);
        return value < max;
    }
    static isGreaterThan(value, max) {
        if (value instanceof BigDecimal && max instanceof BigDecimal)
            return value.isGreaterThan(max);
        return value > max;
    }
    static isLessOrEqualThan(value, max) {
        if (value instanceof BigDecimal && max instanceof BigDecimal)
            return value.isLowerOrEqualThan(max);
        return value <= max;
    }
    static isGreaterOrEqualThan(value, max) {
        if (value instanceof BigDecimal && max instanceof BigDecimal)
            return value.isGreaterOrEqualThan(max);
        return value >= max;
    }
    static isBigInt(value) {
        try {
            BigInt(value);
            return true;
        }
        catch (err) {
            return false;
        }
    }
    static isBigDecimal(value) {
        try {
            if (value instanceof BigDecimal)
                return true;
            BigDecimal.fromString(value);
            return true;
        }
        catch (err) {
            return false;
        }
    }
    static hasMoreDecimals(from, to) {
        let val = from;
        if (typeof val === "string")
            val = BigDecimal.fromString(val);
        return val.format.decimals > to;
    }
    static isNumber(value) {
        try {
            return !isNaN(parseInt(value)) || !this.isBigInt(value);
        }
        catch (error) {
            return false;
        }
    }
}
