/**
 * The `Sink` module provides composable consumers for `Stream` values. A
 * `Sink<A, In, L, E, R>` pulls input elements of type `In`, may require
 * services `R`, may fail with `E`, and eventually produces a result `A` plus
 * any leftover input `L` that was read but not consumed.
 *
 * **Mental model**
 *
 * - A sink is the terminal consumer used by `Stream.run`
 * - Sinks can consume zero, one, many, or all input elements before finishing
 * - Leftovers allow one sink to stop early without losing already-pulled input
 * - Sink composition preserves typed errors and service requirements
 * - Most sinks are built from `Channel` internally, but users compose them with
 *   the higher-level APIs in this module
 *
 * **Common tasks**
 *
 * - Create simple sinks: {@link succeed}, {@link fail}, {@link fromEffect}
 * - Fold input: {@link fold}
 * - Collect values: {@link collect}
 * - Count or drain input: {@link count}, {@link drain}
 * - Transform results: {@link map}, {@link mapEffect}, {@link as}
 * - Adapt input before consumption: {@link mapInput}, {@link mapInputEffect}
 *
 * **Gotchas**
 *
 * - A sink can finish before the stream is exhausted; check leftover-aware
 *   combinators when composing parsers or protocol decoders
 * - `In` is contravariant, so a sink that accepts broader input can be used
 *   where narrower input is expected
 * - Resource and service requirements are tracked in the `R` type parameter
 *
 * @since 2.0.0
 */
import type { NonEmptyReadonlyArray } from "./Array.ts";
import * as Arr from "./Array.ts";
import * as Cause from "./Cause.ts";
import * as Channel from "./Channel.ts";
import type * as Context from "./Context.ts";
import * as Duration from "./Duration.ts";
import * as Effect from "./Effect.ts";
import * as Exit from "./Exit.ts";
import type * as Filter from "./Filter.ts";
import type { LazyArg } from "./Function.ts";
import * as Option from "./Option.ts";
import { type Pipeable } from "./Pipeable.ts";
import type { Predicate, Refinement } from "./Predicate.ts";
import * as PubSub from "./PubSub.ts";
import * as Pull from "./Pull.ts";
import * as Queue from "./Queue.ts";
import * as Scope from "./Scope.ts";
import type { Stream } from "./Stream.ts";
import type * as Types from "./Types.ts";
import type * as Unify from "./Unify.ts";
declare const TypeId = "~effect/Sink";
/**
 * A `Sink<A, In, L, E, R>` is used to consume elements produced by a `Stream`.
 * You can think of a sink as a function that will consume a variable amount of
 * `In` elements (could be 0, 1, or many), might fail with an error of type `E`,
 * and will eventually yield a value of type `A` together with a remainder of
 * type `L` (i.e. any leftovers).
 *
 * **Example** (Running a sink with a stream)
 *
 * ```ts
 * import { Effect, Sink, Stream } from "effect"
 *
 * // Create a simple sink that always succeeds with a value
 * const sink: Sink.Sink<number> = Sink.succeed(42)
 *
 * // Use the sink to consume a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).then(console.log)
 * // Output: 42
 * ```
 *
 * @category models
 * @since 2.0.0
 */
export interface Sink<out A, in In = unknown, out L = never, out E = never, out R = never> extends Sink.Variance<A, In, L, E, R>, Pipeable {
    readonly transform: (upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>, scope: Scope.Scope) => Effect.Effect<End<A, L>, E, R>;
    [Unify.typeSymbol]?: unknown;
    [Unify.unifySymbol]?: SinkUnify<this>;
    [Unify.ignoreSymbol]?: SinkUnifyIgnore;
}
/**
 * Tuple returned when a `Sink` finishes.
 *
 * **Details**
 *
 * The first element is the sink result. The optional second element contains a
 * non-empty array of leftover input that was pulled but not consumed.
 *
 * @category models
 * @since 4.0.0
 */
export type End<A, L = never> = readonly [value: A, leftover?: NonEmptyReadonlyArray<L> | undefined];
/**
 * Type-level unification support for `Sink` values.
 *
 * **Details**
 *
 * This preserves the result, input, leftover, error, and service type
 * parameters when Effect's `Unify` machinery normalizes generic values that
 * include sinks. Users normally do not need to reference this interface
 * directly.
 *
 * @category models
 * @since 2.0.0
 */
export interface SinkUnify<A extends {
    [Unify.typeSymbol]?: any;
}> extends Effect.EffectUnify<A> {
    Sink?: () => A[Unify.typeSymbol] extends Sink<infer A, infer In, infer L, infer E, infer R> | infer _ ? Sink<A, In, L, E, R> : never;
}
/**
 * Marker used by Effect's `Unify` machinery for `Sink` values.
 *
 * **Details**
 *
 * It prevents the inherited `Effect` unifier from being selected when
 * sink-specific unification should preserve the `Sink` type parameters. Users
 * normally do not need to reference this interface directly.
 *
 * @category models
 * @since 2.0.0
 */
export interface SinkUnifyIgnore {
    Effect?: true;
}
/**
 * Namespace containing types and interfaces for Sink variance and type relationships.
 *
 * @since 2.0.0
 */
export declare namespace Sink {
    /**
     * Type-level variance marker for `Sink`.
     *
     * **Details**
     *
     * The result `A`, leftovers `L`, errors `E`, and services `R` are
     * covariant. The input type `In` is contravariant because values flow into
     * the sink.
     *
     * @category models
     * @since 2.0.0
     */
    interface Variance<out A, in In, out L, out E, out R> {
        readonly [TypeId]: VarianceStruct<A, In, L, E, R>;
    }
    /**
     * Structural encoding used by `Sink.Variance` to record each `Sink` type
     * parameter's variance.
     *
     * **Details**
     *
     * `_A`, `_L`, `_E`, and `_R` are covariant markers. `_In` is a
     * contravariant marker.
     *
     * @category models
     * @since 2.0.0
     */
    interface VarianceStruct<out A, in In, out L, out E, out R> {
        _A: Types.Covariant<A>;
        _In: Types.Contravariant<In>;
        _L: Types.Covariant<L>;
        _E: Types.Covariant<E>;
        _R: Types.Covariant<R>;
    }
}
/**
 * Checks whether a value is a Sink.
 *
 * **Example** (Checking for a sink)
 *
 * ```ts
 * import { Sink } from "effect"
 *
 * const sink = Sink.never
 * const notStream = { data: [1, 2, 3] }
 *
 * console.log(Sink.isSink(sink)) // true
 * console.log(Sink.isSink(notStream)) // false
 * ```
 *
 * @category guards
 * @since 4.0.0
 */
export declare const isSink: (u: unknown) => u is Sink<unknown, never, unknown, unknown, unknown>;
/**
 * Creates a sink from a `Channel`.
 *
 * **When to use**
 *
 * Use to create a `Sink` from a `Channel` that processes non-empty arrays of
 * input values.
 *
 * @see {@link toChannel} for converting a `Sink` back to a `Channel`
 * @category constructors
 * @since 2.0.0
 */
export declare const fromChannel: <L, In, E, A, R>(channel: Channel.Channel<never, E, End<A, L>, NonEmptyReadonlyArray<In>, never, void, R>) => Sink<A, In, L, E, R>;
/**
 * Creates a `Sink` from a low-level transform function.
 *
 * **Details**
 *
 * The transform receives the upstream pull of non-empty input arrays and the
 * active scope, and returns an effect that completes with the sink's `End`
 * value.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const fromTransform: <In, A, E, R, L = never>(transform: (upstream: Pull.Pull<NonEmptyReadonlyArray<In>, never, void>, scope: Scope.Scope) => Effect.Effect<End<A, L>, E, R>) => Sink<A, In, L, E, R>;
/**
 * Creates a `Channel` from a Sink.
 *
 * **Example** (Converting a sink to a channel)
 *
 * ```ts
 * import { Sink } from "effect"
 *
 * // Create a sink and extract its channel
 * const sink = Sink.succeed(42)
 * const channel = Sink.toChannel(sink)
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const toChannel: <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Channel.Channel<never, E, End<A, L>, NonEmptyReadonlyArray<In>, never, void, R>;
/**
 * Creates a pipe-style constructor for sinks over input type `In`.
 *
 * **Details**
 *
 * The returned function exposes the sink input as a `Stream<In>`, applies the
 * provided pipeline, and uses the final effect's success value as the sink
 * result.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const make: <In>() => make.Constructor<In>;
/**
 * Companion namespace containing overload types for the pipe-style sink
 * constructor returned by `Sink.make`.
 *
 * @since 4.0.0
 */
export declare namespace make {
    /**
     * Overloaded function type returned by `Sink.make`.
     *
     * **Details**
     *
     * The first pipeline function receives the sink input as a `Stream<In>`. The
     * final pipeline step must return an `Effect`, whose success value becomes
     * the sink result.
     *
     * @category models
     * @since 4.0.0
     */
    interface Constructor<In> {
        <E, R, B = never>(ab: (_: Stream<In>) => Effect.Effect<B, E, R>): Sink<B, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never>(ab: (_: Stream<In>) => B, bc: (_: B) => Effect.Effect<C, E, R>): Sink<C, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => Effect.Effect<D, E, R>): Sink<D, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => Effect.Effect<F, E, R>): Sink<F, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never, G = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => F, fg: (_: F) => Effect.Effect<G, E, R>): Sink<G, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never, G = never, H = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => F, fg: (_: F) => G, gh: (_: G) => Effect.Effect<H, E, R>): Sink<H, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never, G = never, H = never, I = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => Effect.Effect<I, E, R>): Sink<I, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never, G = never, H = never, I = never, J = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => Effect.Effect<J, E, R>): Sink<J, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never, G = never, H = never, I = never, J = never, K = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => Effect.Effect<K, E, R>): Sink<K, In, never, E, Exclude<R, Scope.Scope>>;
        <E, R, B = never, C = never, D = never, F = never, G = never, H = never, I = never, J = never, K = never, L = never>(ab: (_: Stream<In>) => B, bc: (_: B) => C, cd: (_: C) => D, df: (_: D) => F, fg: (_: F) => G, gh: (_: G) => H, hi: (_: H) => I, ij: (_: I) => J, jk: (_: J) => K, kl: (_: K) => Effect.Effect<L, E, R>): Sink<L, In, never, E, Exclude<R, Scope.Scope>>;
    }
}
/**
 * Creates a sink that ignores upstream input and completes from an effect that
 * already returns an `End`.
 *
 * **When to use**
 *
 * Use when the effect needs to provide both the result value and optional
 * leftovers.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const fromEffectEnd: <A, E, R, L = never>(effect: Effect.Effect<End<A, L>, E, R>) => Sink<A, unknown, L, E, R>;
/**
 * Creates a sink that ignores upstream input and completes with the success
 * value of the provided effect.
 *
 * **Details**
 *
 * If the effect fails, the sink fails with the same error.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const fromEffect: <A, E, R>(effect: Effect.Effect<A, E, R>) => Sink<A, unknown, never, E, R>;
/**
 * Creates a sink that offers every consumed input element to a queue.
 *
 * **Details**
 *
 * When the upstream stream ends, the sink ends the queue and completes with
 * `void`.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const fromQueue: <A>(queue: Queue.Queue<A, Cause.Done>) => Sink<void, A>;
/**
 * Creates a sink that publishes every consumed input element to a `PubSub`.
 *
 * **Details**
 *
 * The sink completes with `void` when the upstream stream ends.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const fromPubSub: <A>(pubsub: PubSub.PubSub<A>) => Sink<void, A>;
/**
 * A sink that immediately ends with the specified value.
 *
 * **Example** (Succeeding with a value)
 *
 * ```ts
 * import { Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that always yields the same value
 * const sink = Sink.succeed(42)
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).then(console.log)
 * // Output: 42
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const succeed: <A, L = never>(a: A, leftovers?: NonEmptyReadonlyArray<L> | undefined) => Sink<A, unknown, L>;
/**
 * A sink that immediately ends with the specified lazily evaluated value.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const sync: <A>(a: LazyArg<A>) => Sink<A>;
/**
 * A sink that is created from a lazily evaluated sink.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const suspend: <A, In, L, E, R>(evaluate: LazyArg<Sink<A, In, L, E, R>>) => Sink<A, In, L, E, R>;
/**
 * A sink that always fails with the specified error.
 *
 * **Example** (Failing with an error)
 *
 * ```ts
 * import { Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that always fails
 * const sink = Sink.fail(new Error("Sink failed"))
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).catch(console.log)
 * // Output: Error: Sink failed
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const fail: <E>(e: E) => Sink<never, unknown, never, E>;
/**
 * A sink that always fails with the specified lazily evaluated error.
 *
 * **Example** (Failing with a lazy error)
 *
 * ```ts
 * import { Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that fails with a lazy error
 * const sink = Sink.failSync(() => new Error("Lazy error"))
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).catch(console.log)
 * // Output: Error: Lazy error
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const failSync: <E>(evaluate: LazyArg<E>) => Sink<never, unknown, never, E>;
/**
 * Creates a sink halting with a specified `Cause`.
 *
 * **Example** (Failing with a cause)
 *
 * ```ts
 * import { Cause, Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that fails with a specific cause
 * const sink = Sink.failCause(Cause.fail(new Error("Custom cause")))
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).catch(console.log)
 * // Output: Error: Custom cause
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const failCause: <E>(cause: Cause.Cause<E>) => Sink<never, unknown, never, E>;
/**
 * Creates a sink halting with a specified lazily evaluated `Cause`.
 *
 * **Example** (Failing with a lazy cause)
 *
 * ```ts
 * import { Cause, Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that fails with a lazy cause
 * const sink = Sink.failCauseSync(() => Cause.fail(new Error("Lazy cause")))
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).catch(console.log)
 * // Output: Error: Lazy cause
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const failCauseSync: <E>(evaluate: LazyArg<Cause.Cause<E>>) => Sink<never, unknown, never, E>;
/**
 * Creates a sink halting with a specified defect.
 *
 * **Example** (Dying with a defect)
 *
 * ```ts
 * import { Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that dies with a defect
 * const sink = Sink.die(new Error("Defect error"))
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program).catch(console.log)
 * // Output: Error: Defect error
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const die: (defect: unknown) => Sink<never>;
/**
 * A sink that never completes.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const never: Sink<unknown>;
/**
 * Drops leftovers produced by a sink.
 *
 * **Details**
 *
 * The sink result is preserved, but any leftover elements are discarded
 * instead of being returned to downstream sink composition. This does not
 * continue pulling additional elements from the upstream stream.
 *
 * @category filtering
 * @since 2.0.0
 */
export declare const ignoreLeftover: <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, never, E, R>;
/**
 * Consumes and ignores all stream inputs.
 *
 * **When to use**
 *
 * Use to consume all upstream input and complete with void when the input
 * values and any aggregate result are not needed.
 *
 * @see {@link count} for consuming all input while returning the number of elements
 * @see {@link forEach} for consuming all input while running an effect for each element
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const drain: Sink<void, unknown>;
/**
 * A sink that folds its inputs with the provided function, termination
 * predicate and initial state.
 *
 * **When to use**
 *
 * Use to accumulate stream input element by element with an effectful step and
 * stop based on the accumulated state.
 *
 * **Details**
 *
 * The initial state is evaluated lazily. Each input element is folded with the
 * effectful function, and the sink continues while `contFn` returns `true`. If
 * the sink stops in the middle of a pulled array, the remaining elements from
 * that array are returned as leftovers.
 *
 * @see {@link foldArray} for folding each pulled non-empty input array at once
 * @see {@link foldUntil} for folding until a fixed maximum number of elements is consumed
 *
 * @category folding
 * @since 2.0.0
 */
export declare const fold: <S, In, E = never, R = never>(s: LazyArg<S>, contFn: Predicate<S>, f: (s: S, input: In) => Effect.Effect<S, E, R>) => Sink<S, In, In, E, R>;
/**
 * Folds non-empty input arrays into state with an effectful function.
 *
 * **When to use**
 *
 * Use to update state with an effectful function once per pulled non-empty
 * input array when batch-level processing is the natural unit.
 *
 * **Details**
 *
 * The initial state is evaluated lazily. After each pulled array is folded,
 * the sink continues while `contFn` returns `true`; otherwise it completes
 * with the current state.
 *
 * @see {@link fold} for folding element by element and returning leftovers when stopping mid-array
 * @see {@link reduceWhileArrayEffect} for array-level effectful reducing that checks the predicate before consuming input
 *
 * @category folding
 * @since 4.0.0
 */
export declare const foldArray: <S, In, E = never, R = never>(s: LazyArg<S>, contFn: Predicate<S>, f: (s: S, input: Arr.NonEmptyReadonlyArray<In>) => Effect.Effect<S, E, R>) => Sink<S, In, never, E, R>;
/**
 * Folds input elements into state until the specified maximum number of
 * elements has been consumed or the upstream stream ends.
 *
 * **Details**
 *
 * If the sink stops in the middle of a pulled array, the remaining elements
 * from that array are returned as leftovers.
 *
 * @category folding
 * @since 2.0.0
 */
export declare const foldUntil: <S, In, E = never, R = never>(s: LazyArg<S>, max: number, f: (s: S, input: In) => Effect.Effect<S, E, R>) => Sink<S, In, In, E, R>;
/**
 * A sink that returns whether all elements satisfy the specified predicate.
 *
 * **When to use**
 *
 * Use to reduce a stream to a boolean that is true only when every input
 * satisfies a pure predicate.
 *
 * @see {@link some} for the dual any-match check
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const every: <In>(predicate: Predicate<In>) => Sink<boolean, In, In>;
/**
 * A sink that returns whether an element satisfies the specified predicate.
 *
 * **When to use**
 *
 * Use to reduce a stream to a boolean that is true when any input satisfies a
 * pure predicate.
 *
 * @see {@link every} for the all-match check
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const some: <In>(predicate: Predicate<In>) => Sink<boolean, In, In>;
/**
 * Transforms this sink's result.
 *
 * **When to use**
 *
 * Use to compute a new result from the original sink result while preserving
 * the sink's input consumption behavior.
 *
 * **Details**
 *
 * The transformed sink preserves the original sink's input type, leftovers,
 * errors, and requirements.
 *
 * @see {@link mapEffect} for effectful result transformations
 * @see {@link as} for replacing the result with a constant value
 * @see {@link mapEnd} for transforming both the result and leftovers
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const map: {
    /**
     * Transforms this sink's result.
     *
     * **When to use**
     *
     * Use to compute a new result from the original sink result while preserving
     * the sink's input consumption behavior.
     *
     * **Details**
     *
     * The transformed sink preserves the original sink's input type, leftovers,
     * errors, and requirements.
     *
     * @see {@link mapEffect} for effectful result transformations
     * @see {@link as} for replacing the result with a constant value
     * @see {@link mapEnd} for transforming both the result and leftovers
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, A2>(f: (a: A) => A2): <In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L, E, R>;
    /**
     * Transforms this sink's result.
     *
     * **When to use**
     *
     * Use to compute a new result from the original sink result while preserving
     * the sink's input consumption behavior.
     *
     * **Details**
     *
     * The transformed sink preserves the original sink's input type, leftovers,
     * errors, and requirements.
     *
     * @see {@link mapEffect} for effectful result transformations
     * @see {@link as} for replacing the result with a constant value
     * @see {@link mapEnd} for transforming both the result and leftovers
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, A2>(self: Sink<A, In, L, E, R>, f: (a: A) => A2): Sink<A2, In, L, E, R>;
};
/**
 * Sets the sink's result to a constant value.
 *
 * **When to use**
 *
 * Use to keep a sink's input consumption, errors, requirements, and leftovers
 * while replacing only its result with a known value.
 *
 * @see {@link map} for computing the replacement from the original result
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const as: {
    /**
     * Sets the sink's result to a constant value.
     *
     * **When to use**
     *
     * Use to keep a sink's input consumption, errors, requirements, and leftovers
     * while replacing only its result with a known value.
     *
     * @see {@link map} for computing the replacement from the original result
     *
     * @category mapping
     * @since 2.0.0
     */
    <A2>(a2: A2): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L, E, R>;
    /**
     * Sets the sink's result to a constant value.
     *
     * **When to use**
     *
     * Use to keep a sink's input consumption, errors, requirements, and leftovers
     * while replacing only its result with a known value.
     *
     * @see {@link map} for computing the replacement from the original result
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, A2>(self: Sink<A, In, L, E, R>, a2: A2): Sink<A2, In, L, E, R>;
};
/**
 * Transforms this sink's input elements.
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const mapInput: {
    /**
     * Transforms this sink's input elements.
     *
     * @category mapping
     * @since 2.0.0
     */
    <In0, In>(f: (input: In0) => In): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E, R>;
    /**
     * Transforms this sink's input elements.
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, In0>(self: Sink<A, In, L, E, R>, f: (input: In0) => In): Sink<A, In0, L, E, R>;
};
/**
 * Transforms this sink's input elements effectfully.
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const mapInputEffect: {
    /**
     * Transforms this sink's input elements effectfully.
     *
     * @category mapping
     * @since 2.0.0
     */
    <In0, In, E2, R2>(f: (input: In0) => Effect.Effect<In, E2, R2>): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E2 | E, R2 | R>;
    /**
     * Transforms this sink's input elements effectfully.
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, In0, E2, R2>(self: Sink<A, In, L, E, R>, f: (input: In0) => Effect.Effect<In, E2, R2>): Sink<A, In0, L, E | E2, R | R2>;
};
/**
 * Transforms each non-empty array of upstream input before it is fed to this
 * sink.
 *
 * @category mapping
 * @since 4.0.0
 */
export declare const mapInputArray: {
    /**
     * Transforms each non-empty array of upstream input before it is fed to this
     * sink.
     *
     * @category mapping
     * @since 4.0.0
     */
    <In0, In>(f: (input: Arr.NonEmptyReadonlyArray<In0>) => Arr.NonEmptyReadonlyArray<In>): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E, R>;
    /**
     * Transforms each non-empty array of upstream input before it is fed to this
     * sink.
     *
     * @category mapping
     * @since 4.0.0
     */
    <A, In, L, E, R, In0>(self: Sink<A, In, L, E, R>, f: (input: Arr.NonEmptyReadonlyArray<In0>) => Arr.NonEmptyReadonlyArray<In>): Sink<A, In0, L, E, R>;
};
/**
 * Transforms each non-empty array of upstream input effectfully before it is
 * fed to this sink.
 *
 * @category mapping
 * @since 4.0.0
 */
export declare const mapInputArrayEffect: {
    /**
     * Transforms each non-empty array of upstream input effectfully before it is
     * fed to this sink.
     *
     * @category mapping
     * @since 4.0.0
     */
    <In0, In, E2, R2>(f: (input: Arr.NonEmptyReadonlyArray<In0>) => Effect.Effect<Arr.NonEmptyReadonlyArray<In>, E2, R2>): <A, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In0, L, E2 | E, R2 | R>;
    /**
     * Transforms each non-empty array of upstream input effectfully before it is
     * fed to this sink.
     *
     * @category mapping
     * @since 4.0.0
     */
    <A, In, L, E, R, In0, E2, R2>(self: Sink<A, In, L, E, R>, f: (input: Arr.NonEmptyReadonlyArray<In0>) => Effect.Effect<Arr.NonEmptyReadonlyArray<In>, E2, R2>): Sink<A, In0, L, E | E2, R | R2>;
};
/**
 * Transforms the full `End` produced by this sink.
 *
 * **Details**
 *
 * This can change both the result value and the optional leftovers.
 *
 * @category mapping
 * @since 4.0.0
 */
export declare const mapEnd: {
    /**
     * Transforms the full `End` produced by this sink.
     *
     * **Details**
     *
     * This can change both the result value and the optional leftovers.
     *
     * @category mapping
     * @since 4.0.0
     */
    <A, L, A2, L2 = never>(f: (a: End<A, L>) => End<A2, L2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E, R>;
    /**
     * Transforms the full `End` produced by this sink.
     *
     * **Details**
     *
     * This can change both the result value and the optional leftovers.
     *
     * @category mapping
     * @since 4.0.0
     */
    <A, In, L, E, R, A2, L2 = never>(self: Sink<A, In, L, E, R>, f: (a: End<A, L>) => End<A2, L2>): Sink<A2, In, L2, E, R>;
};
/**
 * Transforms the full `End` produced by this sink effectfully.
 *
 * **Details**
 *
 * This can change both the result value and the optional leftovers, and the
 * transformation can fail or require services.
 *
 * @category mapping
 * @since 4.0.0
 */
export declare const mapEffectEnd: {
    /**
     * Transforms the full `End` produced by this sink effectfully.
     *
     * **Details**
     *
     * This can change both the result value and the optional leftovers, and the
     * transformation can fail or require services.
     *
     * @category mapping
     * @since 4.0.0
     */
    <A, L, A2, E2, R2, L2 = never>(f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L2, E2 | E, R2 | R>;
    /**
     * Transforms the full `End` produced by this sink effectfully.
     *
     * **Details**
     *
     * This can change both the result value and the optional leftovers, and the
     * transformation can fail or require services.
     *
     * @category mapping
     * @since 4.0.0
     */
    <A, In, L, E, R, A2, E2, R2, L2 = never>(self: Sink<A, In, L, E, R>, f: (end: End<A, L>) => Effect.Effect<End<A2, L2>, E2, R2>): Sink<A2, In, L2, E | E2, R | R2>;
};
/**
 * Transforms this sink's result effectfully.
 *
 * **When to use**
 *
 * Use when transforming a sink result itself is effectful, can fail, or needs
 * services.
 *
 * **Details**
 *
 * The transformed sink preserves the original sink's input consumption and
 * leftovers while adding the errors and requirements of the transformation.
 *
 * @see {@link map} for pure result transformations
 * @see {@link mapEffectEnd} for effectfully transforming both the result and leftovers
 * @see {@link flatMap} for continuing with another sink based on the result
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const mapEffect: {
    /**
     * Transforms this sink's result effectfully.
     *
     * **When to use**
     *
     * Use when transforming a sink result itself is effectful, can fail, or needs
     * services.
     *
     * **Details**
     *
     * The transformed sink preserves the original sink's input consumption and
     * leftovers while adding the errors and requirements of the transformation.
     *
     * @see {@link map} for pure result transformations
     * @see {@link mapEffectEnd} for effectfully transforming both the result and leftovers
     * @see {@link flatMap} for continuing with another sink based on the result
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, A2, E2, R2>(f: (a: A) => Effect.Effect<A2, E2, R2>): <In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A2, In, L, E2 | E, R2 | R>;
    /**
     * Transforms this sink's result effectfully.
     *
     * **When to use**
     *
     * Use when transforming a sink result itself is effectful, can fail, or needs
     * services.
     *
     * **Details**
     *
     * The transformed sink preserves the original sink's input consumption and
     * leftovers while adding the errors and requirements of the transformation.
     *
     * @see {@link map} for pure result transformations
     * @see {@link mapEffectEnd} for effectfully transforming both the result and leftovers
     * @see {@link flatMap} for continuing with another sink based on the result
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, A2, E2, R2>(self: Sink<A, In, L, E, R>, f: (a: A) => Effect.Effect<A2, E2, R2>): Sink<A2, In, L, E | E2, R | R2>;
};
/**
 * Transforms the errors emitted by this sink using `f`.
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const mapError: {
    /**
     * Transforms the errors emitted by this sink using `f`.
     *
     * @category mapping
     * @since 2.0.0
     */
    <E, E2>(f: (error: E) => E2): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E2, R>;
    /**
     * Transforms the errors emitted by this sink using `f`.
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, E2>(self: Sink<A, In, L, E, R>, f: (error: E) => E2): Sink<A, In, L, E2, R>;
};
/**
 * Transforms the leftovers emitted by this sink using `f`.
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const mapLeftover: {
    /**
     * Transforms the leftovers emitted by this sink using `f`.
     *
     * @category mapping
     * @since 2.0.0
     */
    <L, L2>(f: (leftover: L) => L2): <A, In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L2, E, R>;
    /**
     * Transforms the leftovers emitted by this sink using `f`.
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, L2>(self: Sink<A, In, L, E, R>, f: (leftover: L) => L2): Sink<A, In, L2, E, R>;
};
/**
 * Collects up to `n` input elements into an array.
 *
 * **Details**
 *
 * If `n` is less than or equal to zero, the sink completes with an empty array.
 * If more elements are pulled than needed, the remaining elements from the same
 * array are returned as leftovers.
 *
 * @category collecting
 * @since 2.0.0
 */
export declare const take: <In>(n: number) => Sink<Array<In>, In, In>;
/**
 * Runs this sink until it yields a result, then uses that result to create
 * another sink from the provided function which will continue to run until it
 * yields a result.
 *
 * **When to use**
 *
 * Use to compose sinks when the next sink depends on the result produced by the
 * previous sink.
 *
 * **Details**
 *
 * Leftovers from the first sink are fed to the sink returned by `f` before more
 * upstream input is pulled.
 *
 * @see {@link map} for transforming the result without switching sinks
 * @see {@link mapEffect} for effectfully transforming the result without switching sinks
 *
 * @category sequencing
 * @since 2.0.0
 */
export declare const flatMap: {
    /**
     * Runs this sink until it yields a result, then uses that result to create
     * another sink from the provided function which will continue to run until it
     * yields a result.
     *
     * **When to use**
     *
     * Use to compose sinks when the next sink depends on the result produced by the
     * previous sink.
     *
     * **Details**
     *
     * Leftovers from the first sink are fed to the sink returned by `f` before more
     * upstream input is pulled.
     *
     * @see {@link map} for transforming the result without switching sinks
     * @see {@link mapEffect} for effectfully transforming the result without switching sinks
     *
     * @category sequencing
     * @since 2.0.0
     */
    <A, A1, L, In1 extends L, L1, E1, R1>(f: (a: A) => Sink<A1, In1, L1, E1, R1>): <In, E, R>(self: Sink<A, In, L, E, R>) => Sink<A1, In & In1, L1 | L, E1 | E, R1 | R>;
    /**
     * Runs this sink until it yields a result, then uses that result to create
     * another sink from the provided function which will continue to run until it
     * yields a result.
     *
     * **When to use**
     *
     * Use to compose sinks when the next sink depends on the result produced by the
     * previous sink.
     *
     * **Details**
     *
     * Leftovers from the first sink are fed to the sink returned by `f` before more
     * upstream input is pulled.
     *
     * @see {@link map} for transforming the result without switching sinks
     * @see {@link mapEffect} for effectfully transforming the result without switching sinks
     *
     * @category sequencing
     * @since 2.0.0
     */
    <A, In, L, E, R, A1, In1 extends L, L1, E1, R1>(self: Sink<A, In, L, E, R>, f: (a: A) => Sink<A1, In1, L1, E1, R1>): Sink<A1, In & In1, L | L1, E | E1, R | R1>;
};
/**
 * A sink that reduces input elements from the provided `initial` state with
 * `f` while the specified `predicate` returns `true`.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduceWhile: <S, In>(initial: LazyArg<S>, predicate: Predicate<S>, f: (s: S, input: In) => S) => Sink<S, In, In>;
/**
 * A sink that effectfully reduces input elements from the provided `initial`
 * state with `f` while the specified `predicate` returns `true`.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduceWhileEffect: <S, In, E, R>(initial: LazyArg<S>, predicate: Predicate<S>, f: (s: S, input: In) => Effect.Effect<S, E, R>) => Sink<S, In, In, E, R>;
/**
 * A sink that reduces non-empty input arrays from the provided `initial` state
 * with `f` while the specified `predicate` returns `true`.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduceWhileArray: <S, In>(initial: LazyArg<S>, contFn: Predicate<S>, f: (s: S, input: NonEmptyReadonlyArray<In>) => S) => Sink<S, In>;
/**
 * A sink that effectfully reduces non-empty input arrays from the provided
 * `initial` state with `f` while the specified `predicate` returns `true`.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduceWhileArrayEffect: <S, In, E, R>(initial: LazyArg<S>, predicate: Predicate<S>, f: (s: S, input: NonEmptyReadonlyArray<In>) => Effect.Effect<S, E, R>) => Sink<S, In, never, E, R>;
/**
 * A sink that reduces its inputs using the provided function `f` starting from
 * the provided `initial` state.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduce: <S, In>(initial: LazyArg<S>, f: (s: S, input: In) => S) => Sink<S, In>;
/**
 * A sink that reduces its inputs using the provided function `f` starting from
 * the specified `initial` state.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduceArray: <S, In>(initial: LazyArg<S>, f: (s: S, input: NonEmptyReadonlyArray<In>) => S) => Sink<S, In>;
/**
 * A sink that reduces its inputs using the provided effectful function `f`
 * starting from the specified `initial` state.
 *
 * @category reducing
 * @since 4.0.0
 */
export declare const reduceEffect: <S, In, E, R>(initial: LazyArg<S>, f: (s: S, input: In) => Effect.Effect<S, E, R>) => Sink<S, In, never, E, R>;
/**
 * Creates a sink containing the first value.
 *
 * **Details**
 *
 * Returns `Option.some(first)` for non-empty input, or `Option.none` when the
 * upstream ends without input. The first element is consumed; later elements
 * from the same pulled array are emitted as leftovers.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const head: <In>() => Sink<Option.Option<In>, In, In>;
/**
 * Creates a sink containing the last value.
 *
 * **When to use**
 *
 * Use when consuming all upstream input and only the final element is needed.
 *
 * **Details**
 *
 * Returns `Option.some(last)` with the final input value, or `Option.none` when
 * the upstream ends without input.
 *
 * **Gotchas**
 *
 * This sink produces a result only when the upstream ends, so it does not
 * complete for a stream that does not end.
 *
 * @see {@link head} for taking the first input value instead
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const last: <In>() => Sink<Option.Option<In>, In>;
/**
 * Creates a sink containing the first value matched by a synchronous predicate.
 *
 * **When to use**
 *
 * Use to scan stream input until the first matching element is found and return
 * that element as an `Option`.
 *
 * **Details**
 *
 * Returns `Option.none` if the upstream stream ends before a match is found.
 * Refinement predicates narrow the returned value type. The matching input is
 * consumed; any later elements from the same pulled array are returned as
 * leftovers.
 *
 * @see {@link findEffect} for an effectful predicate that can fail or require services
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const find: {
    /**
     * Creates a sink containing the first value matched by a synchronous predicate.
     *
     * **When to use**
     *
     * Use to scan stream input until the first matching element is found and return
     * that element as an `Option`.
     *
     * **Details**
     *
     * Returns `Option.none` if the upstream stream ends before a match is found.
     * Refinement predicates narrow the returned value type. The matching input is
     * consumed; any later elements from the same pulled array are returned as
     * leftovers.
     *
     * @see {@link findEffect} for an effectful predicate that can fail or require services
     *
     * @category constructors
     * @since 4.0.0
     */
    <In, Out extends In>(refinement: Refinement<In, Out>): Sink<Option.Option<Out>, In, In>;
    /**
     * Creates a sink containing the first value matched by a synchronous predicate.
     *
     * **When to use**
     *
     * Use to scan stream input until the first matching element is found and return
     * that element as an `Option`.
     *
     * **Details**
     *
     * Returns `Option.none` if the upstream stream ends before a match is found.
     * Refinement predicates narrow the returned value type. The matching input is
     * consumed; any later elements from the same pulled array are returned as
     * leftovers.
     *
     * @see {@link findEffect} for an effectful predicate that can fail or require services
     *
     * @category constructors
     * @since 4.0.0
     */
    <In>(predicate: Predicate<In>): Sink<Option.Option<In>, In, In>;
};
/**
 * Creates a sink containing the first value matched by an effectful predicate.
 *
 * **When to use**
 *
 * Use when deciding whether an input matches requires an effect, can fail, or
 * needs services.
 *
 * **Details**
 *
 * Returns `Option.some` with the first input whose predicate result is `true`,
 * or `Option.none` if the upstream stream ends first. If the predicate effect
 * fails, the sink fails with the same error.
 *
 * @see {@link find} for the synchronous predicate variant
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const findEffect: <In, E, R>(predicate: (input: In) => Effect.Effect<boolean, E, R>) => Sink<Option.Option<In>, In, In, E, R>;
/**
 * Creates a sink which sums up its inputs.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const sum: Sink<number, number>;
/**
 * A sink that counts the number of elements fed to it.
 *
 * **When to use**
 *
 * Use to consume input and return only the number of elements received.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const count: Sink<number, unknown>;
/**
 * Accumulates incoming elements into an array.
 *
 * **When to use**
 *
 * Use to collect all upstream input elements into a single array when you need
 * a sink result containing the complete input.
 *
 * @see {@link take} for collecting only a fixed number of input elements
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const collect: <In>() => Sink<Array<In>, In>;
/**
 * Collects the longest input prefix whose elements satisfy the predicate or
 * refinement.
 *
 * **Details**
 *
 * The first failing input is consumed and excluded from the result. Any later
 * elements from the same pulled array are returned as leftovers.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const takeWhile: {
    /**
     * Collects the longest input prefix whose elements satisfy the predicate or
     * refinement.
     *
     * **Details**
     *
     * The first failing input is consumed and excluded from the result. Any later
     * elements from the same pulled array are returned as leftovers.
     *
     * @category constructors
     * @since 4.0.0
     */
    <In, Out extends In>(refinement: Refinement<In, Out>): Sink<Array<Out>, In, In>;
    /**
     * Collects the longest input prefix whose elements satisfy the predicate or
     * refinement.
     *
     * **Details**
     *
     * The first failing input is consumed and excluded from the result. Any later
     * elements from the same pulled array are returned as leftovers.
     *
     * @category constructors
     * @since 4.0.0
     */
    <In>(predicate: Predicate<In>): Sink<Array<In>, In, In>;
};
/**
 * Applies a `Filter` to input elements while it succeeds, collecting each
 * successful output.
 *
 * **Details**
 *
 * The first input for which the filter fails is consumed and excluded from the
 * result. Any later elements from the same pulled array are returned as
 * leftovers.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const takeWhileFilter: <In, Out, X>(filter: Filter.Filter<In, Out, X>) => Sink<Array<Out>, In, In>;
/**
 * Collects input elements effectfully while the predicate succeeds.
 *
 * **Details**
 *
 * The first input for which the predicate returns `false` is consumed and
 * excluded from the result. Any later elements from the same pulled array are
 * returned as leftovers.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const takeWhileEffect: {
    /**
     * Collects input elements effectfully while the predicate succeeds.
     *
     * **Details**
     *
     * The first input for which the predicate returns `false` is consumed and
     * excluded from the result. Any later elements from the same pulled array are
     * returned as leftovers.
     *
     * @category constructors
     * @since 4.0.0
     */
    <In, E, R>(predicate: (input: In) => Effect.Effect<boolean, E, R>): Sink<Array<In>, In, In, E, R>;
};
/**
 * Applies a `FilterEffect` to input elements effectfully while it succeeds,
 * collecting each successful output.
 *
 * **Details**
 *
 * The first input for which the filter fails is consumed and excluded from the
 * result. Any later elements from the same pulled array are returned as
 * leftovers.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const takeWhileFilterEffect: <In, Out, X, E, R>(filter: Filter.FilterEffect<In, Out, X, E, R>) => Sink<Array<Out>, In, In, E, R>;
/**
 * Collects input elements until the predicate returns `true`, including the
 * matching element in the result.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const takeUntil: <In>(predicate: Predicate<In>) => Sink<Array<In>, In, In>;
/**
 * Collects input elements effectfully until the predicate returns `true`,
 * including the matching element in the result.
 *
 * **Details**
 *
 * If the predicate effect fails, the sink fails with the same error.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const takeUntilEffect: <In, E, R>(predicate: (input: In) => Effect.Effect<boolean, E, R>) => Sink<Array<In>, In, In, E, R>;
/**
 * A sink that executes the provided effectful function for every item fed
 * to it.
 *
 * **Example** (Running effects for each item)
 *
 * ```ts
 * import { Console, Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that logs each item
 * const sink = Sink.forEach((item: number) => Console.log(`Processing: ${item}`))
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program)
 * // Output:
 * // Processing: 1
 * // Processing: 2
 * // Processing: 3
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const forEach: <In, X, E, R>(f: (input: In) => Effect.Effect<X, E, R>) => Sink<void, In, never, E, R>;
/**
 * A sink that executes the provided effectful function for every Chunk fed
 * to it.
 *
 * **Example** (Running effects for each chunk)
 *
 * ```ts
 * import { Console, Effect, Sink, Stream } from "effect"
 *
 * // Create a sink that processes chunks
 * const sink = Sink.forEachArray((chunk: ReadonlyArray<number>) =>
 *   Console.log(
 *     `Processing chunk of ${chunk.length} items: [${chunk.join(", ")}]`
 *   )
 * )
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3, 4, 5)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program)
 * // Output: Processing chunk of 5 items: [1, 2, 3, 4, 5]
 * ```
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const forEachArray: <In, X, E, R>(f: (input: NonEmptyReadonlyArray<In>) => Effect.Effect<X, E, R>) => Sink<void, In, never, E, R>;
/**
 * Runs an effectful function for each input element while it returns `true`.
 *
 * **Details**
 *
 * The sink stops consuming input when the function returns `false` or when the
 * upstream stream ends, and completes with `void`.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const forEachWhile: <In, E, R>(f: (input: In) => Effect.Effect<boolean, E, R>) => Sink<void, In, never, E, R>;
/**
 * Runs an effectful function for each non-empty input array while it returns
 * `true`.
 *
 * **Details**
 *
 * The sink stops consuming input when the function returns `false` or when the
 * upstream stream ends, and completes with `void`.
 *
 * @category constructors
 * @since 4.0.0
 */
export declare const forEachWhileArray: <In, E, R>(f: (input: NonEmptyReadonlyArray<In>) => Effect.Effect<boolean, E, R>) => Sink<void, In, never, E, R>;
/**
 * Creates a sink produced from a scoped effect.
 *
 * **Example** (Unwrapping a sink effect)
 *
 * ```ts
 * import { Console, Effect, Sink, Stream } from "effect"
 *
 * // Create a sink from an effect that produces a sink
 * const sinkEffect = Effect.succeed(
 *   Sink.forEach((item: number) => Console.log(`Item: ${item}`))
 * )
 * const sink = Sink.unwrap(sinkEffect)
 *
 * // Use it with a stream
 * const stream = Stream.make(1, 2, 3)
 * const program = Stream.run(stream, sink)
 *
 * Effect.runPromise(program)
 * // Output:
 * // Item: 1
 * // Item: 2
 * // Item: 3
 * ```
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const unwrap: <A, In, L, E, R, R2>(effect: Effect.Effect<Sink<A, In, L, E, R2>, E, R>) => Sink<A, In, L, E, Exclude<R, Scope.Scope> | R2>;
/**
 * Runs a summary effect when the sink starts and again when it completes.
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const summarized: {
    /**
     * Runs a summary effect when the sink starts and again when it completes.
     *
     * @category mapping
     * @since 2.0.0
     */
    <A2, E2, R2, A3>(summary: Effect.Effect<A2, E2, R2>, f: (start: A2, end: A2) => A3): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<[A, A3], In, L, E2 | E, R2 | R>;
    /**
     * Runs a summary effect when the sink starts and again when it completes.
     *
     * @category mapping
     * @since 2.0.0
     */
    <A, In, L, E, R, A2, E2, R2, A3>(self: Sink<A, In, L, E, R>, summary: Effect.Effect<A2, E2, R2>, f: (start: A2, end: A2) => A3): Sink<[A, A3], In, L, E | E2, R | R2>;
};
/**
 * Returns the sink that executes this one and times its execution.
 *
 * @category mapping
 * @since 2.0.0
 */
export declare const withDuration: <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<[A, Duration.Duration], In, L, E, R>;
/**
 * A sink that drains all input and returns the elapsed duration.
 *
 * @category constructors
 * @since 2.0.0
 */
export declare const timed: Sink<Duration.Duration, unknown>;
/**
 * Provides a `Context` to this sink.
 *
 * **Details**
 *
 * Services contained in the provided context are removed from the sink's
 * service requirements.
 *
 * @category services
 * @since 2.0.0
 */
export declare const provideContext: {
    /**
     * Provides a `Context` to this sink.
     *
     * **Details**
     *
     * Services contained in the provided context are removed from the sink's
     * service requirements.
     *
     * @category services
     * @since 2.0.0
     */
    <Provided>(context: Context.Context<Provided>): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E, Exclude<R, Provided>>;
    /**
     * Provides a `Context` to this sink.
     *
     * **Details**
     *
     * Services contained in the provided context are removed from the sink's
     * service requirements.
     *
     * @category services
     * @since 2.0.0
     */
    <A, In, L, E, R, Provided>(self: Sink<A, In, L, E, R>, context: Context.Context<Provided>): Sink<A, In, L, E, Exclude<R, Provided>>;
};
/**
 * Provides a single service implementation to this sink.
 *
 * **Details**
 *
 * The service identified by `key` is removed from the sink's service
 * requirements.
 *
 * @category services
 * @since 4.0.0
 */
export declare const provideService: {
    /**
     * Provides a single service implementation to this sink.
     *
     * **Details**
     *
     * The service identified by `key` is removed from the sink's service
     * requirements.
     *
     * @category services
     * @since 4.0.0
     */
    <I, S>(key: Context.Key<I, S>, value: Types.NoInfer<S>): <A, In, L, E, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E, Exclude<R, I>>;
    /**
     * Provides a single service implementation to this sink.
     *
     * **Details**
     *
     * The service identified by `key` is removed from the sink's service
     * requirements.
     *
     * @category services
     * @since 4.0.0
     */
    <A, In, L, E, R, I, S>(self: Sink<A, In, L, E, R>, key: Context.Key<I, S>, value: Types.NoInfer<S>): Sink<A, In, L, E, Exclude<R, I>>;
};
/**
 * Runs a fallback sink if this sink fails with a typed error.
 *
 * **Details**
 *
 * The fallback is built from the error and continues consuming from the same
 * upstream stream. If the upstream stream had already ended, the fallback sees
 * the upstream end instead.
 *
 * @category error handling
 * @since 2.0.0
 */
export declare const orElse: {
    /**
     * Runs a fallback sink if this sink fails with a typed error.
     *
     * **Details**
     *
     * The fallback is built from the error and continues consuming from the same
     * upstream stream. If the upstream stream had already ended, the fallback sees
     * the upstream end instead.
     *
     * @category error handling
     * @since 2.0.0
     */
    <E, A2, In2, L2, E2, R2>(f: (error: Types.NoInfer<E>) => Sink<A2, In2, L2, E2, R2>): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A2 | A, In & In2, L2 | L, E2 | E, R2 | R>;
    /**
     * Runs a fallback sink if this sink fails with a typed error.
     *
     * **Details**
     *
     * The fallback is built from the error and continues consuming from the same
     * upstream stream. If the upstream stream had already ended, the fallback sees
     * the upstream end instead.
     *
     * @category error handling
     * @since 2.0.0
     */
    <A, In, L, E, R, A2, In2, L2, E2, R2>(self: Sink<A, In, L, E, R>, f: (error: E) => Sink<A2, In2, L2, E2, R2>): Sink<A | A2, In & In2, L | L2, E | E2, R | R2>;
};
/**
 * Handles failures from this sink by inspecting the full `Cause`.
 *
 * **When to use**
 *
 * Use to recover from a sink failure based on the full `Cause` instead of only
 * the typed error value.
 *
 * **Details**
 *
 * When this sink fails, the handler effect is run and its success value
 * becomes the sink result. If the handler fails, the returned sink fails with
 * that error.
 *
 * @see {@link catch_ catch} for recovering from typed errors only
 * @see {@link orElse} for recovering by switching to another sink
 *
 * @category error handling
 * @since 4.0.0
 */
export declare const catchCause: {
    /**
     * Handles failures from this sink by inspecting the full `Cause`.
     *
     * **When to use**
     *
     * Use to recover from a sink failure based on the full `Cause` instead of only
     * the typed error value.
     *
     * **Details**
     *
     * When this sink fails, the handler effect is run and its success value
     * becomes the sink result. If the handler fails, the returned sink fails with
     * that error.
     *
     * @see {@link catch_ catch} for recovering from typed errors only
     * @see {@link orElse} for recovering by switching to another sink
     *
     * @category error handling
     * @since 4.0.0
     */
    <E, A2, E2, R2>(f: (error: Cause.Cause<Types.NoInfer<E>>) => Effect.Effect<A2, E2, R2>): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A2 | A, In, L, E, R2 | R>;
    /**
     * Handles failures from this sink by inspecting the full `Cause`.
     *
     * **When to use**
     *
     * Use to recover from a sink failure based on the full `Cause` instead of only
     * the typed error value.
     *
     * **Details**
     *
     * When this sink fails, the handler effect is run and its success value
     * becomes the sink result. If the handler fails, the returned sink fails with
     * that error.
     *
     * @see {@link catch_ catch} for recovering from typed errors only
     * @see {@link orElse} for recovering by switching to another sink
     *
     * @category error handling
     * @since 4.0.0
     */
    <A, In, L, E, R, A2, E2, R2>(self: Sink<A, In, L, E, R>, f: (error: Cause.Cause<E>) => Effect.Effect<A2, E2, R2>): Sink<A | A2, In, L, E2, R | R2>;
};
declare const catch_: {
    <E, A2, E2, R2>(f: (error: Types.NoInfer<E>) => Effect.Effect<A2, E2, R2>): <A, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A2 | A, In, L, E, R2 | R>;
    <A, In, L, E, R, A2, E2, R2>(self: Sink<A, In, L, E, R>, f: (error: E) => Effect.Effect<A2, E2, R2>): Sink<A | A2, In, L, E2, R | R2>;
};
export { 
/**
 * Handles typed errors from this sink with an effectful fallback value.
 *
 * **When to use**
 *
 * Use to recover from a typed sink failure by producing the replacement
 * result with an `Effect`.
 *
 * @see {@link catchCause} for recovering from the full failure cause
 * @see {@link orElse} for recovering by switching to another sink
 *
 * @category error handling
 * @since 4.0.0
 */
catch_ as catch };
/**
 * Runs an effect after this sink completes, fails, or is interrupted.
 *
 * **Details**
 *
 * The effect receives the sink's `Exit` for the result value. The original
 * sink result and leftovers are preserved unless the finalizer itself fails.
 *
 * @category Finalization
 * @since 4.0.0
 */
export declare const onExit: {
    /**
     * Runs an effect after this sink completes, fails, or is interrupted.
     *
     * **Details**
     *
     * The effect receives the sink's `Exit` for the result value. The original
     * sink result and leftovers are preserved unless the finalizer itself fails.
     *
     * @category Finalization
     * @since 4.0.0
     */
    <A, E, X, E2, R2>(f: (exit: Exit.Exit<A, E>) => Effect.Effect<X, E2, R2>): <In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E | E2, R2 | R>;
    /**
     * Runs an effect after this sink completes, fails, or is interrupted.
     *
     * **Details**
     *
     * The effect receives the sink's `Exit` for the result value. The original
     * sink result and leftovers are preserved unless the finalizer itself fails.
     *
     * @category Finalization
     * @since 4.0.0
     */
    <A, In, L, E, R, X, E2, R2>(self: Sink<A, In, L, E, R>, f: (exit: Exit.Exit<A, E>) => Effect.Effect<X, E2, R2>): Sink<A, In, L, E | E2, R | R2>;
};
/**
 * Runs a finalizer effect after this sink completes, fails, or is interrupted.
 *
 * **Details**
 *
 * The original sink result and leftovers are preserved unless the finalizer
 * itself fails.
 *
 * @category Finalization
 * @since 2.0.0
 */
export declare const ensuring: {
    /**
     * Runs a finalizer effect after this sink completes, fails, or is interrupted.
     *
     * **Details**
     *
     * The original sink result and leftovers are preserved unless the finalizer
     * itself fails.
     *
     * @category Finalization
     * @since 2.0.0
     */
    <X, E2, R2>(effect: Effect.Effect<X, E2, R2>): <A, E, In, L, R>(self: Sink<A, In, L, E, R>) => Sink<A, In, L, E | E2, R2 | R>;
    /**
     * Runs a finalizer effect after this sink completes, fails, or is interrupted.
     *
     * **Details**
     *
     * The original sink result and leftovers are preserved unless the finalizer
     * itself fails.
     *
     * @category Finalization
     * @since 2.0.0
     */
    <A, In, L, E, R, X, E2, R2>(self: Sink<A, In, L, E, R>, effect: Effect.Effect<X, E2, R2>): Sink<A, In, L, E | E2, R | R2>;
};
//# sourceMappingURL=Sink.d.ts.map