import { I as InferErr, a as InferOk, R as ResultAsync } from './async-Ci6WSL5-.js';
import { R as Result } from './types-BQ9vv0nD.js';

/**
 * @onrails/result/extra — tagged-error helpers.
 */

/** Extract error type from a {@link Result} — alias of {@link InferErr} */
type ErrOf<R> = InferErr<R>;
/** Extract success type from a {@link Result} — alias of {@link InferOk} */
type OkOf<R> = InferOk<R>;
/** Union of error types from a tuple/readonly array of results */
type UnionErrors<R extends readonly Result<unknown, unknown>[]> = {
    [K in keyof R]: ErrOf<R[K]>;
}[number];
/** Manual union when TS fails to infer multi-step errors (neverthrow #603) */
type AccumulateErrors<Errors extends readonly unknown[]> = Errors[number];
/**
 * Declare the error union for a pipeline when inference only picks the first step.
 *
 * @example
 * ```ts
 * const errors = declareErrors<ParseError | NetworkError>();
 * const step = errors.annotate(parseThing());
 * ```
 */
declare const declareErrors: <E>() => {
    annotate: <T>(result: Result<T, unknown>) => Result<T, E>;
    annotateAsync: <T>(result: ResultAsync<T, unknown>) => ResultAsync<T, E>;
};
/** Narrow an error by `kind` when using discriminated unions */
declare const hasKind: <E extends {
    kind: string;
}, K extends E["kind"]>(error: E, kind: K) => error is Extract<E, {
    kind: K;
}>;
/** Map only errors matching `kind`, leave others unchanged */
declare const mapErrKind: <E extends {
    kind: string;
}, K extends E["kind"], F>(kind: K, fn: (error: Extract<E, {
    kind: K;
}>) => F) => <T>(result: Result<T, E>) => Result<T, E | F>;
/** True when no result is Err */
declare const allOk: <T, E>(results: readonly Result<T, E>[]) => boolean;

export { type AccumulateErrors, type ErrOf, type OkOf, type UnionErrors, allOk, declareErrors, hasKind, mapErrKind };
