"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.votes = votes;

var _rxjs = require("rxjs");

var _drr = require("../util/drr");

// Copyright 2017-2019 @polkadot/api-derive authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
function votes(api) {
  return function (referendumId) {
    let accountIds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
    return (!accountIds || !accountIds.length ? (0, _rxjs.of)([]) : api.query.democracy.voteOf.multi(accountIds.map(accountId => [referendumId, accountId]))).pipe((0, _drr.drr)());
  };
}