"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClearEditingLabelDropUCHook = void 0;
const core_1 = require("@vived/core");
const BaseApp_1 = require("../../BaseApp");
const Entities_1 = require("../Entities");
class ClearEditingLabelDropUCHook extends core_1.AppObjectUC {
    get baseApp() {
        return this.getCachedSingleton(BaseApp_1.BaseAppState.type);
    }
    get labelDropRepo() {
        return this.getCachedSingleton(Entities_1.LabelDropRepo.type);
    }
    constructor(appObject) {
        super(appObject, ClearEditingLabelDropUCHook.type);
        this.onBaseAppChange = () => {
            if (!this.baseApp || !this.labelDropRepo) {
                this.warn("Missing Components");
                return;
            }
            if (this.baseApp.isAuthoring === this.lastAuthoringState)
                return;
            if (this.baseApp.isAuthoring === false) {
                this.labelDropRepo.editingID = undefined;
            }
            this.lastAuthoringState = this.baseApp.isAuthoring;
        };
        this.baseApp?.addChangeObserver(this.onBaseAppChange);
    }
}
exports.ClearEditingLabelDropUCHook = ClearEditingLabelDropUCHook;
ClearEditingLabelDropUCHook.type = "ClearEditingLabelDropUCHook";
//# sourceMappingURL=ClearEditingLabelDropUCHook.js.map