"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.flattenObj = exports["default"] = void 0;

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _ramda = require("ramda");

var go = function go(obj) {
  return (0, _ramda.chain)(function (_ref) {
    var _ref2 = (0, _slicedToArray2["default"])(_ref, 2),
        key = _ref2[0],
        value = _ref2[1];

    if ((0, _ramda.type)(value) === 'Object' || (0, _ramda.type)(value) === 'Array') {
      return (0, _ramda.map)(function (_ref3) {
        var _ref4 = (0, _slicedToArray2["default"])(_ref3, 2),
            k = _ref4[0],
            v = _ref4[1];

        return ["".concat(key, ".").concat(k), v];
      }, go(value));
    } else {
      return [[key, value]];
    }
  }, (0, _ramda.toPairs)(obj));
};

var flattenObj = function flattenObj(obj) {
  return (0, _ramda.fromPairs)(go(obj));
};

exports.flattenObj = flattenObj;
var _default = flattenObj;
exports["default"] = _default;