"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.reducer = exports.getInitialState = exports.initialState = exports.actionTypes = void 0;
exports.actionTypes = {
    LOADING: '_loading',
    SET_COLORS: '_set_colors',
    SET_LOGOS: '_set_logos',
    SET_SLOGANS: '_set_slogans'
};
exports.initialState = {
    loading: false,
    colors: [],
    logos: [],
    slogans: [],
    modified: false
};
function getInitialState(data) {
    if (data) {
        return Object.assign(Object.assign({}, exports.initialState), data);
    }
    return exports.initialState;
}
exports.getInitialState = getInitialState;
function reducer(state, action) {
    let _state = Object.assign({}, state);
    switch (action.type) {
        case exports.actionTypes.LOADING:
            _state = Object.assign(Object.assign({}, state), { loading: action.payload.loading });
            break;
        case exports.actionTypes.SET_COLORS:
            _state = Object.assign(Object.assign(Object.assign(Object.assign({}, state), { colors: action.payload.colors, logos: state.logos }), (action.payload.loading !== undefined && { loading: action.payload.loading })), { modified: true });
            break;
        case exports.actionTypes.SET_LOGOS:
            _state = Object.assign(Object.assign(Object.assign(Object.assign({}, state), { logos: action.payload.logos, colors: state.colors }), (action.payload.loading !== undefined && { loading: action.payload.loading })), { modified: true });
            break;
        case exports.actionTypes.SET_SLOGANS:
            _state = Object.assign(Object.assign(Object.assign(Object.assign({}, state), { slogans: action.payload.slogans, logos: state.logos, colors: state.colors }), (action.payload.loading !== undefined && { loading: action.payload.loading })), { modified: true });
            break;
    }
    return _state;
}
exports.reducer = reducer;
