using System;
using System.Collections.Generic;
using System.Linq;
using AGVNavigationCore.Models;
using AGVNavigationCore.PathFinding.Core;
using AGVNavigationCore.PathFinding.Analysis;
using AGVNavigationCore.PathFinding.Validation;

namespace AGVNavigationCore.PathFinding.Planning
{
    /// <summary>
    /// AGV 방향 전환 경로 계획 시스템
    /// 물리적 제약사항을 고려한 방향 전환 경로 생성
    /// </summary>
    public class DirectionChangePlanner
    {
        /// <summary>
        /// 방향 전환 계획 결과
        /// </summary>
        public class DirectionChangePlan
        {
            public bool Success { get; set; }
            public List<MapNode> DirectionChangePath { get; set; }
            public string DirectionChangeNode { get; set; }
            public string ErrorMessage { get; set; }
            public string PlanDescription { get; set; }

            public DirectionChangePlan()
            {
                DirectionChangePath = new List<MapNode>();
                ErrorMessage = string.Empty;
                PlanDescription = string.Empty;
            }

            public static DirectionChangePlan CreateSuccess(List<MapNode> path, string changeNode, string description)
            {
                return new DirectionChangePlan
                {
                    Success = true,
                    DirectionChangePath = path,
                    DirectionChangeNode = changeNode,
                    PlanDescription = description
                };
            }

            public static DirectionChangePlan CreateFailure(string error)
            {
                return new DirectionChangePlan
                {
                    Success = false,
                    ErrorMessage = error
                };
            }
        }

        private readonly List<MapNode> _mapNodes;
        private readonly JunctionAnalyzer _junctionAnalyzer;
        private readonly AStarPathfinder _pathfinder;

        public DirectionChangePlanner(List<MapNode> mapNodes)
        {
            _mapNodes = mapNodes ?? new List<MapNode>();
            _junctionAnalyzer = new JunctionAnalyzer(_mapNodes);
            _pathfinder = new AStarPathfinder();
            _pathfinder.SetMapNodes(_mapNodes);
        }



    }
}