#pragma once

#include <QByteArray>
#include <QJsonArray>
#include <QJsonObject>
#include <QString>

struct BridgeStreamEvent {
    enum Kind {
        Invalid,
        Snapshot,
        State,
        Prefs,
        Netmap,
        Version,
        BrowseURL,
        Error,
        KeepAlive,
    };

    Kind kind = Invalid;
    QJsonObject snapshot;
    QJsonObject objectPayload;
    QString errorMessage;
    QString stringPayload;
};

struct PeerMenuSection {
    QString title;
    QJsonArray peers;
};

BridgeStreamEvent parseBridgeStreamLine(const QByteArray &line);
QList<PeerMenuSection> buildPeerMenuSections(const QJsonObject &snapshot);
QString peerMenuLabel(const QJsonObject &peer);
QString exitNodeMenuLabel(const QJsonObject &exitNode);
