using Febe.Browser.Cdp;
using Febe.Browser.Hosting;
using Febe.Core.Abstractions;
namespace Febe.App;
///
/// The browser of Febe as the shared composition sees it (spec §5, §6.1): Chromium on Xvfb in Docker, WebView2 in the
/// window «Browser di Febe» on Windows, or Edge started as a process (the last fallback of S2). It owns the
/// , starts it with retries, and does the few things the composition needs around it: rest
/// page, «Alberto is driving», showing and hiding the window, «Scollega».
///
public interface IFebeBrowser : IAsyncDisposable
{
/// The page session: stable for the whole life of the composition (a restart keeps the same object).
ICdpSession Cdp { get; }
/// Leases taken while Alberto uses the browser (connection page, remote view, the window in front).
UserDrivingGate UserDriving { get; }
/// True while at least one lease is open: the engine does not act.
bool UserIsDriving { get; }
/// True when the browser runs and commands can be sent.
bool IsAvailable { get; }
/// Why the last start failed, in Italian; null when running.
string? LastError { get; }
/// Dati/browser: holds the Instagram session.
string ProfileDirectory { get; }
/// Width of the page, always the same (spec §6.1).
int WindowWidth { get; }
/// Height of the page, always the same (spec §6.1).
int WindowHeight { get; }
/// Starts the browser, retrying with a growing wait until it works or is cancelled.
Task RunAsync(CancellationToken ct);
/// Puts the browser at rest on the blank page (spec §6.1).
Task RestAsync(CancellationToken ct);
/// Windows: brings the browser window to the front. Docker: nothing (the remote view shows it).
Task ShowToUserAsync(CancellationToken ct);
/// Windows: puts the window out of view, still open and painting (S2). Docker: nothing.
Task HideFromUserAsync(CancellationToken ct);
/// «Scollega» (spec §4.1): closes the browser, deletes the profile folder and starts it again empty.
Task RestartWithEmptyProfileAsync(CancellationToken ct);
}