"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parsedEmbeddedData = parsedEmbeddedData;
exports.generateRandomId = generateRandomId;
exports.parsedTransactionDate = parsedTransactionDate;
function parsedEmbeddedData(data) {
    const parsedData = {};
    Object.keys(data || {}).forEach((key) => {
        if (!data) {
            return;
        }
        if (typeof data[key] === 'string') {
            parsedData[key] = data[key];
        }
        else if (typeof data[key] === 'number') {
            parsedData[key] = data[key];
        }
        else if (typeof data[key] === 'boolean') {
            parsedData[key] = data[key];
        }
        else {
            try {
                parsedData[key] = JSON.stringify(data);
            }
            catch (err) {
                parsedData[key] = data.toString();
            }
        }
    });
    return parsedData;
}
function generateRandomId(length = 16) {
    const patternList = 'abcdefghijklmnopqrstuvwxyz123456789';
    const result = [];
    for (let i = 0; i < length; i++) {
        result.push(patternList[Math.floor(Math.random() * patternList.length)]);
    }
    return result.join('');
}
function parsedTransactionDate(transactionDate) {
    let dateObject = new Date();
    if (typeof transactionDate === 'number') {
        dateObject = new Date(transactionDate);
    }
    else if (typeof transactionDate === 'string') {
        const parsedDate = Date.parse(transactionDate);
        if (!isNaN(parsedDate)) {
            dateObject = new Date(parsedDate);
        }
    }
    return dateObject
        .toISOString()
        .replace('T', ' ')
        .replace(/\.\d{3}Z/, '');
}
//# sourceMappingURL=utils.js.map