"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteCalloutUC = void 0;
exports.makeDeleteCalloutUC = makeDeleteCalloutUC;
const core_1 = require("@vived/core");
const DispatchStateChangeUC_1 = require("../../Dispatcher/UC/DispatchStateChangeUC");
const CalloutEntity_1 = require("../Entities/CalloutEntity");
const DeleteCalloutUndoRedo_1 = require("./DeleteCalloutUndoRedo");
class DeleteCalloutUC extends core_1.AppObjectUC {
    static get(appObj) {
        return appObj.getComponent(this.type);
    }
    static getById(id, appObjects) {
        return appObjects.get(id)?.getComponent(this.type);
    }
}
exports.DeleteCalloutUC = DeleteCalloutUC;
DeleteCalloutUC.type = "DeleteCalloutUC";
function makeDeleteCalloutUC(appObject) {
    return new DeleteCalloutUCImp(appObject);
}
class DeleteCalloutUCImp extends DeleteCalloutUC {
    get callout() {
        return this.getCachedLocalComponent(CalloutEntity_1.CalloutEntity.type);
    }
    constructor(appObject) {
        super(appObject, DeleteCalloutUC.type);
        this.delete = () => {
            if (!this.callout)
                return;
            new DeleteCalloutUndoRedo_1.DeleteCalloutUndoRedo(this.callout.data, this.appObjects);
            this.callout.inRepo?.deleteCallout(this.callout.id);
            (0, DispatchStateChangeUC_1.dispatchStateChange)(this.appObjects);
        };
    }
}
//# sourceMappingURL=DeleteCallout.js.map