'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
const ADD_OPTION_LISTS = exports.ADD_OPTION_LISTS = 'ADD_OPTION_LISTS';

const addOptionLists = exports.addOptionLists = optionLists => {
  const mergedOptionLists = {};

  Object.keys(optionLists).forEach(optionListName => {
    var _optionLists$optionLi = optionLists[optionListName];
    const values = _optionLists$optionLi.values,
          messages = _optionLists$optionLi.messages;


    mergedOptionLists[optionListName] = values.map(value => {
      const merged = {
        value
      };

      if (messages && messages[value]) {
        merged.message = messages[value];
      }

      return merged;
    });
  });

  return {
    type: ADD_OPTION_LISTS,
    payload: mergedOptionLists
  };
};