"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "migrateSettingsRuntime", {
    enumerable: true,
    get: function() {
        return migrateSettingsRuntime;
    }
});
const _serversettingsconstants = require("../constants/server-settings.constants");
const _uuid = require("uuid");
function migrateSettingsRuntime(knownSettings) {
    const entity = knownSettings;
    entity[_serversettingsconstants.wizardSettingKey] ??= (0, _serversettingsconstants.getDefaultWizardSettings)();
    entity[_serversettingsconstants.timeoutSettingKey] ??= (0, _serversettingsconstants.getDefaultTimeout)();
    if (entity[_serversettingsconstants.timeoutSettingKey]) {
        const defaultTimeoutSettings = (0, _serversettingsconstants.getDefaultTimeout)();
        entity[_serversettingsconstants.timeoutSettingKey] = {
            apiTimeout: entity[_serversettingsconstants.timeoutSettingKey].apiTimeout ?? defaultTimeoutSettings.apiTimeout,
            apiUploadTimeout: entity[_serversettingsconstants.timeoutSettingKey].apiUploadTimeout ?? defaultTimeoutSettings.apiUploadTimeout
        };
    }
    entity[_serversettingsconstants.serverSettingsKey] ??= (0, _serversettingsconstants.getDefaultServerSettings)();
    entity[_serversettingsconstants.frontendSettingKey] ??= (0, _serversettingsconstants.getDefaultFrontendSettings)();
    entity[_serversettingsconstants.credentialSettingsKey] ??= {
        ...(0, _serversettingsconstants.getDefaultCredentialSettings)(),
        jwtSecret: (0, _uuid.v4)()
    };
    if (entity[_serversettingsconstants.frontendSettingKey]) {
        const defaultFrontendSettings = (0, _serversettingsconstants.getDefaultFrontendSettings)();
        entity[_serversettingsconstants.frontendSettingKey] = {
            gridCols: entity[_serversettingsconstants.frontendSettingKey].gridCols ?? defaultFrontendSettings.gridCols,
            gridRows: entity[_serversettingsconstants.frontendSettingKey].gridRows ?? defaultFrontendSettings.gridRows,
            largeTiles: entity[_serversettingsconstants.frontendSettingKey].largeTiles ?? defaultFrontendSettings.largeTiles,
            tilePreferCancelOverQuickStop: entity[_serversettingsconstants.frontendSettingKey].tilePreferCancelOverQuickStop ?? defaultFrontendSettings.tilePreferCancelOverQuickStop,
            gridNameSortDirection: entity[_serversettingsconstants.frontendSettingKey].gridNameSortDirection ?? defaultFrontendSettings.gridNameSortDirection
        };
    }
    if (entity[_serversettingsconstants.serverSettingsKey]) {
        const defaultServerSettings = (0, _serversettingsconstants.getDefaultServerSettings)();
        entity[_serversettingsconstants.serverSettingsKey] = {
            loginRequired: entity[_serversettingsconstants.serverSettingsKey].loginRequired ?? defaultServerSettings.loginRequired,
            registration: entity[_serversettingsconstants.serverSettingsKey].registration ?? defaultServerSettings.registration,
            experimentalMoonrakerSupport: entity[_serversettingsconstants.serverSettingsKey].experimentalMoonrakerSupport ?? defaultServerSettings.experimentalMoonrakerSupport,
            experimentalPrusaLinkSupport: entity[_serversettingsconstants.serverSettingsKey].experimentalPrusaLinkSupport ?? defaultServerSettings.experimentalPrusaLinkSupport,
            experimentalBambuSupport: entity[_serversettingsconstants.serverSettingsKey].experimentalBambuSupport ?? defaultServerSettings.experimentalBambuSupport,
            sentryDiagnosticsEnabled: entity[_serversettingsconstants.serverSettingsKey].sentryDiagnosticsEnabled ?? defaultServerSettings.sentryDiagnosticsEnabled
        };
    }
    return entity;
}

//# sourceMappingURL=runtime-settings.migration.js.map