"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseObjectPickMC = void 0;
const core_1 = require("@vived/core");
const BaseAppState_1 = require("../../BaseApp/Entity/BaseAppState");
const MouseInput_1 = require("../../MouseInput/Entities/MouseInput");
const TrySelectObjectPickUC_1 = require("../UseCases/TrySelectObjectPickUC");
const TrySubmitObjectPickUC_1 = require("../UseCases/TrySubmitObjectPickUC");
class MouseObjectPickMC extends core_1.AppObjectController {
    get baseApp() {
        return this.getCachedSingleton(BaseAppState_1.BaseAppState.type);
    }
    get mouseInput() {
        return this.getCachedSingleton(MouseInput_1.MouseInputEntity.type);
    }
    get trySelectObjectPick() {
        return this.getCachedSingleton(TrySelectObjectPickUC_1.TrySelectObjectPickUC.type)?.tryWithPixel;
    }
    get trySubmitObjectPick() {
        return this.getCachedSingleton(TrySubmitObjectPickUC_1.TrySubmitObjectPickUC.type)?.tryWithPixel;
    }
    constructor(appObject) {
        super(appObject, MouseObjectPickMC.type);
        this.onClick = (e) => {
            if (!this.trySelectObjectPick || !this.trySubmitObjectPick)
                return;
            if (e.button !== 0) {
                return;
            }
            if (this.baseApp?.isAuthoring) {
                this.trySelectObjectPick(e.position);
            }
            else {
                this.trySubmitObjectPick(e.position);
            }
        };
        this.mouseInput?.registerController(this);
    }
}
exports.MouseObjectPickMC = MouseObjectPickMC;
MouseObjectPickMC.type = "MouseObjectPickMC";
//# sourceMappingURL=MouseObjectPickMC.js.map