using System;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using Microsoft.AspNetCore.Components;

using CommonHelpers.WASM;
using AFXUI;

using BookRegistry.Client.Shared;

namespace BookRegistry.Client {

//**************************************************************************************************
public abstract partial class AComponent: UComponentBase {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected const string
   General_Role = ServiceRoleNames.General,
   Admin_Role = ServiceRoleNames.Administrator,
   Authorization_Roles = ServiceRoleNames.AuthorizationRoles;
//==================================================================================================

public AComponent(): base()
{}

protected AComponent(bool isPageComponent)
: base( isPageComponent )
{}

//==================================================================================================

/// <exception cref="InvalidOperationException" />
public static bool WasAbandoned_Notify_Deactivate(SimpleSIR simpleResult) =>
   ForeOperation.WasAbandoned_Notify_Deactivate( simpleResult );

//--------------------------------------------------------------------------------------------------

public static async Task<bool> ESC_HasRequestError_ShowError_A(SimpleSIR simpleResult)
{
   if ( simpleResult.Success )
      return false;
   await ESC_ShowRequestError_A( simpleResult );
   return true;
}

public static Task<string> ESC_SetOpFailureShowError_UnexpectedResponse_A() =>
   ESC_SetOpFailureShowError_UnexpectedResponse_A( null );
public static async Task<string> ESC_SetOpFailureShowError_UnexpectedResponse_A(
   string? additionalMessage=null )
{
   string? message = ForeOperation.SetOpFailure_UnexpectedResponse_A( additionalMessage );
   await ESC_ShowRequestError_Unexpected_A( additionalMessage );
   return message;
}

//==================================================================================================

public virtual ElementReference? MainElement { get => null; }
public virtual ElementReference? AdditionalElement { get => null; }
public virtual ElementReference? AdditionalElement_2 { get => null; }
public virtual ElementReference? AdditionalElement_3 { get => null; }

public virtual bool IsEnabled { get => MainElement.IsEnabled(); }
public virtual bool ContainsFocus { get => MainElement.ContainsFocus(); }

//==================================================================================================

public virtual string? Interop_ErrorMessage => null;

public virtual AResetControl? Interop_OuterResetControl { get => null; set {} }
public virtual AUpResetControl? Interop_OuterUpResetControl { get => null; set {} }

public virtual bool Interop_Focus() => false;
public virtual bool Interop_DeferredFocus() => false;
public virtual bool Interop_Click() => false;
public virtual bool Interop_Reset() => false;
public virtual bool Interop_UpReset() => false;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // AComponent
//**************************************************************************************************

} // BookRegistry.Client
