import * as tsplus_module_1 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/validateWith";
import * as tsplus_module_3 from "@tsplus/stdlib/collections/Chunk/isEmpty";
import * as tsplus_module_4 from "@tsplus/stdlib/collections/Chunk/definition";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/succeedNow";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/fail";
import * as tsplus_module_7 from "@effect/core/io/Effect/operations/partition";
import * as tsplus_module_8 from "@effect/core/io/Effect/operations/flatMap";
/**
 * Sequentially zips the this result with the specified result. Combines both
 * `Cause<E1>` when both effects fail.
 *
 * @tsplus fluent ets/Effect validate
 */

export function validateNow_(self, that, __tsplusTrace) {
  return tsplus_module_2.validateWith_(self, that, (a, b) => tsplus_module_1.make(a, b), __tsplusTrace);
}
/**
 * Sequentially zips the this result with the specified result. Combines both
 * `Cause<E1>` when both effects fail.
 *
 * @tsplus static ets/Effect/Aspects validate
 */

export const validateNow = (that, __tsplusTrace) => self => validateNow_(self, that, __tsplusTrace);
/**
 * Feeds elements of type `A` to `f` and accumulates all errors in error
 * channel or successes in success channel.
 *
 * This combinator is lossy meaning that if there are errors all successes
 * will be lost. To retain all information please use `partition`.
 *
 * @tsplus static ets/Effect/Ops validate
 */

export function validate(as, f, __tsplusTrace) {
  return tsplus_module_8.flatMap_(tsplus_module_7.partition(as, f, __tsplusTrace), ({
    tuple: [es, bs]
  }) => tsplus_module_3.isEmpty(es) ? tsplus_module_5.succeedNow(tsplus_module_4.from(bs), __tsplusTrace) : tsplus_module_6.fail(() => es, __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=validate.mjs.map