import type { FeatureState, PolicyApiClient, PolicySnapshotDto } from '../../api/policy/PolicyApiClient';

export class PolicyService {
  constructor(private readonly apiClient: PolicyApiClient) {}

  getSnapshot(): Promise<PolicySnapshotDto> {
    return this.apiClient.getSnapshot();
  }

  getCapabilityState(snapshot: PolicySnapshotDto, capabilityKey: string): FeatureState {
    return snapshot.capabilities[capabilityKey] ?? 'hidden';
  }

  isCapabilityEnabled(snapshot: PolicySnapshotDto, capabilityKey: string): boolean {
    return this.getCapabilityState(snapshot, capabilityKey) === 'enabled';
  }
}