"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.UndoRedoEditSlideText = void 0;
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
const UndoRedoEntity_1 = require("../../UndoRedo/Entities/UndoRedoEntity");
const BaseAppState_1 = require("../Entity/BaseAppState");
class UndoRedoEditSlideText {
    constructor(initialText, appObjects) {
        this.initialText = initialText;
        this.undoAction = () => {
            if (!this.baseAppState || !this.dispatchStateChange)
                return;
            this.baseAppState.slideText = this.initialText;
            this.dispatchStateChange.doDispatch();
        };
        this.redoAction = () => {
            if (!this.baseAppState || !this.dispatchStateChange || !this.finalText)
                return;
            this.baseAppState.slideText = this.finalText;
            this.dispatchStateChange.doDispatch();
        };
        this.baseAppState = BaseAppState_1.BaseAppState.get(appObjects);
        if (!this.baseAppState) {
            appObjects.submitWarning("UndoEditSlideText", "Unable to find BaseAppState");
            return;
        }
        this.finalText = this.baseAppState.slideText;
        if (initialText === this.finalText)
            return;
        this.dispatchStateChange = DispatchStateChangeUC_1.DispatchStateChangeUC.get(appObjects);
        if (!this.dispatchStateChange) {
            appObjects.submitWarning("UndoEditSlideText", "Unable to find DispatchStateChangeUC");
            return;
        }
        const undoRedo = UndoRedoEntity_1.UndoRedoEntity.get(appObjects);
        if (!undoRedo) {
            appObjects.submitWarning("UndoEditSlideText", "Unable to find UndoRedoEntity");
            return;
        }
        undoRedo.submitAction(this);
    }
}
exports.UndoRedoEditSlideText = UndoRedoEditSlideText;
//# sourceMappingURL=UndoRedoEditSlideText.js.map