/**
 * @description used for formatting amount inputs
 * @param {string} s - string to transform
 * @param {{int: number; fra: number}} limits - limit integer and fraction number amount
 */
export const transformToAmount = (s, limits) => {
    let result = s.replace(/,/g, ".").replace(/[^0-9\.]/g, "");
    const firstDotId = result.indexOf(".");
    if (firstDotId > -1) {
        let int = result.slice(0, firstDotId);
        let fra = result.slice(firstDotId + 1).replace(/\./g, "");
        if (limits) {
            int = int.slice(0, limits.int);
            fra = fra.slice(0, limits.fra);
        }
        result = `${int}.${fra}`;
    }
    else if (limits) {
        result = result.slice(0, limits.int);
    }
    if (result.length > 0 && result[0] === ".") {
        return "";
    }
    else if (result.length > 1 && result[0] === "0" && result[1] !== ".") {
        return result[0];
    }
    else {
        return result;
    }
};
/**
 * @description used for formatting substrate address inputs
 * @param {string} s - string to transform
 */
export const transformToBase58 = (s) => s.replace(/[^1-9A-HJ-NP-Za-km-z]/g, "");
/**
 * @description used for formatting evm & moonbeam address inputs
 * @param {string} s - string to transform
 */
export const transformToHex = (s) => {
    if (!s || s === "0" || s === "0x") {
        return s;
    }
    const hex = s.slice(2);
    return "0x" + hex.replace(/[^0-9a-fA-F]/g, "");
};
//# sourceMappingURL=utils.js.map