using System.Net;
using Microsoft.AspNetCore.Antiforgery;
namespace SharepointToolbox.Web.Infrastructure.Auth;
/// Renders the combined login page (Microsoft / Entra button + local credential form)
/// as a self-contained static HTML response. Lives outside the interactive Blazor circuit so
/// the POST handler can issue the auth cookie directly on the HTTP request.
public static class LoginPageRenderer
{
public static string Build(
HttpContext ctx,
IAntiforgery antiforgery,
string? returnUrl,
bool showError,
bool showEntra = true,
bool showDevButton = false)
{
var tokens = antiforgery.GetAndStoreTokens(ctx);
var ru = WebUtility.HtmlEncode(returnUrl ?? "/");
var afField = WebUtility.HtmlEncode(tokens.FormFieldName);
var afToken = WebUtility.HtmlEncode(tokens.RequestToken);
var error = showError
? "