import '../../../domain/entities/camera_lock.dart';

abstract class LockEvent {}

/// Try to acquire a lock on a camera
class TryLock extends LockEvent {
  final int cameraId;
  final CameraLockPriority priority;

  TryLock(this.cameraId, {this.priority = CameraLockPriority.low});
}

/// Release a camera lock
class ReleaseLock extends LockEvent {
  final int cameraId;
  ReleaseLock(this.cameraId);
}

/// Release all locks held by this keyboard
class ReleaseAllLocks extends LockEvent {}

/// Request takeover of a camera locked by another keyboard
class RequestTakeover extends LockEvent {
  final int cameraId;
  final CameraLockPriority priority;

  RequestTakeover(this.cameraId, {this.priority = CameraLockPriority.low});
}

/// Confirm or reject a takeover request from another keyboard
class ConfirmTakeover extends LockEvent {
  final int cameraId;
  final bool confirm;

  ConfirmTakeover(this.cameraId, {required this.confirm});
}

/// Reset lock expiration (keep-alive during PTZ)
class ResetLockExpiration extends LockEvent {
  final int cameraId;
  ResetLockExpiration(this.cameraId);
}

/// Internal: lock state updated from coordinator WebSocket
class LocksUpdated extends LockEvent {
  final Map<int, CameraLock> locks;
  LocksUpdated(this.locks);
}

/// Internal: lock notification received from coordinator
class LockNotificationReceived extends LockEvent {
  final CameraLockNotification notification;
  LockNotificationReceived(this.notification);
}

/// Internal: coordinator connection status changed
class CoordinatorConnectionChanged extends LockEvent {
  final bool connected;
  CoordinatorConnectionChanged(this.connected);
}
