using DeepDrftPublic.Client.Common;
namespace DeepDrftPublic.Client.Services;
///
/// Shared cookie contract for the public-site settings seam (Phase 18 wave 18.6), the analogue of
/// . Holds the cookie names and the (de)serialization for each preference
/// so the server prerender-read service and the client cookie-write service agree on one wire format —
/// the load-bearing reason this is shared rather than duplicated. Each new preference adds its cookie name
/// and a parse/format pair here, keeping the round-trip in one place.
///
public abstract class SettingsServiceBase
{
protected const string StreamQualityCookieName = "streamQuality";
///
/// Parses the streamQuality cookie value into , defaulting to
/// (the OQ2 default) for an absent, empty, or unrecognized value so
/// a missing/garbled cookie never produces a surprising preference.
///
protected static StreamQuality ParseStreamQuality(string? cookieValue) =>
Enum.TryParse(cookieValue, ignoreCase: true, out var parsed)
? parsed
: StreamQuality.LowData;
/// Formats a for cookie storage (round-trips with ).
protected static string FormatStreamQuality(StreamQuality quality) => quality.ToString();
}