#pragma once
// The REAPER read/write half of the per-mode solo surface. Every decision about what
// to cache, clear, or replay is core/view/solo_cache; this pair only moves I_SOLO
// between the live tracks and that pure plan.

#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>

#include "core/view/solo_cache.h"

// Forward-declared to keep this header SDK-free; the .cpp includes the real SDK header.
class MediaTrack;

namespace reasampler {

// The (GUID, handle) enumeration applyMode builds from GetTrack. GetTrack's index
// space excludes the master track, so no solo read or write reachable through this
// type can ever land on master.
using TrackHandles = std::vector<std::pair<std::string, MediaTrack*>>;

std::vector<view::TrackSolo> readTrackSolos(const TrackHandles& handles);

// Applies each op to its live handle in ONE pass over `handles`; an op naming a GUID
// absent from the enumeration is skipped (stale/deleted track).
void applySoloOps(const TrackHandles& handles, const std::vector<view::SoloOp>& ops);

// The outgoing-mode clear: zeroes I_SOLO for every GUID in `soloed` (the just-banked
// values applyMode is about to cache).
void clearTrackSolos(const TrackHandles& handles, const std::map<std::string, int>& soloed);

// The incoming-mode replay: applies `cached` filtered through planSoloRestore's drop
// rules (dead GUID, not visible in the incoming mode).
void restoreTrackSolos(const TrackHandles& handles,
                       const std::map<std::string, int>& cached,
                       const std::set<std::string>& liveGuids,
                       const std::set<std::string>& visibleGuids);

} // namespace reasampler
