using System.Collections.Concurrent;
using System.Diagnostics;
using Autodesk.Revit.UI;
namespace RevitBridge
{
///
/// Thrown by queued work when no Revit document is open.
/// The bridge maps this to HTTP 409 with hasActiveDocument = false.
///
internal sealed class NoActiveDocumentException : InvalidOperationException
{
public NoActiveDocumentException()
: base("No active Revit document is open.")
{
}
}
///
/// Schedules work onto the Revit API thread via an ExternalEvent and returns
/// a Task that completes with the result (standard ExternalEvent +
/// TaskCompletionSource dispatch).
///
internal sealed class CommandQueue : IExternalEventHandler
{
private sealed class WorkItem
{
public required Func Action { get; init; }
public required TaskCompletionSource