"use strict";

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

var _rxjs = require("rxjs");

var _operators = require("rxjs/operators");

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

var _referendumInfo = require("./referendumInfo");

// 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 referendumInfos(api) {
  return function () {
    let ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
    return (!ids || !ids.length ? (0, _rxjs.of)([]) : api.query.democracy.referendumInfoOf.multi(ids)).pipe((0, _operators.map)(infos => ids.map((id, index) => (0, _referendumInfo.constructInfo)(id, infos[index]))), (0, _drr.drr)());
  };
}