using Microsoft.Extensions.Logging;
using WebSocketSharp;

namespace RelayClient;

public static class MauiProgram
{
    // public static event Action<ChatMessage>? MessageSent;
    public static MauiApp CreateMauiApp()
    {
        //wsc.OnMessage += (sender, e) => OnWebSocketRecieved(sender, e);
        //wsc.Connect();
        var builder = MauiApp.CreateBuilder();
        builder.UseMauiApp<App>().ConfigureFonts(fonts =>
            {
                fonts.AddFont("AnonymousPro-Bold.ttf", "AnonymousProBold");
                fonts.AddFont("AnonymousPro-BoldItalic.ttf", "AnonymousProBoldItalic");
                fonts.AddFont("AnonymousPro-Italic.ttf", "AnonymousProItalic");
                fonts.AddFont("AnonymousPro-Regular.ttf", "AnonymousProRegular");
            });
        
        

#if DEBUG
        builder.Services.AddHybridWebViewDeveloperTools();
        builder.Logging.AddDebug(); 
#endif

        return builder.Build();
    }

    //public static void OnWebSocketRecieved(object? sender, MessageEventArgs e)
    //{
    //    Console.WriteLine(sender.ToString());
    //    
    //    ChatSimulator.Send(e.Data.Split(":")[0], e.Data.Split(":")[1]);
    //    // var message = new ChatMessage
    //    // {
    //    //     SenderUsername = e.Data.Split(":")[0],
    //    //     Text = e.Data.Split(":")[1],
    //    //     Timestamp = DateTime.Now
    //    // };
    //    //
    //    // MessageSent?.Invoke(message);
    //}
}