"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsHiddenPM = void 0;
exports.makeIsHiddenPM = makeIsHiddenPM;
const core_1 = require("@vived/core");
const Hideable_1 = require("../Entities/Hideable");
class IsHiddenPM extends core_1.AppObjectPM {
    static get(appObjID, appObjects) {
        const appObj = appObjects.get(appObjID);
        if (appObj === undefined) {
            return undefined;
        }
        return appObj.getComponent(IsHiddenPM.type);
    }
}
exports.IsHiddenPM = IsHiddenPM;
IsHiddenPM.type = "IsHiddenPM";
function makeIsHiddenPM(appObject) {
    return new IsHiddenPMImp(appObject);
}
class IsHiddenPMImp extends IsHiddenPM {
    get hideable() {
        return this.getCachedLocalComponent(Hideable_1.Hideable.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, IsHiddenPM.type);
        this.onIsHiddenChange = () => {
            if (!this.hideable)
                return;
            this.doUpdateView(this.hideable.isHidden);
        };
        this.dispose = () => {
            super.dispose();
            this.hideable?.removeChangeObserver(this.onIsHiddenChange);
            this.hideable?.removeOnDisposeObserver(this.dispose);
        };
        if (!this.hideable) {
            this.error("Unable to find Hideable Entity");
            return;
        }
        else {
            this.hideable.addChangeObserver(this.onIsHiddenChange);
            this.hideable.addOnDisposeObserver(this.dispose);
            this.onIsHiddenChange();
        }
    }
}
//# sourceMappingURL=IsHiddenPM.js.map