"use strict";
// SPDX-License-Identifier: Apache-2.0
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const BigDecimal_1 = __importDefault(require("../../../domain/context/shared/BigDecimal"));
/* eslint-disable @typescript-eslint/no-explicit-any */
class CheckNums {
    static isWithinRange(value, min, max) {
        return this.isLessOrEqualThan(value, max) && this.isGreaterOrEqualThan(value, min);
    }
    static isLessThan(value, max) {
        if (value instanceof BigDecimal_1.default && max instanceof BigDecimal_1.default)
            return value.isLowerThan(max);
        return value < max;
    }
    static isGreaterThan(value, max) {
        if (value instanceof BigDecimal_1.default && max instanceof BigDecimal_1.default)
            return value.isGreaterThan(max);
        return value > max;
    }
    static isLessOrEqualThan(value, max) {
        if (value instanceof BigDecimal_1.default && max instanceof BigDecimal_1.default)
            return value.isLowerOrEqualThan(max);
        return value <= max;
    }
    static isGreaterOrEqualThan(value, max) {
        if (value instanceof BigDecimal_1.default && max instanceof BigDecimal_1.default)
            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_1.default)
                return true;
            BigDecimal_1.default.fromString(value);
            return true;
        }
        catch (err) {
            return false;
        }
    }
    static hasMoreDecimals(from, to) {
        let val = from;
        if (typeof val === "string")
            val = BigDecimal_1.default.fromString(val);
        return val.format.decimals > to;
    }
    static isNumber(value) {
        try {
            return !isNaN(parseInt(value)) || !this.isBigInt(value);
        }
        catch (error) {
            return false;
        }
    }
}
exports.default = CheckNums;
