declare const VOTING_METHOD_IDS: { readonly SINGLE_CHOICE: "single-choice@1"; readonly RANKED_CHOICE_IRV: "ranked-choice-irv@1"; }; type VotingMethodId = (typeof VOTING_METHOD_IDS)[keyof typeof VOTING_METHOD_IDS]; type OptionId = string; type TallyOutcome = "winner" | "tie" | "no-valid-ballots"; interface TallyOption { id: OptionId; tieBreakRank: number; } interface WeightedBallot { id: string; weight: bigint; rankings: readonly OptionId[]; } interface SingleChoiceConfig { method: typeof VOTING_METHOD_IDS.SINGLE_CHOICE; } interface RankedChoiceIrvConfig { method: typeof VOTING_METHOD_IDS.RANKED_CHOICE_IRV; allowPartialRanking: true; maxRankings: number; majorityBasis: "continuing-weight"; eliminationTieBreak: "previous-round-then-option-order"; finalTie: "return-tie"; } type TallyConfig = SingleChoiceConfig | RankedChoiceIrvConfig; interface TallyInput { options: readonly TallyOption[]; ballots: readonly WeightedBallot[]; config: TallyConfig; } interface TallyRound { round: number; activeOptionIds: readonly OptionId[]; tallies: Readonly>; continuingWeight: bigint; exhaustedWeight: bigint; eliminatedOptionId?: OptionId; majorityThreshold: bigint; } interface TallyResult { method: VotingMethodId; outcome: TallyOutcome; winnerOptionId?: OptionId; totalBallotWeight: bigint; finalContinuingWeight: bigint; finalExhaustedWeight: bigint; rounds: readonly TallyRound[]; configHash: string; ballotSetHash: string; resultHash: string; } type VotingTallyErrorCode = "invalid-config" | "invalid-option-count" | "invalid-option-id" | "duplicate-option-id" | "invalid-tie-break-rank" | "duplicate-tie-break-rank" | "non-contiguous-tie-break-rank" | "invalid-ballot-id" | "duplicate-ballot-id" | "invalid-ballot-weight" | "empty-ranking" | "ranking-too-long" | "unknown-ranked-option" | "duplicate-ranked-option" | "invalid-single-choice-ranking"; declare class VotingTallyError extends Error { readonly code: VotingTallyErrorCode; readonly path?: string; constructor(code: VotingTallyErrorCode, message: string, path?: string); } declare const VOTING_CONTRACT_METHOD_IDS: Readonly>; declare function validateTallyInput(input: TallyInput): void; declare function hashTallyConfig(options: readonly TallyOption[], config: TallyConfig): string; declare function hashWeightedBallot(ballot: WeightedBallot): string; declare function hashBallotSet(ballots: readonly WeightedBallot[]): string; declare function tallyVotes(input: TallyInput): TallyResult; export { type OptionId, type RankedChoiceIrvConfig, type SingleChoiceConfig, type TallyConfig, type TallyInput, type TallyOption, type TallyOutcome, type TallyResult, type TallyRound, VOTING_CONTRACT_METHOD_IDS, VOTING_METHOD_IDS, type VotingMethodId, VotingTallyError, type VotingTallyErrorCode, type WeightedBallot, hashBallotSet, hashTallyConfig, hashWeightedBallot, tallyVotes, validateTallyInput };