"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupUninit = setupUninit;
exports.setupOnUninit = setupOnUninit;
/**
 * Composes multiple uninit handlers into a single `ExpectedExports.uninit`-compatible function.
 * Handlers are executed sequentially in the order provided.
 *
 * @param uninits - One or more uninit handlers to compose
 */
function setupUninit(...uninits) {
    return async (opts) => {
        for (const uninit of uninits) {
            if ('uninit' in uninit)
                await uninit.uninit(opts.effects, opts.target);
            else
                await uninit(opts.effects, opts.target);
        }
    };
}
/** Normalizes a {@link UninitScriptOrFn} into a {@link UninitScript} object. */
function setupOnUninit(onUninit) {
    return 'uninit' in onUninit
        ? onUninit
        : {
            uninit: async (effects, target) => {
                await onUninit(effects, target);
            },
        };
}
//# sourceMappingURL=setupUninit.js.map