import * as tsplus_module_1 from "@effect/core/io/Layer/operations/failCause";
import * as tsplus_module_2 from "@effect/core/io/Cause/operations/failureOrCause";
import * as tsplus_module_3 from "@tsplus/stdlib/data/Either/fold";
import * as tsplus_module_4 from "@effect/core/io/Layer/operations/foldCauseLayer";
/**
 * Feeds the error or output services of this layer into the input of either
 * the specified `failure` or `success` layers, resulting in a new layer with
 * the inputs of this layer, and the error or outputs of the specified layer.
 *
 * @tsplus fluent ets/Layer foldLayer
 */

export function foldLayer_(self, failure, success) {
  return tsplus_module_4.foldCauseLayer_(self, cause => tsplus_module_3.fold_(tsplus_module_2.failureOrCause(cause), failure, cause => tsplus_module_1.failCause(() => cause)), success);
}
/**
 * Feeds the error or output services of this layer into the input of either
 * the specified `failure` or `success` layers, resulting in a new layer with
 * the inputs of this layer, and the error or outputs of the specified layer.
 *
 * @tsplus static ets/Layer/Aspects foldLayer
 */

export const foldLayer = (failure, success) => self => foldLayer_(self, failure, success);
//# sourceMappingURL=foldLayer.mjs.map