"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.structParN_ = exports.structParN = exports.structPar = exports.struct = void 0;
// ets_tracing: off
const R = __importStar(require("../Collections/Immutable/Dictionary"));
const excl_forEach_1 = require("./excl-forEach");
const map_1 = require("./map");
/**
 * Applicative structure
 */
function struct(r, __trace) {
    return (0, map_1.map_)((0, excl_forEach_1.forEach_)(R.collect_(r, (k, v) => [k, v]), ([_, e]) => (0, map_1.map_)(e, (a) => [_, a]), __trace), (values) => {
        const res = {};
        for (const [k, v] of values) {
            res[k] = v;
        }
        return res;
    });
}
exports.struct = struct;
/**
 * Applicative structure processed in parallel
 */
function structPar(r, __trace) {
    return (0, map_1.map_)((0, excl_forEach_1.forEachPar_)(R.collect_(r, (k, v) => [k, v]), ([_, e]) => (0, map_1.map_)(e, (a) => [_, a]), __trace), (values) => {
        const res = {};
        for (const [k, v] of values) {
            res[k] = v;
        }
        return res;
    });
}
exports.structPar = structPar;
/**
 * Applicative structure processed in parallel with up to N fibers
 *
 * @ets_data_first structParN_
 */
function structParN(n, __trace) {
    return (r) => 
    // @ts-expect-error
    structParN_(r, n, __trace);
}
exports.structParN = structParN;
/**
 * Applicative structure processed in parallel with up to N fibers
 */
function structParN_(r, n, __trace) {
    return (0, map_1.map_)((0, excl_forEach_1.forEachParN_)(R.collect_(r, (k, v) => [k, v]), n, ([_, e]) => (0, map_1.map_)(e, (a) => [_, a]), __trace), (values) => {
        const res = {};
        for (const [k, v] of values) {
            res[k] = v;
        }
        return res;
    });
}
exports.structParN_ = structParN_;
//# sourceMappingURL=struct.js.map