namespace Inspectron.Epson.Templates.Language.Nodes;

public record ConditionBranch(
    string Condition,
    List<ITemplateNode> Body,
    SourcePosition Position);

public record IfNode(
    ConditionBranch IfBranch,
    IReadOnlyList<ConditionBranch> ElseIfBranches,
    List<ITemplateNode>? ElseBranch,
    SourcePosition Position) : ITemplateNode
{
    public IReadOnlyList<ITemplateNode> Children
    {
        get
        {
            var children = new List<ITemplateNode>();
            children.AddRange(IfBranch.Body);
            foreach (var branch in ElseIfBranches)
            {
                children.AddRange(branch.Body);
            }
            if (ElseBranch != null)
            {
                children.AddRange(ElseBranch);
            }
            return children;
        }
    }
}
