"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getParamValue = exports.getParamArray = exports.getNameValuePairs = exports.getEnabledParams = void 0;
const lodash_1 = require("lodash");
function getEnabledParams(params) {
    const enabledParams = [];
    for (const param of params) {
        if (typeof param !== 'object')
            continue;
        if (param.isEnabled && param.name !== '') {
            enabledParams.push(param);
        }
    }
    return enabledParams;
}
exports.getEnabledParams = getEnabledParams;
function getNameValuePairs(params, options = { enabled: false }) {
    const filteredParams = options.enabled ? getEnabledParams(params) : params;
    const paramObj = {};
    for (const param of filteredParams) {
        paramObj[param.name] = param.value;
    }
    return paramObj;
}
exports.getNameValuePairs = getNameValuePairs;
function getParamArray(param = {}) {
    const paramArray = [];
    lodash_1.forEach(param, (val, key) => {
        if (Array.isArray(val)) {
            paramArray.push(...val.map(value => ({
                name: key,
                value,
                isEnabled: true,
            })));
        }
        else {
            paramArray.push({
                name: key,
                value: val,
                isEnabled: true,
            });
        }
    });
    return paramArray;
}
exports.getParamArray = getParamArray;
function getParamValue(params = {}, key) {
    for (const paramKey in params) {
        if (paramKey.toLowerCase() === key.toLowerCase()) {
            return params[paramKey];
        }
    }
    return undefined;
}
exports.getParamValue = getParamValue;
//# sourceMappingURL=params.js.map