import { isNil, checkValueIsFilled, checkValueIsEmpty, isNotNil, checkEveryValueIsEmpty, checkSomeValueIsEmpty } from '@angular-ru/cdk/utils';

const DEFAULT_DIGITS = 3;
const EXPONENTIAL_PARTS_LENGTH = 2;
const NUMBER_SYSTEM = 10;
const DEFAULT_PRECISSION = 8;
const PRECISSION_SECOND = 2;

function trim(number) {
    const split = number.split('.') ?? [];
    const parts = removeZerosAtTheBeginning(split);
    if (isNil(parts[1])) {
        return parts[0] ?? '';
    }
    else {
        return `${parts[0]}.${parts[1]}`;
    }
}
// eslint-disable-next-line max-lines-per-function, complexity
function add(inputA, inputB = '0') {
    let a = inputA;
    let b = inputB;
    let neg = 0;
    let ind = -1;
    // check for negatives
    if (inputA.toString()[0] === '-') {
        neg++;
        ind = 1;
        a = inputA.toString().substring(1);
    }
    if (inputB[0] === '-') {
        neg++;
        ind = EXPONENTIAL_PARTS_LENGTH;
        b = inputB.substring(1);
    }
    const padResult = pad(trim(a), trim(b));
    a = padResult[0];
    b = padResult[1];
    if (neg === 1) {
        if (ind === 1) {
            a = compliment(a);
        }
        else {
            b = compliment(b);
        }
    }
    const result = addCore(a, b);
    if (!neg) {
        return trim(result);
    }
    else if (neg === EXPONENTIAL_PARTS_LENGTH) {
        return `-${trim(result)}`;
    }
    else {
        if (a.length < result.length) {
            return trim(result.substring(1));
        }
        else {
            return `-${trim(compliment(result))}`;
        }
    }
}
// eslint-disable-next-line max-lines-per-function, complexity
function pad(inputA, inputB) {
    const partsA = inputA.toString().split('.');
    const partsB = inputB.toString().split('.');
    // pad integral part
    let length1 = partsA[0]?.length ?? 0;
    let length2 = partsB[0]?.length ?? 0;
    let larger = Math.abs(length1 - length2);
    if (length1 > length2) {
        partsB[0] = getIntegralPart(partsB, larger);
    }
    else {
        partsA[0] = getIntegralPart(partsA, larger);
    }
    // pad fractional part
    length1 = checkValueIsFilled(partsA[1]) ? partsA[1].length : 0;
    length2 = checkValueIsFilled(partsB[1]) ? partsB[1].length : 0;
    larger = Math.abs(length1 - length2);
    if (length1 || length2) {
        if (length1 > length2) {
            partsB[1] = getFractionalPart(partsB, larger);
        }
        else {
            partsA[1] = getFractionalPart(partsA, larger);
        }
    }
    const a = getPadFormat(partsA);
    const b = getPadFormat(partsB);
    return [a, b];
}
function compliment(num) {
    let s = '';
    const part = num.split('.')[1];
    const ld = checkValueIsFilled(part) ? part.length : 0;
    for (const element of num) {
        s += getPreparedDigit(element ?? '');
    }
    const one = ld > 0 ? `0.${new Array(ld).join('0')}1` : '1';
    return addCore(s, one);
}
function getPreparedDigit(char) {
    const isDigit = char >= '0' && char <= '9';
    if (isDigit) {
        // eslint-disable-next-line @typescript-eslint/no-magic-numbers
        return 9 - parseInt(char);
    }
    else {
        return char;
    }
}
function getIntegralPart(parts, larger) {
    return new Array(larger + 1).join('0') + (checkValueIsFilled(parts[0]) ? parts[0] : '');
}
function getFractionalPart(parts, larger) {
    return (checkValueIsFilled(parts[1]) ? parts[1] : '') + new Array(larger + 1).join('0');
}
function getPadFormat(parts) {
    return parts[0] + (checkValueIsFilled(parts[1]) ? `.${parts[1]}` : '');
}
function removeZerosAtTheBeginning(parts) {
    const result = [...parts];
    if (checkValueIsEmpty(result[0])) {
        result[0] = '0';
    }
    while (result[0][0] === '0' && result[0].length > 1) {
        result[0] = result[0].substring(1);
    }
    return result;
}
function addCore(inputA, inputB) {
    const parts = pad(inputA, inputB);
    const a = parts[0] ?? '';
    const b = parts[1] ?? '';
    const calculateResult = calculateCarryAndSum(a, b);
    const sum = calculateResult.sum;
    const carry = calculateResult.carry;
    return carry ? carry.toString() + sum : sum;
}
function calculateCarryAndSum(a, b) {
    let sum = '';
    let carry = 0;
    for (let i = a.length - 1; i >= 0; i--) {
        if (a[i] === '.') {
            sum = `.${sum}`;
            continue;
        }
        const temp = parseInt(a[i] ?? '') + parseInt(b[i] ?? '') + carry;
        sum = (temp % NUMBER_SYSTEM) + sum;
        carry = Math.floor(temp / NUMBER_SYSTEM);
    }
    return { sum, carry };
}

function compareTo(a, b) {
    const onlyOneNegative = compareIfOnlyOneNegative(a, b);
    if (isNotNil(onlyOneNegative)) {
        return onlyOneNegative;
    }
    const bothNegative = compareIfBothNegative(a, b);
    if (isNotNil(bothNegative)) {
        return bothNegative;
    }
    const bothPositive = compareIfBothPositive(a, b);
    if (isNotNil(bothPositive)) {
        return bothPositive;
    }
    return 0;
}
function compareIfOnlyOneNegative(a, b) {
    let result = null;
    if (a[0] === '-' && b[0] !== '-') {
        result = -1;
    }
    if (a[0] !== '-' && b[0] === '-') {
        result = 1;
    }
    return result;
}
function compareIfBothNegative(inputA, inputB) {
    if (inputA[0] !== '-' || inputB[0] !== '-') {
        return null;
    }
    // eslint-disable-next-line deprecation/deprecation
    const a = inputA.substr(1);
    // eslint-disable-next-line deprecation/deprecation
    const b = inputB.substr(1);
    const compareModulesResult = compareNumberModules(a, b);
    if (compareModulesResult === 1) {
        return -1;
    }
    if (compareModulesResult === -1) {
        return 1;
    }
    return compareModulesResult;
}
function compareIfBothPositive(a, b) {
    return compareNumberModules(a, b);
}
function compareNumberModules(inputA, inputB) {
    const a = pad(inputA, inputB)[0];
    const b = pad(inputA, inputB)[1];
    if (a.localeCompare(b) === 0) {
        return 0;
    }
    // eslint-disable-next-line unicorn/no-for-loop
    for (let i = 0; i < a.length; i++) {
        const compareDigitsResult = compareDigits(a[i] ?? '', b[i] ?? '');
        if (compareDigitsResult === 0) {
            continue;
        }
        else {
            return compareDigitsResult;
        }
    }
    return 0;
}
function compareDigits(a, b) {
    if (a === b) {
        return 0;
    }
    if (a > b) {
        return 1;
    }
    return -1;
}

/**
 *
 * @param input the number to round
 * @param n precision
 * @param mode Rounding Mode
 */
function roundOff(input, n = 0, mode = 4 /* HALF_EVEN */) {
    if (mode === 6 /* UNNECESSARY */) {
        throw new Error('UNNECESSARY Rounding Mode has not yet been implemented');
    }
    if (typeof input == 'number')
        input = input.toString();
    let neg = false;
    if (input[0] === '-') {
        neg = true;
        input = input.substring(1);
    }
    let parts = input.split('.'), partInt = parts[0], partDec = parts[1];
    //handle case of -ve n: roundOff(12564,-2)=12600
    if (n < 0) {
        n = -n;
        if ((partInt?.length ?? 0) <= n)
            return '0';
        else {
            let prefix = partInt?.substr(0, (partInt?.length ?? 0) - n);
            input = prefix + '.' + partInt?.substr((partInt?.length ?? 0) - n) + partDec;
            prefix = roundOff(input, 0, mode);
            return (neg ? '-' : '') + prefix + new Array(n + 1).join('0');
        }
    }
    // handle case when integer output is desired
    if (n == 0) {
        if (greaterThanFive(parts[1], partInt, neg, mode)) {
            return (neg ? '-' : '') + increment(partInt);
        }
        return (neg ? '-' : '') + partInt;
    }
    // handle case when n>0
    if (!parts[1]) {
        return (neg ? '-' : '') + partInt + '.' + new Array(n + 1).join('0');
    }
    else if (parts[1].length < n) {
        return (neg ? '-' : '') + partInt + '.' + parts[1] + new Array(n - parts[1].length + 1).join('0');
    }
    partDec = parts[1].substring(0, n);
    let rem = parts[1].substring(n);
    if (rem && greaterThanFive(rem, partDec, neg, mode)) {
        partDec = increment(partDec);
        if (partDec.length > n) {
            return (neg ? '-' : '') + increment(partInt, parseInt(partDec[0] ?? '')) + '.' + partDec.substring(1);
        }
    }
    return (neg ? '-' : '') + partInt + '.' + partDec;
}
function greaterThanFive(part, pre, neg, mode) {
    if (!part || part === new Array(part.length + 1).join('0'))
        return false;
    // #region UP, DOWN, CEILING, FLOOR
    if (mode === 1 /* DOWN */ ||
        (!neg && mode === 2 /* FLOOR */) ||
        (neg && mode === 0 /* CEILING */))
        return false;
    if (mode === 7 /* UP */ || (neg && mode === 2 /* FLOOR */) || (!neg && mode === 0 /* CEILING */))
        return true;
    // #endregion
    // case when part !== five
    let five = '5' + new Array(part.length).join('0');
    if (part > five)
        return true;
    else if (part < five)
        return false;
    // case when part === five
    switch (mode) {
        case 3 /* HALF_DOWN */:
            return false;
        case 5 /* HALF_UP */:
            return true;
        case 4 /* HALF_EVEN */:
        default:
            return parseInt(pre[pre.length - 1]) % 2 == 1;
    }
}
function increment(part, c = 0) {
    if (!c)
        c = 1;
    if (typeof part == 'number')
        part.toString();
    let l = part.length - 1, s = '';
    for (let i = l; i >= 0; i--) {
        let x = parseInt(part[i]) + c;
        if (x == 10) {
            c = 1;
            x = 0;
        }
        else {
            c = 0;
        }
        s += x;
    }
    if (c)
        s += c;
    return s.split('').reverse().join('');
}

// eslint-disable-next-line max-lines-per-function,complexity,sonarjs/cognitive-complexity
function divide(inputDividend, inputDivisor, inputPrecision = DEFAULT_PRECISSION) {
    checkDivisionByZero(inputDivisor);
    let dividend = inputDividend.toString();
    let divisor = inputDivisor.toString();
    dividend = removeTrailingZeros(dividend);
    divisor = removeTrailingZeros(divisor);
    if (dividend === '0') {
        return '0';
    }
    const isNegative = checkNegative(divisor, dividend);
    divisor = getAbsoluteValue(divisor);
    dividend = getAbsoluteValue(dividend);
    dividend = parseDividend(dividend, divisor);
    divisor = trim(divisor.replace('.', ''));
    const dl = divisor.length;
    let precission = 0;
    let quotient = '';
    let dividendBeforePoint = dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl
        ? dividend.substring(0, dl + 1)
        : dividend.substring(0, dl);
    dividend =
        dividend.indexOf('.') > -1 && dividend.indexOf('.') < dl ? dividend.substring(dl + 1) : dividend.substring(dl);
    if (dividendBeforePoint.indexOf('.') > -1) {
        let shift = dividendBeforePoint.length - dividendBeforePoint.indexOf('.') - 1;
        dividendBeforePoint = dividendBeforePoint.replace('.', '');
        if (dl > dividendBeforePoint.length) {
            shift += dl - dividendBeforePoint.length;
            dividendBeforePoint = dividendBeforePoint + new Array(dl - dividendBeforePoint.length + 1).join('0');
        }
        precission = shift;
        quotient = `0.${new Array(shift).join('0')}`;
    }
    while (precission <= inputPrecision + PRECISSION_SECOND) {
        let qt = 0;
        while (parseInt(dividendBeforePoint) >= parseInt(divisor)) {
            dividendBeforePoint = add(dividendBeforePoint, `-${divisor}`);
            qt++;
        }
        quotient += qt;
        const isDividendEmpty = checkValueIsEmpty(dividend);
        if (isDividendEmpty) {
            if (!precission) {
                quotient += '.';
            }
            precission++;
            dividendBeforePoint = `${dividendBeforePoint}0`;
        }
        else {
            if (dividend[0] === '.') {
                quotient += '.';
                precission++;
                dividend = dividend.substring(1);
            }
            dividendBeforePoint = dividendBeforePoint + dividend.substring(0, 1);
            dividend = dividend.substring(1);
        }
    }
    return (isNegative ? '-' : '') + trim(roundOff(quotient, inputPrecision));
}
function parseDividend(inputDividend, divisor) {
    let dividend = inputDividend;
    const ptDivisor = divisor.indexOf('.') > 0 ? divisor.length - divisor.indexOf('.') - 1 : -1;
    if (ptDivisor >= 0) {
        dividend = parseDividendByPositiveDividend(dividend, ptDivisor);
    }
    return dividend;
}
function parseDividendByPositiveDividend(inputDividend, ptDivisor) {
    let dividend = inputDividend;
    const ptDividend = dividend.indexOf('.') > 0 ? dividend.length - dividend.indexOf('.') - 1 : -1;
    if (ptDividend === -1) {
        dividend = trim(dividend + new Array(ptDivisor + 1).join('0'));
    }
    else {
        if (ptDivisor > ptDividend) {
            dividend = dividend.replace('.', '');
            dividend = trim(dividend + new Array(ptDivisor - ptDividend + 1).join('0'));
        }
        else if (ptDivisor < ptDividend) {
            dividend = dividend.replace('.', '');
            const i = dividend.length - ptDividend + ptDivisor;
            dividend = trim(`${dividend.substring(0, i)}.${dividend.substring(i)}`);
        }
        else if (ptDivisor === ptDividend) {
            dividend = trim(dividend.replace('.', ''));
        }
    }
    return dividend;
}
function removeTrailingZeros(value) {
    return value.replace(/(\.\d*?[1-9])0+$/g, '$1').replace(/\.0+$/, '');
}
function checkDivisionByZero(divisor) {
    if (divisor === 0 || divisor === '0') {
        throw new Error('Cannot divide by 0');
    }
}
function checkNegative(divisor, dividend) {
    let isNegative = false;
    if (divisor[0] === '-') {
        isNegative = !isNegative;
    }
    if (dividend[0] === '-') {
        isNegative = !isNegative;
    }
    return isNegative;
}
function getAbsoluteValue(value) {
    return value[0] === '-' ? value.substring(1) : value;
}

/* eslint-disable */
function multiply(number1, number2) {
    number1 = number1.toString();
    number2 = number2.toString();
    /*Filter numbers*/
    let negative = 0;
    if (number1[0] == '-') {
        negative++;
        number1 = number1.substr(1);
    }
    if (number2[0] == '-') {
        negative++;
        number2 = number2.substr(1);
    }
    number1 = trailZero(number1);
    number2 = trailZero(number2);
    let decimalLength1 = 0;
    let decimalLength2 = 0;
    if (number1.indexOf('.') != -1) {
        decimalLength1 = number1.length - number1.indexOf('.') - 1;
    }
    if (number2.indexOf('.') != -1) {
        decimalLength2 = number2.length - number2.indexOf('.') - 1;
    }
    let decimalLength = decimalLength1 + decimalLength2;
    number1 = trailZero(number1.replace('.', ''));
    number2 = trailZero(number2.replace('.', ''));
    if (number1.length < number2.length) {
        let temp = number1;
        number1 = number2;
        number2 = temp;
    }
    if (number2 == '0') {
        return '0';
    }
    /*
     * Core multiplication
     */
    let length = number2.length;
    let carry = 0;
    let positionVector = [];
    let currentPosition = length - 1;
    let result = '';
    for (let i = 0; i < length; i++) {
        positionVector[i] = number1.length - 1;
    }
    for (let i = 0; i < 2 * number1.length; i++) {
        let sum = 0;
        for (let j = number2.length - 1; j >= currentPosition && j >= 0; j--) {
            if ((positionVector[j] ?? 0) > -1 && (positionVector[j] ?? 0) < number1.length) {
                sum += parseInt(number1[positionVector[j]--]) * parseInt(number2[j]);
            }
        }
        sum += carry;
        carry = Math.floor(sum / 10);
        result = (sum % 10) + result;
        currentPosition--;
    }
    /*
     * Formatting result
     */
    result = trailZero(adjustDecimal(result, decimalLength));
    if (negative == 1) {
        result = '-' + result;
    }
    return result;
}
/*
 * Add decimal point
 */
function adjustDecimal(number, decimal) {
    if (decimal == 0)
        return number;
    else {
        number = decimal >= number.length ? new Array(decimal - number.length + 1).join('0') + number : number;
        return number.substr(0, number.length - decimal) + '.' + number.substr(number.length - decimal, decimal);
    }
}
/*
 * Removes zero from front and back*/
function trailZero(number) {
    while (number[0] == '0') {
        number = number.substr(1);
    }
    if (number.indexOf('.') != -1) {
        while (number[number.length - 1] == '0') {
            number = number.substr(0, number.length - 1);
        }
    }
    if (number == '' || number == '.') {
        number = '0';
    }
    else if (number[number.length - 1] == '.') {
        number = number.substr(0, number.length - 1);
    }
    if (number[0] == '.') {
        number = '0' + number;
    }
    return number;
}

function subtract(number1, number2) {
    const a = number1.toString();
    let b = number2.toString();
    b = negate(b);
    return add(a, b);
}
function negate(number) {
    let result = '';
    if (number[0] === '-') {
        // eslint-disable-next-line deprecation/deprecation
        result = number.substr(1);
    }
    else {
        result = `-${number}`;
    }
    return result;
}

function modulus(inputDividend, inputDivisor) {
    validateDividend(inputDividend);
    let dividend = inputDividend.toString();
    let divisor = inputDivisor.toString();
    validate(dividend);
    validate(divisor);
    let sign = '';
    if (dividend[0] === '-') {
        sign = '-';
        // eslint-disable-next-line deprecation/deprecation
        dividend = dividend.substr(1);
    }
    if (divisor[0] === '-') {
        // eslint-disable-next-line deprecation/deprecation
        divisor = divisor.substr(1);
    }
    const result = subtract(dividend, multiply(divisor, roundOff(divide(dividend, divisor), 0, 2 /* FLOOR */)));
    return sign + result;
}
function validate(operand) {
    if (operand.indexOf('.') !== -1) {
        throw new Error('Modulus of non-integers not supported');
    }
}
function validateDividend(dividend) {
    if (dividend === 0 || dividend === '0') {
        throw new Error('Cannot divide by 0');
    }
}

class BigDecimal {
    constructor(num = '0') {
        this.value = BigDecimal.validate(num);
    }
    static negate(inputNum) {
        const num = BigDecimal.validate(inputNum);
        return negate(num);
    }
    static ceil(inputNum) {
        const num = BigDecimal.validate(inputNum);
        if (num.indexOf('.') === -1) {
            return num;
        }
        return BigDecimal.round(num, 0, 0 /* CEILING */);
    }
    static add(inputA, inputB) {
        const a = BigDecimal.validate(inputA);
        const b = BigDecimal.validate(inputB);
        return add(a, b);
    }
    static subtract(inputA, inputB) {
        const a = BigDecimal.validate(inputA);
        const b = BigDecimal.validate(inputB);
        return subtract(a, b);
    }
    static multiply(inputA, inputB) {
        const a = BigDecimal.validate(inputA);
        const b = BigDecimal.validate(inputB);
        return multiply(a, b);
    }
    static divide(inputA, inputB, precision) {
        const a = BigDecimal.validate(inputA);
        const b = BigDecimal.validate(inputB);
        return divide(a, b, precision);
    }
    static modulus(inputA, inputB) {
        const a = BigDecimal.validate(inputA);
        const b = BigDecimal.validate(inputB);
        return modulus(a, b);
    }
    static compareTo(inputA, inputB) {
        const a = BigDecimal.validate(inputA);
        const b = BigDecimal.validate(inputB);
        return compareTo(a, b);
    }
    static round(inputA, precision = 0, mode = 4 /* HALF_EVEN */) {
        const a = BigDecimal.validate(inputA);
        if (isNaN(precision)) {
            throw new Error(`Precision is not a num: ${precision}`);
        }
        return roundOff(a, precision, mode);
    }
    static floor(inputA) {
        const a = BigDecimal.validate(inputA);
        if (a.indexOf('.') === -1) {
            return a;
        }
        return BigDecimal.round(a, 0, 2 /* FLOOR */);
    }
    static getPrettyValue(inputNum, digits, separator) {
        let num = inputNum;
        const prettyParams = validatePrettyParams({ digits, separator });
        num = BigDecimal.validate(num);
        const neg = num.charAt(0) === '-';
        if (neg) {
            num = num.substring(1);
        }
        let numLength = num.indexOf('.');
        numLength = numLength > 0 ? numLength : num.length;
        const temp = getTemp(prettyParams, numLength, num);
        return (neg ? '-' : '') + temp + num.substring(numLength);
    }
    static validate(inputNum) {
        let num = prepareNum(inputNum);
        const isPoint = num.startsWith('.');
        const isDashPoint = num.startsWith('-.');
        if (isPoint) {
            num = `0${num}`;
        }
        else if (isDashPoint) {
            num = `-0${num.substr(1)}`;
        }
        if (/e/i.test(num)) {
            num = getExponentiation(num);
        }
        return num;
    }
    getValue() {
        return this.value;
    }
    getPrettyValue(digits, separator) {
        return BigDecimal.getPrettyValue(this.value, digits, separator);
    }
    round(precision = 0, mode = 4 /* HALF_EVEN */) {
        if (isNaN(precision)) {
            throw new Error(`Precision is not a num: ${precision}`);
        }
        return new BigDecimal(roundOff(this.value, precision, mode));
    }
    floor() {
        if (this.value.indexOf('.') === -1) {
            return new BigDecimal(this.value);
        }
        return new BigDecimal(this.value).round(0, 2 /* FLOOR */);
    }
    ceil() {
        if (this.value.indexOf('.') === -1) {
            return new BigDecimal(this.value);
        }
        return new BigDecimal(this.value).round(0, 0 /* CEILING */);
    }
    add(num) {
        return new BigDecimal(add(this.value, num.getValue()));
    }
    subtract(num) {
        return new BigDecimal(subtract(this.value, num.getValue()));
    }
    multiply(num) {
        return new BigDecimal(multiply(this.value, num.getValue()));
    }
    divide(num, precision) {
        return new BigDecimal(divide(this.value, num.getValue(), precision));
    }
    modulus(num) {
        return new BigDecimal(modulus(this.value, num.getValue()));
    }
    compareTo(num) {
        return compareTo(this.value, num.getValue());
    }
    negate() {
        return new BigDecimal(negate(this.value));
    }
}
function validatePrettyParams(params) {
    const result = { ...params };
    if (checkEveryValueIsEmpty(params.digits, params.separator)) {
        result.digits = DEFAULT_DIGITS;
        result.separator = ',';
    }
    else if (checkSomeValueIsEmpty(params.digits, params.separator)) {
        throw new Error('Illegal Arguments. Should pass both digits and separator or pass none');
    }
    return result;
}
function getTemp(params, length_, num) {
    let temp = '';
    for (let i = length_; i > 0;) {
        if (i < params?.digits) {
            params.digits = i;
            i = 0;
        }
        else {
            i -= params?.digits;
        }
        temp =
            num.substring(i, i + params?.digits) +
                (i < length_ - params?.digits && i >= 0 ? params.separator : '') +
                temp;
    }
    return temp;
}
function getExponentiation(inputNum) {
    const numParts = inputNum.split(/[Ee]/);
    if (numParts.length !== EXPONENTIAL_PARTS_LENGTH) {
        return inputNum;
    }
    let mantisa = trim(numParts[0] ?? '');
    let exponent = numParts[1] ?? '';
    let offset = 0;
    if (mantisa.indexOf('.') >= 0) {
        exponent = parseInt(exponent) + mantisa.indexOf('.');
        mantisa = mantisa.replace('.', '');
        offset = 1;
    }
    return prepareExponentiation(mantisa, exponent, offset);
}
function prepareExponentiation(mantisa, exponent, offset) {
    let num = '';
    if (mantisa.length < exponent) {
        num = mantisa + new Array(exponent - mantisa.length + 1).join('0');
    }
    else if (mantisa.length >= exponent && exponent > 0) {
        num =
            trim(mantisa.substring(0, exponent)) + (mantisa.length > exponent ? `.${mantisa.substring(exponent)}` : '');
    }
    else {
        num = `0.${new Array(-exponent + offset).join('0')}${mantisa}`;
    }
    return num;
}
function prepareNum(inputNum) {
    let num = inputNum;
    if (checkValueIsFilled(inputNum)) {
        num = inputNum.toString();
        if (isNaN(num)) {
            throw new Error(`Parameter is not a num: ${num}`);
        }
        if (num[0] === '+') {
            num = num.substring(1);
        }
    }
    else {
        num = '0';
    }
    return num;
}

/**
 * Generated bundle index. Do not edit.
 */

export { BigDecimal };
//# sourceMappingURL=angular-ru-cdk-big-decimal.mjs.map
