"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MouseAddCalloutMC = void 0;
const core_1 = require("@vived/core");
const MouseInput_1 = require("../../MouseInput/Entities/MouseInput");
const TryAddCallout_1 = require("../UC/TryAddCallout");
class MouseAddCalloutMC extends core_1.AppObjectController {
    get tryAddCalloutUc() {
        return this.getCachedSingleton(TryAddCallout_1.TryAddCalloutUC.type);
    }
    get mouseInput() {
        return this.getCachedSingleton(MouseInput_1.MouseInputEntity.type);
    }
    constructor(appObject) {
        super(appObject, MouseAddCalloutMC.type);
        this.isAdding = false;
        this.onDown = (e) => {
            this.isAdding = false;
            if (e.button !== 0)
                return;
            this.isAdding =
                this.tryAddCalloutUc?.initializeWithPixel(e.position) ?? false;
        };
        this.onMove = (e) => {
            if (!this.isAdding)
                return;
            this.tryAddCalloutUc?.moveWithPixel(e.position);
        };
        this.onUp = (e) => {
            if (!this.isAdding)
                return;
            this.tryAddCalloutUc?.stop();
            this.isAdding = false;
        };
        this.mouseInput?.registerController(this);
    }
}
exports.MouseAddCalloutMC = MouseAddCalloutMC;
MouseAddCalloutMC.type = "MouseAddCalloutMC";
//# sourceMappingURL=MouseAddCalloutMC.js.map