"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getNumFromStr = getNumFromStr;
exports.formatCurrency = formatCurrency;
const isNil_1 = __importDefault(require("lodash/isNil"));
const cn_ui_common_1 = require("@cainiaofe/cn-ui-common");
const utils_1 = require("../../utils");
function getNumFromStr(val, adapterLocale) {
    return (0, utils_1.isNumberStr)(`${val}`) ? formatCurrency(`${val}`, adapterLocale) : val;
}
function formatCurrency(val, adapterLocale) {
    if (adapterLocale) {
        return (0, cn_ui_common_1.numberFormat)(val, adapterLocale);
    }
    const [pre, suff] = val === null || val === void 0 ? void 0 : val.split('.');
    return `${Number(pre).toLocaleString('zh-CN')}${(0, isNil_1.default)(suff) ? '' : `.${suff}`}`;
}
