// Copyright (c) Microsoft. All rights reserved.

using Microsoft.Agents.AI.Workflows.Execution;
using PredicateT = System.Func<object?, bool>;

namespace Microsoft.Agents.AI.Workflows;

/// <summary>
/// Represents a directed edge between two nodes, optionally associated with a condition that determines whether the
/// edge is active.
/// </summary>
public sealed class DirectEdgeData : EdgeData
{
    internal DirectEdgeData(string sourceId, string sinkId, EdgeId id, PredicateT? condition = null, string? label = null) : base(id, label)
    {
        this.SourceId = sourceId;
        this.SinkId = sinkId;
        this.Condition = condition;
        this.Connection = new([sourceId], [sinkId]);
    }

    /// <summary>
    /// The Id of the source <see cref="Executor"/> node.
    /// </summary>
    public string SourceId { get; }

    /// <summary>
    /// The Id of the destination <see cref="Executor"/> node.
    /// </summary>
    public string SinkId { get; }

    /// <summary>
    /// An optional predicate determining whether the edge is active for a given message. If <see langword="null"/>,
    /// the edge is always active when a message is generated by the source.
    /// </summary>
    public PredicateT? Condition { get; }

    /// <inheritdoc />
    internal override EdgeConnection Connection { get; }
}
