"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeUnbounded = exports.makeBounded = void 0;
// ets_tracing: off
require("../../Operator");
const BoundedHubArb_1 = require("./BoundedHubArb");
const BoundedHubPow2_1 = require("./BoundedHubPow2");
const BoundedHubSingle_1 = require("./BoundedHubSingle");
const errors_1 = require("./errors");
const UnboundedHub_1 = require("./UnboundedHub");
function nextPow2(n) {
    const nextPow = Math.ceil(Math.log(n) / Math.log(2.0));
    return Math.max(Math.pow(2, nextPow), 2);
}
function makeBounded(requestedCapacity) {
    (0, errors_1.ensureCapacity)(requestedCapacity);
    if (requestedCapacity === 1) {
        return new BoundedHubSingle_1.BoundedHubSingle();
    }
    else if (nextPow2(requestedCapacity) === requestedCapacity) {
        return new BoundedHubPow2_1.BoundedHubPow2(requestedCapacity);
    }
    else {
        return new BoundedHubArb_1.BoundedHubArb(requestedCapacity);
    }
}
exports.makeBounded = makeBounded;
function makeUnbounded() {
    return new UnboundedHub_1.UnboundedHub();
}
exports.makeUnbounded = makeUnbounded;
__exportStar(require("./Hub"), exports);
//# sourceMappingURL=hubFactory.js.map