export const CAPABILITY_PROFILES = Object.freeze({
  monitoring_only: Object.freeze({ assessments: true, probes: false, remediation: false, adversarial: false }),
  monitoring_and_probes: Object.freeze({ assessments: true, probes: true, remediation: false, adversarial: false }),
  active_security: Object.freeze({ assessments: true, probes: true, remediation: true, adversarial: false }),
  adversarial_probing: Object.freeze({ assessments: true, probes: true, remediation: true, adversarial: true }),
});

export function assertProfile(profile) {
  if (!Object.hasOwn(CAPABILITY_PROFILES, profile)) throw new Error(`Unknown enrolled capability profile: ${String(profile)}.`);
  return profile;
}

export function permits(profile, capability) {
  const policy = CAPABILITY_PROFILES[assertProfile(profile)];
  if (capability.kind === "assessment") return policy.assessments;
  if (capability.kind === "remediation") return policy.remediation;
  if (capability.kind === "adversarial_probe") return policy.adversarial;
  return false;
}
