import { AppObjectPM, getSingletonComponent, } from "@vived/core";
import { LabelDropRepo } from "../Entities/LabelDropRepo";
export class LabelDropReviewPM extends AppObjectPM {
}
LabelDropReviewPM.type = "LabelDropReviewPM";
LabelDropReviewPM.get = (appObjects) => getSingletonComponent(LabelDropReviewPM.type, appObjects);
export function makeLabelDropReviewPM(appObject) {
    return new LabelDropReviewPMImp(appObject);
}
class LabelDropReviewPMImp extends LabelDropReviewPM {
    get labelDropRepo() {
        return this.getCachedSingleton(LabelDropRepo.type);
    }
    vmsAreEqual(a, b) {
        if (a.length !== b.length)
            return false;
        let vmsEqual = true;
        for (let i = 0; i < a.length; i++) {
            if (a[i].id !== b[i].id) {
                vmsEqual = false;
            }
            else if (a[i].label !== b[i].label) {
                vmsEqual = false;
            }
            else if (a[i].tries !== b[i].tries) {
                vmsEqual = false;
            }
        }
        return vmsEqual;
    }
    constructor(appObject) {
        super(appObject, LabelDropReviewPM.type);
        this.onEntityChange = () => {
            if (!this.labelDropRepo)
                return;
            const labelDropReviewVM = this.labelDropRepo
                .getAll()
                .map((item) => {
                return {
                    id: item.id,
                    label: item.labelEntity.display,
                    tries: item.tries,
                };
            });
            this.doUpdateView(labelDropReviewVM);
        };
        this.labelDropRepo?.addChangeObserver(this.onEntityChange);
        this.appObjects.registerSingleton(this);
        this.onEntityChange();
    }
}
//# sourceMappingURL=LabelDropReviewPM.js.map