using Flyshot.Core.Domain;
using Flyshot.Core.Planning;
using Flyshot.Core.Triggering;

namespace Flyshot.ControllerClientCompat;

/// <summary>
/// 表示兼容层执行轨迹前生成的完整规划结果包。
/// </summary>
public sealed class PlannedExecutionBundle
{
    /// <summary>
    /// 初始化一份执行规划结果包。
    /// </summary>
    /// <param name="plannedTrajectory">规划后的原始连续轨迹。</param>
    /// <param name="shotTimeline">飞拍触发时间轴。</param>
    /// <param name="result">对运行时和监控层暴露的规划结果。</param>
    /// <param name="preparedExecution">飞拍链路预先准备好的最终发送队列。</param>
    /// <param name="executionTrajectory">与运行时结果同口径的连续执行轨迹；为空时复用 plannedTrajectory。</param>
    public PlannedExecutionBundle(
        PlannedTrajectory plannedTrajectory,
        ShotTimeline shotTimeline,
        TrajectoryResult result,
        FlyshotPreparedExecution? preparedExecution = null,
        PlannedTrajectory? executionTrajectory = null)
    {
        PlannedTrajectory = plannedTrajectory ?? throw new ArgumentNullException(nameof(plannedTrajectory));
        ShotTimeline = shotTimeline ?? throw new ArgumentNullException(nameof(shotTimeline));
        Result = result ?? throw new ArgumentNullException(nameof(result));
        PreparedExecution = preparedExecution;
        ExecutionTrajectory = executionTrajectory ?? plannedTrajectory;
    }

    /// <summary>
    /// 获取规划后的原始连续轨迹。
    /// </summary>
    public PlannedTrajectory PlannedTrajectory { get; }

    /// <summary>
    /// 获取与运行时结果同口径的连续执行轨迹，用于构建最终 8ms 发送队列。
    /// </summary>
    public PlannedTrajectory ExecutionTrajectory { get; }

    /// <summary>
    /// 获取飞拍触发时间轴。
    /// </summary>
    public ShotTimeline ShotTimeline { get; }

    /// <summary>
    /// 获取运行时可消费的规划结果。
    /// </summary>
    public TrajectoryResult Result { get; }

    /// <summary>
    /// 获取飞拍链路预先准备好的最终发送队列；普通轨迹与 move_joint 为 null。
    /// </summary>
    public FlyshotPreparedExecution? PreparedExecution { get; }
}
