"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.initErrorReducer = exports.INIT_ERROR_INITIAL_STATE = void 0;
var tslib_1 = require("tslib");
var array_1 = require("../utils/array");
var actions_1 = require("../constants/actions");
exports.INIT_ERROR_INITIAL_STATE = {
    options: {},
    error: undefined,
    includeStack: true,
    warnings: []
};
function initErrorReducer(state, action) {
    if (state === void 0) { state = exports.INIT_ERROR_INITIAL_STATE; }
    switch (action.type) {
        case actions_1.ActionType.INIT_ACKNOWLEDGE_WARNINGS:
            {
                return tslib_1.__assign(tslib_1.__assign({}, state), { warnings: [] });
            }
        case actions_1.ActionType.INIT_APP:
            {
                return tslib_1.__assign(tslib_1.__assign({}, state), { warnings: (0, array_1.makeUnique)(action.payload.warnings) });
            }
        case actions_1.ActionType.INIT_ERROR:
            {
                var payload = action.payload;
                var error = payload.error;
                var options = payload.options;
                var includeStack = payload.includeStack;
                if (typeof (includeStack) == 'undefined') {
                    includeStack = true;
                }
                return { error: error, options: options, includeStack: includeStack, warnings: [] };
            }
    }
    return state;
}
exports.initErrorReducer = initErrorReducer;
//# sourceMappingURL=init-error.js.map