"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsTransparentPM = void 0;
exports.makeIsTransparentPM = makeIsTransparentPM;
const core_1 = require("@vived/core");
const Entities_1 = require("../Entities");
class IsTransparentPM extends core_1.AppObjectPM {
    static get(appObjID, appObjects) {
        const appObj = appObjects.get(appObjID);
        if (appObj === undefined) {
            return undefined;
        }
        return appObj.getComponent(IsTransparentPM.type);
    }
}
exports.IsTransparentPM = IsTransparentPM;
IsTransparentPM.type = "IsTransparentPM";
function makeIsTransparentPM(appObject) {
    return new IsTransparentPMImp(appObject);
}
class IsTransparentPMImp extends IsTransparentPM {
    get transparency() {
        return this.getCachedLocalComponent(Entities_1.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