import type {
  BallotSecrecy,
  ElectionPositionType,
  ElectionStatus,
  EligibilityModel,
  ResultsVisibility,
  VotingMethod,
} from "@/types";

export const RANK_BASED_VOTING_METHODS: VotingMethod[] = [
  "ranked_choice_irv",
  "single_transferable_vote",
  "condorcet",
];

export function isRankBasedVotingMethod(method: VotingMethod): boolean {
  return RANK_BASED_VOTING_METHODS.includes(method);
}

export const VOTING_METHOD_LABELS: Record<VotingMethod, string> = {
  plurality: "Plurality",
  ranked_choice_irv: "Ranked choice (IRV)",
  single_transferable_vote: "Single transferable vote",
  approval: "Approval",
  condorcet: "Condorcet",
  cumulative: "Cumulative",
  weighted: "Weighted",
};

export const ELIGIBILITY_MODEL_LABELS: Record<EligibilityModel, string> = {
  member: "One member, one vote",
  property: "Property / unit-based",
  shareholder: "Weighted by shares",
  custom: "Custom entity",
};

export const VOTING_ACCESS_LABELS = {
  open: "Open vote",
  roll: "Email / voter roll",
} as const;

export const VOTING_ENTITY_TYPE_LABELS: Record<
  import("@/types").VotingEntityType,
  string
> = {
  individual: "Individual",
  property_unit: "Property / unit",
  shareholder_account: "Shareholder account",
  membership: "Membership",
  custom: "Custom",
};

export const AUTHORIZATION_STATUS_LABELS: Record<
  import("@/types").AuthorizationRecordStatus,
  string
> = {
  valid: "Valid",
  missing: "Missing",
  rejected: "Rejected",
  superseded: "Superseded",
};

export const ELIGIBILITY_STATUS_LABELS: Record<
  import("@/types").EligibilityStatus,
  string
> = {
  eligible: "Eligible",
  blocked: "Blocked",
  pending_authorization: "Pending authorization",
};

export const VERIFICATION_METHOD_LABELS: Record<
  import("@/types").BallotVerificationMethod,
  string
> = {
  email: "Email code",
  sms_2fa: "SMS code",
  email_sms: "Email + SMS code",
};

export const SIGNATURE_TYPE_LABELS: Record<
  import("@/types").DigitalSignatureType,
  string
> = {
  checkbox_consent: "Checkbox consent",
  typed: "Typed name",
  drawn: "Drawn signature",
};

export const BALLOT_SECRECY_LABELS: Record<BallotSecrecy, string> = {
  secret: "Secret ballot",
  open: "Open ballot",
};

export const RESULTS_VISIBILITY_LABELS: Record<ResultsVisibility, string> = {
  after_close: "After close",
  admin_realtime: "Realtime for admins",
};

export const POSITION_TYPE_LABELS: Record<ElectionPositionType, string> = {
  single_seat: "Single seat",
  multi_seat: "Multi seat",
  ballot_measure: "Ballot measure",
};

export const ELECTION_STATUS_LABELS: Record<ElectionStatus, string> = {
  draft: "Draft",
  open: "Open",
  closed: "Closed",
  certified: "Certified",
};
