'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const initialMessagesState = {
    messages: [],
};
function messagesReducer(state, action) {
    switch (action.type) {
        case 'add':
            return Object.assign(Object.assign({}, state), { messages: [...state.messages, action.message] });
        case 'remove':
            return Object.assign(Object.assign({}, state), { messages: state.messages.filter((message) => message.id !== action.messageId) });
        case 'clear':
            return Object.assign(Object.assign({}, state), { messages: [] });
        default:
            return state;
    }
}

exports.initialMessagesState = initialMessagesState;
exports.messagesReducer = messagesReducer;
