'use strict';

var PhoneInputBase = require('react-phone-number-input');

const localizeNumberFormat = (num, locale, maximumFractionDigits = 2) => {
    return Intl.NumberFormat(undefined, {
        maximumFractionDigits,
    }).format(num);
};
const convertLocalizedStringToNumber = (value) => {
    return Number(value.replace(/,/gi, '.'));
};
const formatPhoneNumber = (phone) => {
    try {
        const parseData = PhoneInputBase.parsePhoneNumber(phone, 'VN');
        if (!(parseData === null || parseData === void 0 ? void 0 : parseData.number)) {
            throw new Error('Invalid number');
        }
        return PhoneInputBase.formatPhoneNumber(parseData.number);
    }
    catch (error) {
        console.log('🚀 ~ formatPhoneNumber ~ error:', error);
        return phone;
    }
};

exports.convertLocalizedStringToNumber = convertLocalizedStringToNumber;
exports.formatPhoneNumber = formatPhoneNumber;
exports.localizeNumberFormat = localizeNumberFormat;
