"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.flat = exports.isDefined = void 0;
function isDefined(value) {
    if (typeof value === 'object') {
        return !!value && Object.keys(value).length !== 0;
    }
    return !(value === undefined || value === null || value === '' || value === 0 || value === '0');
}
exports.isDefined = isDefined;
function flat(data, prefix = '') {
    if (!isDefined(data)) {
        return undefined;
    }
    let result = {};
    for (const key in data) {
        if (typeof data[key] == 'object' && data[key] !== null) {
            const flatten = flat(data[key], prefix + '.' + key);
            result = { ...result, ...flatten };
        }
        else {
            const stringifiedValue = stringify(data[key]);
            result[(prefix + '.' + key).replace(/^\./, '')] = stringifiedValue;
        }
    }
    return result;
}
exports.flat = flat;
function stringify(value) {
    if (typeof value === 'string') {
        return value;
    }
    if (typeof value === 'number' || typeof value === 'boolean') {
        return value.toString();
    }
    return JSON.stringify(value);
}
//# sourceMappingURL=utils.js.map