import { assocPath } from 'ramda';
const initialState = {
    dbPendingWrites: 0,
    syncState: {
        status: 'inactive',
        entryStatus: {},
    },
    services: {
        db: { status: 'inactive' },
        ipfs: { status: 'inactive' },
        sync: { status: 'inactive' },
    },
};
function backendReducer(state = initialState, action) {
    switch (action.type) {
        case 'indexeddb_write': {
            return assocPath(['dbPendingWrites'], action.value, state);
        }
        case 'sync_status': {
            return assocPath(['syncState'], Object.assign(Object.assign({}, state.syncState), action.value), state);
        }
        case 'sync_entry': {
            const { entry, state: entryState } = action.value;
            const updatedEntry = Object.assign(Object.assign(Object.assign({}, state.syncState.entryStatus[entry]), { done: false }), entryState);
            return assocPath(['syncState', 'entryStatus', entry], updatedEntry, state);
        }
        case 'service_status': {
            const { name, status, message } = action.value;
            return assocPath(['services', name], { status, message }, state);
        }
        default:
            return state;
    }
}
export default backendReducer;
//# sourceMappingURL=backend.js.map