import * as tsplus_module_1 from "@tsplus/stdlib/data/Maybe/definition";
import * as tsplus_module_2 from "@effect/core/io/Cause/operations/map";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/timeoutFailCause";
import * as tsplus_module_4 from "@effect/core/stream/Stream/operations/toPull";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/map";
import * as tsplus_module_6 from "@effect/core/stream/Stream/operations/fromPull";
import * as tsplus_module_7 from "@tsplus/stdlib/data/Tuple/make";
import * as tsplus_module_8 from "@effect/core/stream/Stream/operations/succeed";
import * as tsplus_module_9 from "@effect/core/stream/Stream/operations/flatMap";
/**
 * Fails the stream with given cause if it does not produce a value after the
 * specified duration.
 *
 * @tsplus fluent ets/Stream timeoutFailCause
 */

export function timeoutFailCause_(self, cause, duration, __tsplusTrace) {
  return tsplus_module_9.flatMap_(tsplus_module_8.succeed(() => tsplus_module_7.make(cause(), duration()), __tsplusTrace), ({
    tuple: [cause, duration]
  }) => tsplus_module_6.fromPull(() => tsplus_module_5.map_(tsplus_module_4.toPull(self, __tsplusTrace), pull => tsplus_module_3.timeoutFailCause_(pull, () => tsplus_module_2.map_(cause, tsplus_module_1.some), () => duration, __tsplusTrace), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
/**
 * Fails the stream with given cause if it does not produce a value after the
 * specified duration.
 *
 * @tsplus static ets/Stream/Aspects timeoutFailCause
 */

export const timeoutFailCause = (cause, duration, __tsplusTrace) => self => timeoutFailCause_(self, cause, duration, __tsplusTrace);
//# sourceMappingURL=timeoutFailCause.mjs.map