"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.StylusLabelDrop = void 0;
exports.makeStylusLabelDrop = makeStylusLabelDrop;
const core_1 = require("@vived/core");
const StylusEntity_1 = require("../../Stylus/Entity/StylusEntity");
const LabelDropRepo_1 = require("../Entities/LabelDropRepo");
const DragLabelDropWorldUC_1 = require("../UseCases/DragLabelDropWorldUC");
class StylusLabelDrop extends core_1.AppObjectController {
}
exports.StylusLabelDrop = StylusLabelDrop;
StylusLabelDrop.type = "StylusLabelDrop";
function makeStylusLabelDrop(appObject) {
    return new StylusLabelDropImp(appObject);
}
class StylusLabelDropImp extends StylusLabelDrop {
    get stylus() {
        return this.getCachedSingleton(StylusEntity_1.StylusEntity.type);
    }
    constructor(appObject) {
        super(appObject, StylusLabelDrop.type);
        this.onButtonDown = (button) => { };
        this.onStylusMove = () => {
            if (!this.stylus)
                return;
            if (!this.labelDropEntity)
                return;
            if (!this.labelDropEntity.draggingID)
                return;
            if (!this.dragLabelDropWorldUC)
                return;
            this.dragLabelDropWorldUC.updateDrag(this.stylus.pickRay);
        };
        this.onButtonUp = (button) => {
            if (!this.stylus)
                return;
            if (!this.labelDropEntity)
                return;
            if (!this.labelDropEntity.draggingID)
                return;
            if (!this.dragLabelDropWorldUC)
                return;
            this.dragLabelDropWorldUC.releaseDrag(this.stylus.pickRay);
        };
        this.labelDropEntity = LabelDropRepo_1.LabelDropRepo.get(this.appObjects);
        if (!this.labelDropEntity) {
            this.error("[StylusLabelDrop] unable to find LabelDropEntity");
            return;
        }
        this.dragLabelDropWorldUC = DragLabelDropWorldUC_1.DragLabelDropWorldUC.get(this.appObjects);
        if (!this.dragLabelDropWorldUC) {
            this.error("[StylusLabelDrop] unable to find DragLabelDropWorldUC");
            return;
        }
        if (!this.stylus) {
            this.error("[StylusLabelDrop] unable to find ZSpaceStylusEntity");
            return;
        }
        this.stylus.registerController(this);
    }
}
//# sourceMappingURL=StylusLabelDrop.js.map