"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeTryPanLabelUC = makeTryPanLabelUC;
const SceneRayPickUC_1 = require("../../Babylon/UC/SceneRayPickUC");
const Tools_1 = require("../../Tools");
const UC_1 = require("../../Transform3D/UC");
const CalloutEntity_1 = require("../Entities/CalloutEntity");
function makeTryPanLabelUC(appObject) {
    return new TryPanLabelUC(appObject);
}
class TryPanLabelUC extends UC_1.TryPanTransformUCImp {
    constructor() {
        super(...arguments);
        this.allow = () => {
            if (this.toolRepo?.activeTool?.toolType !== "PEEL" &&
                this.toolRepo?.activeTool?.toolType !== "CALLOUT") {
                return false;
            }
            return true;
        };
        this.tryWithRay = (pickRay) => {
            this.panUC = undefined;
            if (!this.allow()) {
                return false;
            }
            const scenePick = SceneRayPickUC_1.SceneRayPickUC.get(this.appObjects)?.sceneRayPick(pickRay);
            if (!scenePick || !scenePick.worldPickPoint)
                return false;
            const appObjectID = scenePick.appObjectID;
            if (!appObjectID)
                return false;
            const callout = CalloutEntity_1.CalloutEntity.getById(appObjectID, this.appObjects);
            if (!callout) {
                return false;
            }
            this.panUC = callout.labelTransform.appObject.getComponent(UC_1.PanTransformUC.type);
            if (!this.panUC) {
                return false;
            }
            this.panUC.initializeRay(pickRay);
            return true;
        };
    }
    get toolRepo() {
        return this.getCachedSingleton(Tools_1.ToolRepository.type);
    }
}
//# sourceMappingURL=TryPanLabelUC.js.map