import * as tsplus_module_1 from "@effect/core/stream/Stream/operations/fromChunkHubScoped";
import * as tsplus_module_2 from "@effect/core/io/Effect/operations/ensuring";
import * as tsplus_module_3 from "@effect/core/io/Effect/operations/succeed";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/flatMap";
/**
 * Creates a stream from a subscription to a hub in the context of a scoped
 * effect. The scoped effect describes subscribing to receive messages from
 * the hub while the stream describes taking messages from the hub.
 *
 * The hub will be shut down once the stream is closed.
 *
 * @tsplus static ets/Stream/Ops fromChunkHubScopedWithShutdown
 */

export function fromChunkHubScopedWithShutdown(hub, __tsplusTrace) {
  return tsplus_module_4.flatMap_(tsplus_module_3.succeed(hub, __tsplusTrace), hub => tsplus_module_2.ensuring_(tsplus_module_1.fromChunkHubScoped(() => hub, __tsplusTrace), () => hub.shutdown, __tsplusTrace), __tsplusTrace);
}
//# sourceMappingURL=fromChunkHubScopedWithShutdown.mjs.map