import 'package:sentinel_shield/core/permissions/permission_capability.dart';

enum CapabilityPermissionState {
  granted,
  denied,
  permanentlyDenied,
  restricted,
  unsupported,
}

class PermissionActivationState {
  const PermissionActivationState({
    required this.states,
    required this.developerModeEnabled,
    required this.deviceOwnerRequired,
  });

  final Map<PermissionCapability, CapabilityPermissionState> states;
  final bool developerModeEnabled;
  final bool deviceOwnerRequired;

  bool get allRuntimePermissionsGranted => states.values.every(
        (CapabilityPermissionState state) =>
            state == CapabilityPermissionState.granted ||
            state == CapabilityPermissionState.unsupported,
      );

  List<PermissionCapability> get deniedCapabilities => states.entries
      .where((MapEntry<PermissionCapability, CapabilityPermissionState> item) =>
          item.value != CapabilityPermissionState.granted &&
          item.value != CapabilityPermissionState.unsupported)
      .map((MapEntry<PermissionCapability, CapabilityPermissionState> item) =>
          item.key)
      .toList(growable: false);
}
