"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteAllLandmarksUC = void 0;
exports.makeDeleteAllLandmarksUC = makeDeleteAllLandmarksUC;
const core_1 = require("@vived/core");
const Dispatcher_1 = require("../../Dispatcher");
const LandmarkRepo_1 = require("../Entities/LandmarkRepo");
const DeleteAllLandmarksUndoRedo_1 = require("./DeleteAllLandmarksUndoRedo");
class DeleteAllLandmarksUC extends core_1.AppObjectUC {
}
exports.DeleteAllLandmarksUC = DeleteAllLandmarksUC;
DeleteAllLandmarksUC.type = "DeleteAllLandmarksUC";
DeleteAllLandmarksUC.get = (appObjects) => (0, core_1.getSingletonComponent)(DeleteAllLandmarksUC.type, appObjects);
function makeDeleteAllLandmarksUC(appObject) {
    return new DeleteAllCalloutsUCImp(appObject);
}
class DeleteAllCalloutsUCImp extends DeleteAllLandmarksUC {
    deleteAllLandmarks() {
        const deletedLandmarks = [];
        const landmarkRepos = this.appObjects.getAllComponents(LandmarkRepo_1.LandmarkRepo.type);
        landmarkRepos.forEach((repo) => {
            const callouts = repo.getAll();
            callouts.forEach((landmark) => {
                deletedLandmarks.push(landmark.data);
                repo.removeForAppObject(landmark.appObject.id);
                landmark.appObject.dispose();
            });
        });
        (0, Dispatcher_1.dispatchStateChange)(this.appObjects);
        new DeleteAllLandmarksUndoRedo_1.DeleteAllLandmarksUndoRedo(deletedLandmarks, this.appObjects);
    }
    constructor(appObject) {
        super(appObject, DeleteAllLandmarksUC.type);
    }
}
//# sourceMappingURL=DeleteAllLandmarksUC.js.map