"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "configureContainer", {
    enumerable: true,
    get: function() {
        return configureContainer;
    }
});
const _octokit = require("octokit");
const _awilix = require("awilix");
const _toadscheduler = require("toad-scheduler");
const _containertokens = require("./container.tokens");
const _printerservice = require("./services/orm/printer.service");
const _printermaintenancelogservice = require("./services/orm/printer-maintenance-log.service");
const _settingsstore = require("./state/settings.store");
const _serverreleaseservice = require("./services/core/server-release.service");
const _taskmanagerservice = require("./services/task-manager.service");
const _githubservice = require("./services/core/github.service");
const _printerwebsockettask = require("./tasks/printer-websocket.task");
const _socketiotask = require("./tasks/socketio.task");
const _socketfactory = require("./services/socket.factory");
const _eventemitter = require("./handlers/event-emitter");
const _serverconstants = require("./server.constants");
const _softwareupdatetask = require("./tasks/software-update.task");
const _loggerfactory = require("./handlers/logger-factory");
const _multerservice = require("./services/core/multer.service");
const _fileuploadtrackercache = require("./state/file-upload-tracker.cache");
const _serverhost = require("./server.host");
const _boottask = require("./tasks/boot.task");
const _userservice = require("./services/orm/user.service");
const _roleservice = require("./services/orm/role.service");
const _permissionservice = require("./services/orm/permission.service");
const _authorizationconstants = require("./constants/authorization.constants");
const _printerwebsocketrestoretask = require("./tasks/printer-websocket-restore.task");
const _configservice = require("./services/core/config.service");
const _socketiogateway = require("./state/socket-io.gateway");
const _clientbundleservice = require("./services/core/client-bundle.service");
const _floorstore = require("./state/floor.store");
const _yamlservice = require("./services/core/yaml.service");
const _monsterpiservice = require("./services/core/monsterpi.service");
const _batchcallservice = require("./services/core/batch-call.service");
const _clientbundletask = require("./tasks/client-bundle.task");
const _octoprintwebsocketadapter = require("./services/octoprint/octoprint-websocket.adapter");
const _printercache = require("./state/printer.cache");
const _printersocketstore = require("./state/printer-socket.store");
const _testprintersocketstore = require("./state/test-printer-socket.store");
const _printereventscache = require("./state/printer-events.cache");
const _logsmanagerservice = require("./services/core/logs-manager.service");
const _camerastreamservice = require("./services/orm/camera-stream.service");
const _jwtservice = require("./services/authentication/jwt.service");
const _authservice = require("./services/authentication/auth.service");
const _pluginthrottling = require("@octokit/plugin-throttling");
const _refreshtokenservice = require("./services/orm/refresh-token.service");
const _settingsservice = require("./services/orm/settings.service");
const _floorservice = require("./services/orm/floor.service");
const _floorpositionservice = require("./services/orm/floor-position.service");
const _exceptionfilter = require("./middleware/exception.filter");
const _typeormservice = require("./services/typeorm/typeorm.service");
const _userroleservice = require("./services/orm/user-role.service");
const _printertagservice = require("./services/orm/printer-tag.service");
const _moonrakerclient = require("./services/moonraker/moonraker.client");
const _moonrakerwebsocketadapter = require("./services/moonraker/moonraker-websocket.adapter");
const _octoprintapi = require("./services/octoprint.api");
const _octoprintclient = require("./services/octoprint/octoprint.client");
const _moonrakerapi = require("./services/moonraker.api");
const _printerapifactory = require("./services/printer-api.factory");
const _printerthumbnailcache = require("./state/printer-thumbnail.cache");
const _httpclientfactory = require("./services/core/http-client.factory");
const _cradleservice = require("./services/core/cradle.service");
const _prusalinkapi = require("./services/prusa-link/prusa-link.api");
const _prusalinkhttppollingadapter = require("./services/prusa-link/prusa-link-http-polling.adapter");
const _bambuclient = require("./services/bambu/bambu.client");
const _bambumqttadapter = require("./services/bambu/bambu-mqtt.adapter");
const _bambuftpadapter = require("./services/bambu/bambu-ftp.adapter");
const _bambuapi = require("./services/bambu.api");
const _printqueueservice = require("./services/print-queue.service");
const _filestorageservice = require("./services/file-storage.service");
const _printjobservice = require("./services/orm/print-job.service");
const _fileanalysisservice = require("./services/file-analysis.service");
const _printjobanalysistask = require("./tasks/print-job-analysis.task");
const _printfiledownloaderservice = require("./services/print-file-downloader.service");
function configureContainer() {
    const container = (0, _awilix.createContainer)({
        injectionMode: _awilix.InjectionMode.CLASSIC
    });
    const di = _containertokens.DITokens;
    container.register({
        [di.appDefaultRole]: (0, _awilix.asValue)(_authorizationconstants.ROLES.GUEST),
        [di.appDefaultRoleNoLogin]: (0, _awilix.asValue)(_authorizationconstants.ROLES.ADMIN),
        [di.serverVersion]: (0, _awilix.asFunction)(()=>{
            return process.env[_serverconstants.AppConstants.VERSION_KEY];
        }),
        [di.cradleService]: (0, _awilix.asClass)(_cradleservice.CradleService).inject((container)=>({
                container
            })),
        [di.socketFactory]: (0, _awilix.asClass)(_socketfactory.SocketFactory).transient(),
        [di.typeormService]: (0, _awilix.asClass)(_typeormservice.TypeormService).singleton(),
        [di.settingsService]: (0, _awilix.asClass)(_settingsservice.SettingsService),
        [di.floorService]: (0, _awilix.asClass)(_floorservice.FloorService).singleton(),
        [di.floorPositionService]: (0, _awilix.asClass)(_floorpositionservice.FloorPositionService).singleton(),
        [di.cameraStreamService]: (0, _awilix.asClass)(_camerastreamservice.CameraStreamService).singleton(),
        [di.printerService]: (0, _awilix.asClass)(_printerservice.PrinterService),
        [di.printerMaintenanceLogService]: (0, _awilix.asClass)(_printermaintenancelogservice.PrinterMaintenanceLogService),
        [di.printerTagService]: (0, _awilix.asClass)(_printertagservice.PrinterTagService),
        [di.refreshTokenService]: (0, _awilix.asClass)(_refreshtokenservice.RefreshTokenService).singleton(),
        [di.userService]: (0, _awilix.asClass)(_userservice.UserService).singleton(),
        [di.userRoleService]: (0, _awilix.asClass)(_userroleservice.UserRoleService).singleton(),
        [di.roleService]: (0, _awilix.asClass)(_roleservice.RoleService).singleton(),
        [di.permissionService]: (0, _awilix.asClass)(_permissionservice.PermissionService).singleton(),
        [di.serverHost]: (0, _awilix.asClass)(_serverhost.ServerHost).singleton(),
        [di.exceptionFilter]: (0, _awilix.asClass)(_exceptionfilter.ExceptionFilter).singleton(),
        [di.settingsStore]: (0, _awilix.asClass)(_settingsstore.SettingsStore).singleton(),
        [di.configService]: (0, _awilix.asClass)(_configservice.ConfigService),
        [di.authService]: (0, _awilix.asClass)(_authservice.AuthService).singleton(),
        [di.jwtService]: (0, _awilix.asClass)(_jwtservice.JwtService).singleton(),
        [di.loggerFactory]: (0, _awilix.asFunction)(_loggerfactory.LoggerFactory).transient(),
        [di.taskManagerService]: (0, _awilix.asClass)(_taskmanagerservice.TaskManagerService).singleton(),
        [di.toadScheduler]: (0, _awilix.asClass)(_toadscheduler.ToadScheduler).singleton(),
        [di.eventEmitter2]: (0, _awilix.asFunction)(_eventemitter.configureEventEmitter).singleton(),
        [di.serverReleaseService]: (0, _awilix.asClass)(_serverreleaseservice.ServerReleaseService).singleton(),
        [di.monsterPiService]: (0, _awilix.asClass)(_monsterpiservice.MonsterPiService).singleton(),
        [di.githubService]: (0, _awilix.asClass)(_githubservice.GithubService),
        [di.octokitService]: (0, _awilix.asFunction)((configService)=>{
            const CustomOctoKit = _octokit.Octokit.plugin(_pluginthrottling.throttling);
            return new CustomOctoKit({
                auth: configService.get(_serverconstants.AppConstants.GITHUB_PAT),
                throttle: {
                    onRateLimit: (_retryAfter, options, _octokit, _retryCount)=>{
                        const logger = (0, _loggerfactory.LoggerFactory)()("OctoKitThrottle");
                        logger.warn(`Request quota exhausted for request ${options.method} ${options.url}`);
                    },
                    onSecondaryRateLimit: (_retryAfter, options, _octokit)=>{
                        const logger = (0, _loggerfactory.LoggerFactory)()("OctoKitThrottle");
                        logger.warn(`SecondaryRateLimit detected for request ${options.method} ${options.url}`);
                    }
                }
            });
        }),
        [di.clientBundleService]: (0, _awilix.asClass)(_clientbundleservice.ClientBundleService),
        [di.logDumpService]: (0, _awilix.asClass)(_logsmanagerservice.LogDumpService),
        [di.httpClientFactory]: (0, _awilix.asClass)(_httpclientfactory.HttpClientFactory),
        [di.socketIoGateway]: (0, _awilix.asClass)(_socketiogateway.SocketIoGateway).singleton(),
        [di.multerService]: (0, _awilix.asClass)(_multerservice.MulterService).singleton(),
        [di.yamlService]: (0, _awilix.asClass)(_yamlservice.YamlService),
        [di.printerLogin]: (0, _awilix.asValue)(null),
        [di.printerApiFactory]: (0, _awilix.asClass)(_printerapifactory.PrinterApiFactory).transient(),
        [di.prusaLinkApi]: (0, _awilix.asClass)(_prusalinkapi.PrusaLinkApi).transient(),
        [di.prusaLinkPollingAdapter]: (0, _awilix.asClass)(_prusalinkhttppollingadapter.PrusaLinkHttpPollingAdapter).transient(),
        [di.octoprintApi]: (0, _awilix.asClass)(_octoprintapi.OctoprintApi).transient(),
        [di.octoprintClient]: (0, _awilix.asClass)(_octoprintclient.OctoprintClient).singleton(),
        [di.octoPrintSockIoAdapter]: (0, _awilix.asClass)(_octoprintwebsocketadapter.OctoprintWebsocketAdapter).transient(),
        [di.moonrakerApi]: (0, _awilix.asClass)(_moonrakerapi.MoonrakerApi).transient(),
        [di.moonrakerClient]: (0, _awilix.asClass)(_moonrakerclient.MoonrakerClient).singleton(),
        [di.moonrakerWebsocketAdapter]: (0, _awilix.asClass)(_moonrakerwebsocketadapter.MoonrakerWebsocketAdapter).transient(),
        [di.bambuApi]: (0, _awilix.asClass)(_bambuapi.BambuApi).transient(),
        [di.bambuClient]: (0, _awilix.asClass)(_bambuclient.BambuClient).transient(),
        [di.bambuFtpAdapter]: (0, _awilix.asClass)(_bambuftpadapter.BambuFtpAdapter).transient(),
        [di.bambuMqttAdapter]: (0, _awilix.asClass)(_bambumqttadapter.BambuMqttAdapter).transient(),
        [di.batchCallService]: (0, _awilix.asClass)(_batchcallservice.BatchCallService).singleton(),
        [di.floorStore]: (0, _awilix.asClass)(_floorstore.FloorStore).singleton(),
        [di.printerThumbnailCache]: (0, _awilix.asClass)(_printerthumbnailcache.PrinterThumbnailCache).singleton(),
        [di.fileUploadTrackerCache]: (0, _awilix.asClass)(_fileuploadtrackercache.FileUploadTrackerCache).singleton(),
        [di.printerCache]: (0, _awilix.asClass)(_printercache.PrinterCache).singleton(),
        [di.printerEventsCache]: (0, _awilix.asClass)(_printereventscache.PrinterEventsCache).singleton(),
        [di.printerSocketStore]: (0, _awilix.asClass)(_printersocketstore.PrinterSocketStore).singleton(),
        [di.testPrinterSocketStore]: (0, _awilix.asClass)(_testprintersocketstore.TestPrinterSocketStore).singleton(),
        [di.printJobService]: (0, _awilix.asClass)(_printjobservice.PrintJobService).singleton(),
        [di.printQueueService]: (0, _awilix.asClass)(_printqueueservice.PrintQueueService).singleton(),
        [di.fileStorageService]: (0, _awilix.asClass)(_filestorageservice.FileStorageService).singleton(),
        [di.fileAnalysisService]: (0, _awilix.asClass)(_fileanalysisservice.FileAnalysisService).singleton(),
        [di.printFileDownloaderService]: (0, _awilix.asClass)(_printfiledownloaderservice.PrintFileDownloaderService).singleton(),
        [di.bootTask]: (0, _awilix.asClass)(_boottask.BootTask),
        [di.softwareUpdateTask]: (0, _awilix.asClass)(_softwareupdatetask.SoftwareUpdateTask),
        [di.socketIoTask]: (0, _awilix.asClass)(_socketiotask.SocketIoTask).singleton(),
        [di.clientDistDownloadTask]: (0, _awilix.asClass)(_clientbundletask.ClientDistDownloadTask).singleton(),
        [di.printerWebsocketTask]: (0, _awilix.asClass)(_printerwebsockettask.PrinterWebsocketTask).singleton(),
        [di.printerWebsocketRestoreTask]: (0, _awilix.asClass)(_printerwebsocketrestoretask.PrinterWebsocketRestoreTask).singleton(),
        [di.printJobAnalysisTask]: (0, _awilix.asClass)(_printjobanalysistask.PrintJobAnalysisTask).singleton()
    });
    return container;
}

//# sourceMappingURL=container.js.map