"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.isDevelopment = isDevelopment;
exports.getRegistry = getRegistry;
exports.defaultValue = defaultValue;
exports.mapSchema = mapSchema;
function isDevelopment() {
  return process.env.NODE_ENV !== "production";
}

function getRegistry() {
  return {
    fields: require("./components/index.js").default
  };
}

function defaultValue(_ref) {
  var properties = _ref.properties;

  var defVal = Object.keys(properties).reduce(function (agg, field) {
    if (properties[field].default !== undefined) {
      agg[field] = properties[field].default;
    }
    return agg;
  }, {});
  return defVal;
}

function mapSchema(events, schema, mapping) {
  if (!mapping) {
    return events;
  }

  var defVal = defaultValue(schema.properties ? schema : schema.items);
  var mappedEvents = events.map(function (event) {
    var mappedEvent = Object.keys(mapping).reduce(function (agg, field) {
      var schemaField = mapping[field];
      agg[schemaField] = event[field];
      return agg;
    }, Object.assign({}, defVal));
    return mappedEvent;
  });

  return mappedEvents;
}