/**
 * Gets the value at path of object.
 * If the resolved value is undefined, the defaultValue is returned in its place.
 */
function getObjectValue(object, path, value) {
  if (!path) {
    return value;
  }

  var pathArray = Array.isArray(path) ? path : path.split(".").filter(function (key) {
    return key;
  });
  var pathArrayFlat = pathArray.flatMap(function (part) {
    return typeof part === "string" ? part.split(".") : part;
  });
  return pathArrayFlat.reduce(function (obj, key) {
    return obj && obj[key];
  }, object) || value;
}

export { getObjectValue as g };
