"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.defaultLabelDropEditingIDVM = exports.LabelDropEditingIDPM = void 0;
exports.makeLabelDropEditingIDPM = makeLabelDropEditingIDPM;
const core_1 = require("@vived/core");
const LabelDropRepo_1 = require("../Entities/LabelDropRepo");
class LabelDropEditingIDPM extends core_1.AppObjectPM {
}
exports.LabelDropEditingIDPM = LabelDropEditingIDPM;
LabelDropEditingIDPM.type = "LabelDropEditingIDPM";
LabelDropEditingIDPM.get = (appObjects) => (0, core_1.getSingletonComponent)(LabelDropEditingIDPM.type, appObjects);
function makeLabelDropEditingIDPM(appObject) {
    return new LabelDropEditingIDPMImp(appObject);
}
class LabelDropEditingIDPMImp extends LabelDropEditingIDPM {
    get labelDropRepo() {
        return this.getCachedSingleton(LabelDropRepo_1.LabelDropRepo.type);
    }
    vmsAreEqual(a, b) {
        if (a.editingId !== b.editingId)
            return false;
        if (a.isEditingNewAnswer !== b.isEditingNewAnswer)
            return false;
        return true;
    }
    constructor(appObject) {
        super(appObject, LabelDropEditingIDPM.type);
        this.onEntityChange = () => {
            if (!this.labelDropRepo)
                return;
            const vm = {
                editingId: this.labelDropRepo.editingID,
                isEditingNewAnswer: this.labelDropRepo.isEditingNewAnswer,
            };
            this.doUpdateView(vm);
        };
        this.labelDropRepo?.addChangeObserver(this.onEntityChange);
        this.appObjects.registerSingleton(this);
        this.onEntityChange();
    }
}
exports.defaultLabelDropEditingIDVM = {
    editingId: undefined,
    isEditingNewAnswer: false,
};
//# sourceMappingURL=LabelDropEditingIDPM.js.map