import { AppObjectPM } from "@vived/core";
import { Transparency } from "../Entities";
export class IsTransparentPM extends AppObjectPM {
    static get(appObjID, appObjects) {
        const appObj = appObjects.get(appObjID);
        if (appObj === undefined) {
            return undefined;
        }
        return appObj.getComponent(IsTransparentPM.type);
    }
}
IsTransparentPM.type = "IsTransparentPM";
export function makeIsTransparentPM(appObject) {
    return new IsTransparentPMImp(appObject);
}
class IsTransparentPMImp extends IsTransparentPM {
    get transparency() {
        return this.getCachedLocalComponent(Transparency.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, IsTransparentPM.type);
        this.onIsHiddenChange = () => {
            if (!this.transparency)
                return;
            this.doUpdateView(this.transparency.isTransparent);
        };
        this.dispose = () => {
            super.dispose();
            this.transparency?.removeChangeObserver(this.onIsHiddenChange);
            this.transparency?.removeOnDisposeObserver(this.dispose);
        };
        if (!this.transparency) {
            this.error("Unable to find Transparency Entity");
            return;
        }
        else {
            this.transparency.addChangeObserver(this.onIsHiddenChange);
            this.transparency.addOnDisposeObserver(this.dispose);
            this.onIsHiddenChange();
        }
    }
}
//# sourceMappingURL=IsTransparentPM.js.map