import { SceneRayPickUC } from "../../Babylon/UC/SceneRayPickUC";
import { ToolRepository } from "../../Tools";
import { PanTransformUC, TryPanTransformUCImp, } from "../../Transform3D/UC";
import { CalloutEntity } from "../Entities/CalloutEntity";
export function makeTryPanLabelUC(appObject) {
    return new TryPanLabelUC(appObject);
}
class TryPanLabelUC extends 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.get(this.appObjects)?.sceneRayPick(pickRay);
            if (!scenePick || !scenePick.worldPickPoint)
                return false;
            const appObjectID = scenePick.appObjectID;
            if (!appObjectID)
                return false;
            const callout = CalloutEntity.getById(appObjectID, this.appObjects);
            if (!callout) {
                return false;
            }
            this.panUC = callout.labelTransform.appObject.getComponent(PanTransformUC.type);
            if (!this.panUC) {
                return false;
            }
            this.panUC.initializeRay(pickRay);
            return true;
        };
    }
    get toolRepo() {
        return this.getCachedSingleton(ToolRepository.type);
    }
}
//# sourceMappingURL=TryPanLabelUC.js.map