import { AppObjectUC } from "@vived/core";
import { dispatchStateChange } from "../../Dispatcher";
import { OverlayColor } from "../Entities";
import { SetOverlayColorUndoRedo } from "./SetOverlayColorUndoRedo";
export class SetOverlayColorUC extends 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(prevColor, color, this.appObject);
            dispatchStateChange(this.appObjects);
        };
        this.overlayColor = appObject.getComponent(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);
    }
}
SetOverlayColorUC.type = "SetOverlayColorUC";
//# sourceMappingURL=SetOverlayColorUC.js.map