#pragma once

#include <string>

namespace aptt {

enum class DeviceLifecycleState {
  kDiscovered,
  kReserved,
  kPrepared,
  kRunningSignal,
  kRunningSilence,
  kDraining,
  kHeldOpen,
  kReleasing,
  kReleased,
  kFaulted,
};

struct LifecyclePolicy {
  bool allow_immediate_release = false;
  bool allow_reinitialize_loop = false;
  bool known_problem_device = false;
};

struct TransitionDecision {
  bool allowed = false;
  bool safety_warning = false;
  const char* reason = "";
};

const char* ToString(DeviceLifecycleState state);

TransitionDecision EvaluateTransition(
    DeviceLifecycleState from,
    DeviceLifecycleState to,
    const LifecyclePolicy& policy = {});

bool IsRunning(DeviceLifecycleState state);
bool IsTerminal(DeviceLifecycleState state);

}  // namespace aptt

