@inherits ComponentBase
@implements IDisposable

@if (@Actions is not null)
{
    <MudDialog @bind-IsVisible="Visible" Style="max-width: inherit !important;">
        <DialogContent>
            <MudStack Class="mt-n3 mb-3">
                @Content
            </MudStack>
        </DialogContent>
        <DialogActions>
            <MudStack Row="true" Class="mb-1">
                @Actions
            </MudStack>
        </DialogActions>
    </MudDialog>
}
else
{
    <MudDialog @bind-IsVisible="Visible"  Style="max-width: inherit !important;">
        <DialogContent>
            <MudStack Class="mt-n3 mb-3">
                @Content
            </MudStack>
        </DialogContent>
    </MudDialog>
}

@code{
    [CascadingParameter] public MudDialogInstance MudDialog { get; set; } = default!;

    [Parameter] public bool Visible
    {
        get => _visible;
        set
        {
            if (_visible == value) return;
            _visible = value;

            VisibleChanged.InvokeAsync(value);
        }
    }
    [Parameter] public EventCallback<bool> VisibleChanged { get; set; }
    [Parameter] public RenderFragment? Content { get; set; }
    [Parameter] public RenderFragment? Actions { get; set; }

    private bool _visible;
    private bool _disposed;

    protected override void OnAfterRender(bool firstRender)
    {
        if (firstRender is false) return;
    }

    public void Dispose()
    {
        Dispose(true);
        GC.SuppressFinalize(this);
    }

    private void Dispose(bool disposing)
    {
        if (_disposed is false) return;
        if (disposing is false) return;

        try
        {

        }
        finally
        {
            _disposed = true;
        }
    }
}