import { AppObjectUC } from "@vived/core";
import { dispatchStateChange } from "../../Dispatcher";
import { LandmarkEntity } from "../Entities";
import { DeleteLandmarkUndoRedo } from "./DeleteLandmarkUndoRedo";
export class DeleteLandmarkUC extends AppObjectUC {
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
    static getById(id, appObjs) {
        return appObjs.get(id)?.getComponent(this.type);
    }
}
DeleteLandmarkUC.type = "DeleteLandmarkUC";
export function makeDeleteLandmarkUC(appObject) {
    return new DeleteLandmarkUCImp(appObject);
}
class DeleteLandmarkUCImp extends DeleteLandmarkUC {
    get landmark() {
        return this.getCachedLocalComponent(LandmarkEntity.type);
    }
    constructor(appObject) {
        super(appObject, DeleteLandmarkUC.type);
        this.deleteLandmark = () => {
            if (!this.landmark)
                return;
            new DeleteLandmarkUndoRedo(this.landmark.data, this.appObjects);
            this.landmark.inRepo?.deleteLandmark(this.landmark.id);
            dispatchStateChange(this.appObjects);
        };
    }
}
//# sourceMappingURL=DeleteLandmarkUC.js.map