"use strict"
// tracing: off
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.bindAllParN_ =
  exports.bindAllParN =
  exports.bindAllPar_ =
  exports.bindAllPar =
  exports.bindAll_ =
  exports.bindAll =
  exports.structParN_ =
  exports.structParN =
  exports.structPar =
  exports.struct =
    void 0
const R = __importStar(require("../Collections/Immutable/Dictionary"))
const core_1 = require("./core")
const forEach_1 = require("./forEach")
function struct(r, __trace) {
  return core_1.map_(
    forEach_1.forEach_(
      R.collect_(r, (k, v) => [k, v]),
      ([_, e]) => core_1.map_(e, (a) => [_, a]),
      __trace
    ),
    (values) => {
      const res = {}
      for (const [k, v] of values) {
        res[k] = v
      }
      return res
    }
  )
}
exports.struct = struct
function structPar(r, __trace) {
  return core_1.map_(
    forEach_1.forEachPar_(
      R.collect_(r, (k, v) => [k, v]),
      ([_, e]) => core_1.map_(e, (a) => [_, a]),
      __trace
    ),
    (values) => {
      const res = {}
      for (const [k, v] of values) {
        res[k] = v
      }
      return res
    }
  )
}
exports.structPar = structPar
/**
 * @dataFirst structParN_
 */
function structParN(n, __trace) {
  // @ts-expect-error
  return (r) => structParN_(r, n, __trace)
}
exports.structParN = structParN
function structParN_(r, n, __trace) {
  return core_1.map_(
    forEach_1.forEachParN_(
      R.collect_(r, (k, v) => [k, v]),
      n,
      ([_, e]) => core_1.map_(e, (a) => [_, a]),
      __trace
    ),
    (values) => {
      const res = {}
      for (const [k, v] of values) {
        res[k] = v
      }
      return res
    }
  )
}
exports.structParN_ = structParN_
/**
 * @dataFirst bindAll_
 */
function bindAll(r, __trace) {
  // @ts-expect-error
  return (s) => bindAll_(s, r, __trace)
}
exports.bindAll = bindAll
function bindAll_(s, r, __trace) {
  return core_1.chain_(s, (k) =>
    core_1.map_(
      forEach_1.forEach_(
        R.collect_(r(k), (k, v) => [k, v]),
        ([_, e]) => core_1.map_(e, (a) => [_, a]),
        __trace
      ),
      (values) => {
        const res = {}
        for (const [k, v] of values) {
          res[k] = v
        }
        return Object.assign(res, k)
      }
    )
  )
}
exports.bindAll_ = bindAll_
/**
 * @dataFirst bindAllPar_
 */
function bindAllPar(r, __trace) {
  // @ts-expect-error
  return (s) => bindAllPar_(s, r, __trace)
}
exports.bindAllPar = bindAllPar
function bindAllPar_(s, r, __trace) {
  return core_1.chain_(s, (k) =>
    core_1.map_(
      forEach_1.forEachPar_(
        R.collect_(r(k), (k, v) => [k, v]),
        ([_, e]) => core_1.map_(e, (a) => [_, a]),
        __trace
      ),
      (values) => {
        const res = {}
        for (const [k, v] of values) {
          res[k] = v
        }
        return Object.assign(res, k)
      }
    )
  )
}
exports.bindAllPar_ = bindAllPar_
/**
 * @dataFirst bindAllParN_
 */
function bindAllParN(n, r, __trace) {
  // @ts-expect-error
  return (s) => bindAllParN_(s, n, r, __trace)
}
exports.bindAllParN = bindAllParN
function bindAllParN_(s, n, r, __trace) {
  return core_1.chain_(s, (k) =>
    core_1.map_(
      forEach_1.forEachParN_(
        R.collect_(r(k), (k, v) => [k, v]),
        n,
        ([_, e]) => core_1.map_(e, (a) => [_, a]),
        __trace
      ),
      (values) => {
        const res = {}
        for (const [k, v] of values) {
          res[k] = v
        }
        return Object.assign(res, k)
      }
    )
  )
}
exports.bindAllParN_ = bindAllParN_
//# sourceMappingURL=struct.js.map
