"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClearAllColorOverlayUndoRedo = void 0;
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
const OverlayColor_1 = require("../../OverlayColor/Entities/OverlayColor");
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
class ClearAllColorOverlayUndoRedo {
    constructor(undoState, appObjects) {
        this.undoState = undoState;
        this.appObjects = appObjects;
        this.undoAction = () => {
            this.undoState.forEach((color, id) => {
                const overlay = OverlayColor_1.OverlayColor.getByID(id, this.appObjects);
                if (overlay) {
                    overlay.overlayColor = color;
                }
            });
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
        this.redoAction = () => {
            this.undoState.forEach((color, id) => {
                const overlay = OverlayColor_1.OverlayColor.getByID(id, this.appObjects);
                if (overlay) {
                    overlay.overlayColor = OverlayColor_1.OverlayColorEnums.NONE;
                }
            });
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
        const undoRedo = UndoRedoEntity_1.UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitError("ClearAllColorOverlayUndoRedo", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.ClearAllColorOverlayUndoRedo = ClearAllColorOverlayUndoRedo;
//# sourceMappingURL=ClearAllColorOverlayUndoRedo.js.map