"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ActiveModelPM = void 0;
exports.makeActiveModelPM = makeActiveModelPM;
const core_1 = require("@vived/core");
const Entities_1 = require("../Entities");
class ActiveModelPM extends core_1.AppObjectPM {
    static get(appObjects) {
        return (0, core_1.getSingletonComponent)(ActiveModelPM.type, appObjects);
    }
}
exports.ActiveModelPM = ActiveModelPM;
ActiveModelPM.type = "ActiveModelPM";
function makeActiveModelPM(appObject) {
    return new ActiveModelPMImp(appObject);
}
class ActiveModelPMImp extends ActiveModelPM {
    get repo() {
        return this.getCachedSingleton(Entities_1.ChannelModelRepo.type);
    }
    vmsAreEqual(a, b) {
        return a === b;
    }
    constructor(appObject) {
        super(appObject, ActiveModelPM.type);
        this.onEntityChange = () => {
            if (!this.repo)
                return;
            this.doUpdateView(this.repo.activeModel);
        };
        this.repo?.addChangeObserver(this.onEntityChange);
        this.onEntityChange();
        this.appObjects.registerSingleton(this);
    }
}
//# sourceMappingURL=ActiveModelPM.js.map