import { AppObjectPM } from "@vived/core";
import { OverlayColor } from "../Entities/OverlayColor";
export class OverlayColorPM extends AppObjectPM {
    static getForID(appObjID, appObjects) {
        const appObj = appObjects.get(appObjID);
        if (appObj === undefined) {
            return undefined;
        }
        return appObj.getComponent(OverlayColorPM.type);
    }
}
OverlayColorPM.type = "OverlayColorPM";
export function makeOverlayColorPM(appObject) {
    return new OverlayColorPMImp(appObject);
}
class OverlayColorPMImp extends OverlayColorPM {
    get overlayColor() {
        return this.getCachedLocalComponent(OverlayColor.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, OverlayColorPM.type);
        this.onColorChange = () => {
            if (!this.overlayColor)
                return;
            this.doUpdateView(this.overlayColor.overlayColor);
        };
        this.dispose = () => {
            super.dispose();
            this.overlayColor?.removeChangeObserver(this.onColorChange);
            this.overlayColor?.removeOnDisposeObserver(this.dispose);
        };
        if (!this.overlayColor) {
            this.error("[OverlayColorPM] Unable to find OverlayColor Entity");
            return;
        }
        else {
            this.overlayColor.addChangeObserver(this.onColorChange);
            this.overlayColor.addOnDisposeObserver(this.dispose);
            this.onColorChange();
        }
    }
}
//# sourceMappingURL=OverlayColorPM.js.map