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