var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var BlocksQueueModule_1;
import { Module } from '@nestjs/common';
import { BlockchainProviderService } from '../blockchain-provider/blockchain-provider.service';
import { BlocksQueueService } from './blocks-queue.service';
import { BlocksQueueIteratorService } from './blocks-iterator/blocks-iterator.service';
import { BlocksQueueLoaderService } from './blocks-loader/blocks-loader.service';
import { MempoolLoaderService } from './mempool-loader.service';
let BlocksQueueModule = BlocksQueueModule_1 = class BlocksQueueModule {
    static async forRootAsync(config) {
        const { blocksCommandExecutor, mempoolCommandExecutor, mempoolLoaderStrategyName = 'subscribe-ws', tracesEnabled = false, verifyTrie = false, ...restConfig } = config;
        return {
            module: BlocksQueueModule_1,
            imports: [],
            providers: [
                {
                    provide: 'BlocksCommandExecutor',
                    useClass: blocksCommandExecutor,
                },
                {
                    provide: 'MempoolCommandExecutor',
                    useClass: mempoolCommandExecutor,
                },
                {
                    provide: BlocksQueueIteratorService,
                    useFactory: (executor, blockchainProvider) => new BlocksQueueIteratorService(executor, blockchainProvider, { ...restConfig }),
                    inject: ['BlocksCommandExecutor', BlockchainProviderService],
                },
                {
                    provide: MempoolLoaderService,
                    useFactory: (provider, executor) => new MempoolLoaderService(provider, executor, mempoolLoaderStrategyName),
                    inject: [BlockchainProviderService, 'MempoolCommandExecutor'],
                },
                {
                    provide: BlocksQueueLoaderService,
                    useFactory: (provider, mempoolService) => new BlocksQueueLoaderService(provider, mempoolService, { ...restConfig, tracesEnabled, verifyTrie }),
                    inject: [BlockchainProviderService, MempoolLoaderService],
                },
                {
                    provide: BlocksQueueService,
                    useFactory: (iterator, loader, mempoolService, blockchainProvider) => new BlocksQueueService(iterator, loader, mempoolService, blockchainProvider, {
                        ...restConfig,
                        tracesEnabled,
                        verifyTrie,
                    }),
                    inject: [
                        BlocksQueueIteratorService,
                        BlocksQueueLoaderService,
                        MempoolLoaderService,
                        BlockchainProviderService,
                    ],
                },
            ],
            exports: [BlocksQueueService, MempoolLoaderService],
        };
    }
};
BlocksQueueModule = BlocksQueueModule_1 = __decorate([
    Module({})
], BlocksQueueModule);
export { BlocksQueueModule };
