// transports/middleware/compose.ts — Left-fold middleware composition (SPEC-740)
/**
 * Composes multiple middlewares into a single middleware via left-fold.
 * compose(a, b, c)(handler) = a(b(c(handler)))
 *
 * This means `a` is the outermost wrapper (first to execute, last to return).
 */
export function composeMiddleware(...middlewares) {
    return (handler) => {
        // Right-to-left fold: innermost first, outermost last
        return middlewares.reduceRight((wrapped, mw) => mw(wrapped), handler);
    };
}
//# sourceMappingURL=compose.js.map