var _a;
import { createSlice } from '@reduxjs/toolkit';
import { createSelector } from 'reselect';
export var initialState = {
    showDialog: false,
    displayButton: true,
    disableCreateNewUser: false,
    loading: false,
    loadingMessage: undefined,
};
export var swUIlice = createSlice({
    name: 'swUI',
    initialState: initialState,
    reducers: {
        showDialog: function (state, action) {
            state.showDialog = action.payload;
        },
        setDisableCreateNewUser: function (state, action) {
            state.disableCreateNewUser = action.payload;
        },
        setDisplayButton: function (state, action) {
            state.displayButton = action.payload;
        },
        setLoading: function (state, action) {
            state.loading = action.payload;
        },
        startLoading: function (state, action) {
            state.loading = true;
            state.loadingMessage = action.payload;
        },
        setLoadingMessage: function (state, action) {
            state.loadingMessage = action.payload;
        },
        setLoadingData: function (state, action) {
            state.loading = action.payload.loading;
            state.loadingMessage = action.payload.loadingMessage;
        },
        loadingFinished: function (state, action) {
            state.loading = false;
            state.loadingMessage = undefined;
        },
    },
});
export var setDisplayButton = (_a = swUIlice.actions, _a.setDisplayButton), showDialog = _a.showDialog, setLoading = _a.setLoading, setDisableCreateNewUser = _a.setDisableCreateNewUser, setLoadingMessage = _a.setLoadingMessage, setLoadingData = _a.setLoadingData, loadingFinished = _a.loadingFinished, startLoading = _a.startLoading;
export var isOpen = createSelector(function (state) { return state.swUI.showDialog; }, function (isShown) { return isShown; });
export var showButton = createSelector(function (state) { return state.swUI.displayButton; }, function (display) { return display; });
export var loadingInProgress = createSelector(function (state) { return state.swUI.loading; }, function (isLoading) { return isLoading; });
export var loadingData = createSelector(function (state) {
    return {
        loading: state.swUI.loading,
        loadingMessage: state.swUI.loadingMessage,
    };
}, function (isLoading) { return isLoading; });
export default swUIlice.reducer;
