using Microsoft.AspNetCore.Components;
namespace AIStudio.Components;
/// 
/// Configuration component for any boolean option.
/// 
public partial class ConfigurationOption : ConfigurationBase
{
    /// 
    /// Text to display when the option is true.
    /// 
    [Parameter]
    public string LabelOn { get; set; } = string.Empty;
    
    /// 
    /// Text to display when the option is false.
    /// 
    [Parameter]
    public string LabelOff { get; set; } = string.Empty;
    
    /// 
    /// The boolean state of the option.
    /// 
    [Parameter]
    public Func State { get; set; } = () => false;
    
    /// 
    /// An action which is called when the option is changed.
    /// 
    [Parameter]
    public Action StateUpdate { get; set; } = _ => { };
    
    private async Task OptionChanged(bool updatedState)
    {
        this.StateUpdate(updatedState);
        await this.SettingsManager.StoreSettings();
    }
}