"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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.crossN = void 0;
// ets_tracing: off
const A = __importStar(require("../../Collections/Immutable/Array"));
const Function_1 = require("../../Function");
const flattenTuples_1 = require("./_internal/flattenTuples");
const cross_1 = require("./cross");
const map_1 = require("./map");
/**
 * Composes the specified streams to create a cartesian product of elements
 * with a specified function. Subsequent streams would be run multiple times,
 * for every combination of elements in the prior streams.
 *
 * See also `Stream#zipN` for the more common point-wise variant.
 */
function crossN(...[s1, s2, ...streams]) {
    return (f) => {
        return ((0, map_1.map)((_) => f(...(0, flattenTuples_1.flattenTuples)(_)))(A.reduce_(streams, (0, cross_1.cross_)(s1, s2), cross_1.cross_)));
    };
}
exports.crossN = crossN;
//# sourceMappingURL=crossN.js.map