using Beam.Abstractions;
using HtmlAgilityPack;

namespace Beam.Dynamic;

public class ManyAnchorsDataProvider : AnchorDataProvider, IManySelectionComposableDataProvider<string[]> {
    public new string[] Get(HtmlDocument document) {
        return [base.Get(document)];
    }
    public string[] ManyGet(HtmlNode[] node) {
        return node.Select(x => base.Get(x)).ToArray();
    }
    public HtmlNode[]? SelectMany(HtmlDocument doc) {
        var k = Select(doc);
        return k == null ? null : [k];
    }
    public HtmlNode[]? SelectMany(HtmlNode[] node) {
        return node.Select(x => Select(x) ?? null).Where(x => x is not null).Cast<HtmlNode>().ToArray();
    }
}