using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using RevitEstimate.Models;

namespace RevitEstimate.Calculators
{
    public class Item57Calculator : IItemCalculator
    {
        private ProjectLevels _levels;

        public Item57Calculator(ProjectLevels levels = null)
        {
            _levels = levels ?? new ProjectLevels();
        }

        public List<EstimateRowModel> Calculate(List<Element> collector, out double totalQty)
        {
            totalQty = 0.0;
            var rows = new List<EstimateRowModel>();

            // Calculate area directly using Item46Calculator logic for M.S. Grills
            double grillArea = 0.0;
            var item46Calc = new Item46Calculator(_levels);
            var item46Rows = item46Calc.Calculate(collector, out grillArea);

            totalQty = grillArea;

            rows.Add(new EstimateRowModel
            {
                SNo = "",
                ItemOfWork = "   -> Synthetic Enamel Paint on steel grills (Picked from Item 46 total area)",
                NosOfFlats = "1",
                NosOfInstance = "1",
                Length = grillArea.ToString("F2"),
                Width = "",
                HeightDepth = "",
                Qty = grillArea.ToString("F2"),
                Unit = "Sqm",
                Remarks = $"Synthetic enamel paint area directly matched with Item 46 M.S. Grills area ({grillArea:F2} Sqm)."
            });

            return rows;
        }
    }
}