import { produce } from "immer";
import { ToolbarActions } from "../actions/toolbarActions";
const initialState = {
    myFoo: "",
    myBar: "",
    dashbarItems: [],
    dashbarItemKeys: [],
};
export const toolbarReducer = produce((state, action) => {
    ToolbarActions.match(action, {
        REORDER_DASHBAR_ITEMS: ({ oldIndex, newIndex }) => {
            const dashbarItemsInNewOrder = [...state.dashbarItems];
            const dashbarItemToMove = dashbarItemsInNewOrder[oldIndex];
            dashbarItemsInNewOrder.splice(oldIndex, 1);
            dashbarItemsInNewOrder.splice(newIndex, 0, dashbarItemToMove);
            state.dashbarItems = dashbarItemsInNewOrder;
        },
        SET_DASHBAR_ITEMS: (items) => {
            state.dashbarItems = (items === null || items === void 0 ? void 0 : items.length) ? items : [];
        },
        TOOLBAR_ACTION1: ({ foo }) => {
            state.myFoo = foo;
        },
        TOOLBAR_ACTION2: ({ bar }) => {
            state.myBar = bar;
        },
        default: () => state,
    });
}, initialState);
//# sourceMappingURL=toolbarReducer.js.map