"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SetOverlayColorUC = void 0;
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const Entities_1 = require("../Entities");
const SetOverlayColorUndoRedo_1 = require("./SetOverlayColorUndoRedo");
class SetOverlayColorUC extends core_1.AppObjectUC {
    constructor(appObject) {
        super(appObject, SetOverlayColorUC.type);
        this.setOverlayColor = (color) => {
            if (!this.overlayColor) {
                this.warn("[SetOverlayColorUC] Unable to get Overlay Color Entity");
                return;
            }
            if (this.overlayColor.overlayColor === color)
                return;
            const prevColor = this.overlayColor.overlayColor;
            this.overlayColor.overlayColor = color;
            new SetOverlayColorUndoRedo_1.SetOverlayColorUndoRedo(prevColor, color, this.appObject);
            (0, Dispatcher_1.dispatchStateChange)(this.appObjects);
        };
        this.overlayColor = appObject.getComponent(Entities_1.OverlayColor.type);
        if (!this.overlayColor) {
            this.warn("SetOverlayColorUC has been added to an App Object that does not have a Overlay Color Entity. Add a Overlay Color Entity before adding the UC");
        }
    }
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
}
exports.SetOverlayColorUC = SetOverlayColorUC;
SetOverlayColorUC.type = "SetOverlayColorUC";
//# sourceMappingURL=SetOverlayColorUC.js.map