#pragma once
// ── CS2 External C++ WebRadar — Config ───────────────────────────────────────
// Loads webradar.config.json.
// Matches C# WebRadarConfig.cs.

#include <string>
#include <fstream>
#include <nlohmann/json.hpp>

struct WebRadarConfig {
    std::string web_asset_root = "webapp";
    int         websocket_port = 8082;
    std::string websocket_path = "/ws";

    static WebRadarConfig load(const std::string& path) {
        WebRadarConfig cfg;
        try {
            std::ifstream f(path);
            if (!f.is_open()) return cfg;
            auto j = nlohmann::json::parse(f);

            if (j.contains("Web_Asset_Root")) cfg.web_asset_root = j["Web_Asset_Root"];
            if (j.contains("WebSocket_Port")) cfg.websocket_port = j["WebSocket_Port"];
            if (j.contains("WebSocket_Path")) cfg.websocket_path = j["WebSocket_Path"];
        } catch (...) {}
        return cfg;
    }
};
