using System.Collections.Generic;

namespace UVC.Twin.MonitoringUI
{
    internal static class MonitoringUIDefaultData
    {
        public const string DefaultCurrentDate = "2025-02-27";

        public static Dictionary<string, ShortcutTabMapping> BuildShortcutTabMap()
        {
            return new Dictionary<string, ShortcutTabMapping>
            {
                [PanelTypes.OverviewAll] = new ShortcutTabMapping
                {
                    Shortcut = new InfoShortcutData(
                        PanelTypes.OverviewAll, "i", "전체OVERVIEW", PanelTypes.OverviewAll),
                    Tabs = new List<NamedItemData>
                    {
                        new("trans-bay", "Trans Bay"),
                        new("25-bay", "25 Bay"),
                        new("24-bay", "24 Bay"),
                        new("23-bay", "23 Bay"),
                        new("22-bay", "22 Bay"),
                    },
                    DefaultActiveTabId = "trans-bay",
                },
                [PanelTypes.OverviewSection] = new ShortcutTabMapping
                {
                    Shortcut = new InfoShortcutData(
                        PanelTypes.OverviewSection, "i", "관별 OVERVIEW", PanelTypes.OverviewSection),
                    Tabs = new List<NamedItemData>
                    {
                        new("section-a", "A 관"),
                        new("section-b", "B 관"),
                        new("section-c", "C 관"),
                    },
                    DefaultActiveTabId = "section-a",
                },
                [PanelTypes.OverviewComplex] = new ShortcutTabMapping
                {
                    Shortcut = new InfoShortcutData(
                        PanelTypes.OverviewComplex, "i", "공단 OVERVIEW", PanelTypes.OverviewComplex),
                    Tabs = new List<NamedItemData>
                    {
                        new("complex-1", "1 공단"),
                        new("complex-2", "2 공단"),
                    },
                    DefaultActiveTabId = "complex-1",
                },
                [PanelTypes.OverviewLeader] = new ShortcutTabMapping
                {
                    Shortcut = new InfoShortcutData(
                        PanelTypes.OverviewLeader, "i", "팀장 OVERVIEW", PanelTypes.OverviewLeader),
                    Tabs = new List<NamedItemData>
                    {
                        new("leader-ops", "운영팀"),
                        new("leader-maint", "보수팀"),
                    },
                    DefaultActiveTabId = "leader-ops",
                },
            };
        }

        public static List<InfoShortcutData> BuildShortcutList(
            Dictionary<string, ShortcutTabMapping> map)
        {
            var orderedKeys = new[]
            {
                PanelTypes.OverviewAll,
                PanelTypes.OverviewSection,
                PanelTypes.OverviewComplex,
                PanelTypes.OverviewLeader,
            };

            var result = new List<InfoShortcutData>();
            foreach (var key in orderedKeys)
            {
                if (map.TryGetValue(key, out var mapping))
                    result.Add(mapping.Shortcut);
            }
            return result;
        }

        public static List<NamedItemData> BuildDrawerItems() => new List<NamedItemData>
        {
            new("overview", "Overview"),
            new("alarms", "Alarms"),
            new("reports", "Reports"),
            new("settings", "Settings"),
        };

        public static Dictionary<string, List<EquipmentCardData>> BuildBayEquipmentMap()
        {
            var charts = new List<BarChartItemData>
            {
                new("장재 수(EA)", 999, 777, 1200),
                new("절단 장(m)", 999, 777, 1200),
                new("작업 시간(분)", 999, 777, 1200),
            };

            return new Dictionary<string, List<EquipmentCardData>>
            {
                ["trans-bay"] = new List<EquipmentCardData>
                {
                    new("trans-summary", "Trans Bay 종합", true, charts),
                    new("pls51-1", "PLS51-1", false, charts,
                        "SN2427FLLA510PR01", "SN2427FLLA510PR02"),
                    new("pls51-2", "PLS51-2", false, charts,
                        "SN2427FLLA510PR03", "SN2427FLLA510PR04"),
                    new("pls52-1", "PLS52-1", false, charts,
                        "SN2427FLLA520PR01", "SN2427FLLA520PR02"),
                    new("pls52-2", "PLS52-2", false, charts,
                        "SN2427FLLA520PR03", "SN2427FLLA520PR04"),
                },
                ["25-bay"] = new List<EquipmentCardData>
                {
                    new("25bay-summary", "25Bay 종합", true, charts),
                    new("pls45-1", "PLS45-1", false, charts,
                        "SN2527FLLA450PR01", "SN2527FLLA450PR02"),
                    new("pls45-2", "PLS45-2", false, charts,
                        "SN2527FLLA450PR03", "SN2527FLLA450PR04"),
                    new("pls46-1", "PLS46-1", false, charts,
                        "SN2527FLLA460PR01", "SN2527FLLA460PR02"),
                    new("pls46-2", "PLS46-2", false, charts,
                        "SN2527FLLA460PR03", "SN2527FLLA460PR04"),
                },
                ["24-bay"] = new List<EquipmentCardData>
                {
                    new("24bay-summary", "24Bay 종합", true, charts),
                    new("pls43-1", "PLS43-1", false, charts,
                        "SN2427FLLA310PR01", "SN2427FLLA310PR02"),
                    new("pls43-2", "PLS43-2", false, charts,
                        "SN2427FLLA310PR03", "SN2427FLLA310PR04"),
                    new("pls43-3", "PLS43-3", false, charts,
                        "SN2427FLLA310PR05", "SN2427FLLA310PR06"),
                    new("pls43-4", "PLS43-4", false, charts,
                        "SN2427FLLA310PR07", "SN2427FLLA310PR08"),
                },
                ["23-bay"] = new List<EquipmentCardData>
                {
                    new("23bay-summary", "23Bay 종합", true, charts),
                    new("pls41-1", "PLS41-1", false, charts,
                        "SN2327FLLA410PR01", "SN2327FLLA410PR02"),
                    new("pls41-2", "PLS41-2", false, charts,
                        "SN2327FLLA410PR03", "SN2327FLLA410PR04"),
                    new("pls42-1", "PLS42", false, charts,
                        "SN2327FLLA420PR01", "SN2327FLLA420PR02"),
                },
                ["22-bay"] = new List<EquipmentCardData>
                {
                    new("22bay-summary", "22Bay 종합", true, charts),
                    new("pls39-1", "PLS39-1", false, charts,
                        "SN2227FLLA390PR01", "SN2227FLLA390PR02"),
                    new("pls39-2", "PLS39-2", false, charts,
                        "SN2227FLLA390PR03", "SN2227FLLA390PR04"),
                    new("pls40-1", "PLS40", false, charts,
                        "SN2227FLLA400PR01", "SN2227FLLA400PR02"),
                },
            };
        }

        public static List<ScheduleRowData> BuildScheduleRows() => new List<ScheduleRowData>
        {
            new("SN2633FLL5150PN54", "20250106", "20250107", "FL", "51.39", "PLS43-1"),
            new("SN2633FLL5150PN53", "20250106", "20250107", "FL", "47.25", "PLS43-2"),
            new("SN2633FLL5150PN55", "20250106", "20250107", "FL", "51.39", "PLS42"),
            new("SN2632FLLD110CP04", "20250106", "20250107", "FL", "39.709", "PLS43-3"),
            new("SN2632FLLD110CP06", "20250106", "20250107", "FL", "29.07", "PLS43-4"),
            new("SN2632FLLD110CP07", "20250106", "20250107", "FL", "28.389", "PLS42"),
            new("SN2632FLLD110CP02", "20250106", "20250107", "FL", "39.97", "PLS42"),
            new("SN2632FLLD110CP01", "20250106", "20250107", "FL", "35.233", "PLS42"),
            new("SN2653FLLT121PP04", "20250107", "20250108", "FL", "36.206", "PLS42"),
            new("SN2653FLLT121PP01", "20250107", "20250108", "FL", "37.356", "PLS42"),
        };

        public static List<string> BuildDefaultDateChoices() =>
            new List<string> { "2025-02-27", "2025-02-28", "2025-03-01" };
    }
}
