"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
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 __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FrontendService = void 0;
const backend_common_1 = require("@n8n/backend-common");
const config_1 = require("@n8n/config");
const constants_1 = require("@n8n/constants");
const di_1 = require("@n8n/di");
const fs_1 = require("fs");
const promises_1 = require("fs/promises");
const uniq_1 = __importDefault(require("lodash/uniq"));
const n8n_core_1 = require("n8n-core");
const path_1 = __importDefault(require("path"));
const config_2 = __importDefault(require("../config"));
const constants_2 = require("../constants");
const credential_types_1 = require("../credential-types");
const credentials_overwrites_1 = require("../credentials-overwrites");
const license_1 = require("../license");
const load_nodes_and_credentials_1 = require("../load-nodes-and-credentials");
const mfa_service_1 = require("../mfa/mfa.service");
const community_packages_config_1 = require("../modules/community-packages/community-packages.config");
const public_api_1 = require("../public-api");
const push_config_1 = require("../push/push.config");
const ownership_service_1 = require("../services/ownership.service");
const sso_helpers_1 = require("../sso.ee/sso-helpers");
const email_1 = require("../user-management/email");
const health_endpoint_util_1 = require("../utils/health-endpoint.util");
const workflow_history_helper_1 = require("../workflows/workflow-history/workflow-history-helper");
const ai_usage_service_1 = require("./ai-usage.service");
const url_service_1 = require("./url.service");
let FrontendService = class FrontendService {
    constructor(globalConfig, logger, loadNodesAndCredentials, credentialTypes, credentialsOverwrites, license, mailer, instanceSettings, urlService, securityConfig, pushConfig, binaryDataConfig, licenseState, moduleRegistry, mfaService, ownershipService, aiUsageService) {
        this.globalConfig = globalConfig;
        this.logger = logger;
        this.loadNodesAndCredentials = loadNodesAndCredentials;
        this.credentialTypes = credentialTypes;
        this.credentialsOverwrites = credentialsOverwrites;
        this.license = license;
        this.mailer = mailer;
        this.instanceSettings = instanceSettings;
        this.urlService = urlService;
        this.securityConfig = securityConfig;
        this.pushConfig = pushConfig;
        this.binaryDataConfig = binaryDataConfig;
        this.licenseState = licenseState;
        this.moduleRegistry = moduleRegistry;
        this.mfaService = mfaService;
        this.ownershipService = ownershipService;
        this.aiUsageService = aiUsageService;
        loadNodesAndCredentials.addPostProcessor(async () => await this.generateTypes());
        void this.generateTypes();
        if (di_1.Container.get(community_packages_config_1.CommunityPackagesConfig).enabled) {
            void Promise.resolve().then(() => __importStar(require('../modules/community-packages/community-packages.service'))).then(({ CommunityPackagesService }) => {
                this.communityPackagesService = di_1.Container.get(CommunityPackagesService);
            });
        }
    }
    collectEnvFeatureFlags() {
        const envFeatureFlags = {};
        for (const [key, value] of Object.entries(process.env)) {
            if (key.startsWith('N8N_ENV_FEAT_') && value !== undefined) {
                envFeatureFlags[key] = value;
            }
        }
        return envFeatureFlags;
    }
    async getShowSetupOnFirstLoad() {
        const previewMode = process.env.N8N_PREVIEW_MODE === 'true';
        const hasInstanceOwner = await this.ownershipService.hasInstanceOwner();
        return previewMode ? false : !hasInstanceOwner;
    }
    async initSettings() {
        const instanceBaseUrl = this.urlService.getInstanceBaseUrl();
        const restEndpoint = this.globalConfig.endpoints.rest;
        const telemetrySettings = {
            enabled: this.globalConfig.diagnostics.enabled,
        };
        if (telemetrySettings.enabled) {
            const conf = this.globalConfig.diagnostics.frontendConfig;
            const [key, url] = conf.split(';');
            const proxy = `${instanceBaseUrl}/${restEndpoint}/telemetry/proxy`;
            const sourceConfig = `${instanceBaseUrl}/${restEndpoint}/telemetry/rudderstack`;
            if (!key || !url) {
                this.logger.warn('Diagnostics frontend config is invalid');
                telemetrySettings.enabled = false;
            }
            telemetrySettings.config = { key, url, proxy, sourceConfig };
        }
        const previewMode = process.env.N8N_PREVIEW_MODE === 'true';
        this.settings = {
            settingsMode: 'authenticated',
            inE2ETests: constants_2.inE2ETests,
            isDocker: this.instanceSettings.isDocker,
            databaseType: this.globalConfig.database.type,
            previewMode,
            endpointForm: this.globalConfig.endpoints.form,
            endpointFormTest: this.globalConfig.endpoints.formTest,
            endpointFormWaiting: this.globalConfig.endpoints.formWaiting,
            endpointMcp: this.globalConfig.endpoints.mcp,
            endpointMcpTest: this.globalConfig.endpoints.mcpTest,
            endpointWebhook: this.globalConfig.endpoints.webhook,
            endpointWebhookTest: this.globalConfig.endpoints.webhookTest,
            endpointWebhookWaiting: this.globalConfig.endpoints.webhookWaiting,
            endpointHealth: (0, health_endpoint_util_1.resolveFrontendHealthEndpointPath)(this.globalConfig),
            saveDataErrorExecution: this.globalConfig.executions.saveDataOnError,
            saveDataSuccessExecution: this.globalConfig.executions.saveDataOnSuccess,
            saveManualExecutions: this.globalConfig.executions.saveDataManualExecutions,
            saveExecutionProgress: this.globalConfig.executions.saveExecutionProgress,
            executionTimeout: this.globalConfig.executions.timeout,
            maxExecutionTimeout: this.globalConfig.executions.maxTimeout,
            workflowCallerPolicyDefaultOption: this.globalConfig.workflows.callerPolicyDefaultOption,
            timezone: this.globalConfig.generic.timezone,
            urlBaseWebhook: this.urlService.getWebhookBaseUrl(),
            urlBaseEditor: instanceBaseUrl,
            binaryDataMode: this.binaryDataConfig.mode,
            nodeJsVersion: process.version.replace(/^v/, ''),
            nodeEnv: process.env.NODE_ENV,
            versionCli: constants_2.N8N_VERSION,
            concurrency: this.globalConfig.executions.concurrency.productionLimit,
            authCookie: {
                secure: this.globalConfig.auth.cookie.secure,
            },
            releaseChannel: this.globalConfig.generic.releaseChannel,
            oauthCallbackUrls: {
                oauth1: `${instanceBaseUrl}/${restEndpoint}/oauth1-credential/callback`,
                oauth2: `${instanceBaseUrl}/${restEndpoint}/oauth2-credential/callback`,
            },
            versionNotifications: {
                enabled: this.globalConfig.versionNotifications.enabled,
                endpoint: this.globalConfig.versionNotifications.endpoint,
                whatsNewEnabled: this.globalConfig.versionNotifications.whatsNewEnabled,
                whatsNewEndpoint: this.globalConfig.versionNotifications.whatsNewEndpoint,
                infoUrl: this.globalConfig.versionNotifications.infoUrl,
            },
            dynamicBanners: {
                endpoint: this.globalConfig.dynamicBanners.endpoint,
                enabled: this.globalConfig.dynamicBanners.enabled && this.globalConfig.diagnostics.enabled,
            },
            instanceId: this.instanceSettings.instanceId,
            telemetry: telemetrySettings,
            posthog: {
                enabled: this.globalConfig.diagnostics.enabled,
                apiHost: this.globalConfig.diagnostics.posthogConfig.apiHost,
                apiKey: this.globalConfig.diagnostics.posthogConfig.apiKey,
                autocapture: false,
                disableSessionRecording: this.globalConfig.deployment.type !== 'cloud',
                proxy: `${instanceBaseUrl}/${restEndpoint}/ph`,
                debug: this.globalConfig.logging.level === 'debug',
            },
            personalizationSurveyEnabled: this.globalConfig.personalization.enabled && this.globalConfig.diagnostics.enabled,
            defaultLocale: this.globalConfig.defaultLocale,
            userManagement: {
                quota: this.license.getUsersLimit(),
                showSetupOnFirstLoad: await this.getShowSetupOnFirstLoad(),
                smtpSetup: this.mailer.isEmailSetUp,
                authenticationMethod: (0, sso_helpers_1.getCurrentAuthenticationMethod)(),
            },
            sso: {
                saml: {
                    loginEnabled: false,
                    loginLabel: '',
                },
                ldap: {
                    loginEnabled: false,
                    loginLabel: '',
                },
                oidc: {
                    loginEnabled: false,
                    loginUrl: `${instanceBaseUrl}/${restEndpoint}/sso/oidc/login`,
                    callbackUrl: `${instanceBaseUrl}/${restEndpoint}/sso/oidc/callback`,
                },
            },
            dataTables: {
                maxSize: this.globalConfig.dataTable.maxSize,
            },
            publicApi: {
                enabled: (0, public_api_1.isApiEnabled)(),
                latestVersion: 1,
                path: this.globalConfig.publicApi.path,
                swaggerUi: {
                    enabled: !this.globalConfig.publicApi.swaggerUiDisabled,
                },
            },
            workflowTagsDisabled: this.globalConfig.tags.disabled,
            logLevel: this.globalConfig.logging.level,
            hiringBannerEnabled: this.globalConfig.hiringBanner.enabled,
            aiAssistant: {
                enabled: false,
                setup: false,
            },
            templates: {
                enabled: this.globalConfig.templates.enabled,
                host: this.globalConfig.templates.host,
            },
            executionMode: this.globalConfig.executions.mode,
            isMultiMain: this.instanceSettings.isMultiMain,
            pushBackend: this.pushConfig.backend,
            communityNodesEnabled: di_1.Container.get(community_packages_config_1.CommunityPackagesConfig).enabled,
            unverifiedCommunityNodesEnabled: di_1.Container.get(community_packages_config_1.CommunityPackagesConfig).unverifiedEnabled,
            deployment: {
                type: this.globalConfig.deployment.type,
            },
            allowedModules: {
                builtIn: process.env.NODE_FUNCTION_ALLOW_BUILTIN?.split(',') ?? undefined,
                external: process.env.NODE_FUNCTION_ALLOW_EXTERNAL?.split(',') ?? undefined,
            },
            enterprise: {
                sharing: false,
                ldap: false,
                saml: false,
                oidc: false,
                mfaEnforcement: false,
                logStreaming: false,
                advancedExecutionFilters: false,
                variables: false,
                sourceControl: false,
                auditLogs: false,
                externalSecrets: false,
                showNonProdBanner: false,
                debugInEditor: false,
                binaryDataS3: false,
                workerView: false,
                advancedPermissions: false,
                workflowDiffs: false,
                namedVersions: false,
                provisioning: false,
                projects: {
                    team: {
                        limit: 0,
                    },
                },
                customRoles: false,
                personalSpacePolicy: false,
                dataRedaction: false,
            },
            mfa: {
                enabled: false,
                enforced: false,
            },
            hideUsagePage: this.globalConfig.hideUsagePage,
            license: {
                consumerId: 'unknown',
                environment: this.globalConfig.license.tenantId === 1 ? 'production' : 'staging',
            },
            variables: {
                limit: 0,
            },
            banners: {
                dismissed: [],
            },
            askAi: {
                enabled: false,
            },
            aiBuilder: {
                enabled: false,
                setup: false,
            },
            aiCredits: {
                enabled: false,
                credits: 0,
                setup: false,
            },
            ai: {
                allowSendingParameterValues: true,
            },
            workflowHistory: {
                pruneTime: (0, workflow_history_helper_1.getWorkflowHistoryPruneTime)(),
                licensePruneTime: (0, workflow_history_helper_1.getWorkflowHistoryLicensePruneTime)(),
            },
            pruning: {
                isEnabled: this.globalConfig.executions.pruneData,
                maxAge: this.globalConfig.executions.pruneDataMaxAge,
                maxCount: this.globalConfig.executions.pruneDataMaxCount,
            },
            security: {
                blockFileAccessToN8nFiles: this.securityConfig.blockFileAccessToN8nFiles,
            },
            easyAIWorkflowOnboarded: false,
            folders: {
                enabled: false,
            },
            evaluation: {
                quota: this.licenseState.getMaxWorkflowsWithEvaluations(),
            },
            activeModules: this.moduleRegistry.getActiveModules(),
            canvasOnly: this.globalConfig.canvasOnly,
            envFeatureFlags: this.collectEnvFeatureFlags(),
        };
    }
    async generateTypes() {
        this.overwriteCredentialsProperties();
        const { credentials, nodes } = await this.loadNodesAndCredentials.collectTypes();
        const { staticCacheDir } = this.instanceSettings;
        await (0, promises_1.mkdir)(path_1.default.join(staticCacheDir, 'types'), { recursive: true });
        await this.writeStaticJSON('nodes', nodes);
        const nodeVersionIdentifiers = this.getNodeVersionIdentifiers(nodes);
        await this.writeStaticJSON('node-versions', nodeVersionIdentifiers);
        await this.writeStaticJSON('credentials', credentials);
    }
    async getSettings() {
        if (!this.settings) {
            await this.initSettings();
        }
        const restEndpoint = this.globalConfig.endpoints.rest;
        const instanceBaseUrl = this.urlService.getInstanceBaseUrl();
        this.settings.urlBaseWebhook = this.urlService.getWebhookBaseUrl();
        this.settings.urlBaseEditor = instanceBaseUrl;
        this.settings.oauthCallbackUrls = {
            oauth1: `${instanceBaseUrl}/${restEndpoint}/oauth1-credential/callback`,
            oauth2: `${instanceBaseUrl}/${restEndpoint}/oauth2-credential/callback`,
        };
        Object.assign(this.settings.userManagement, {
            quota: this.license.getUsersLimit(),
            authenticationMethod: (0, sso_helpers_1.getCurrentAuthenticationMethod)(),
            showSetupOnFirstLoad: await this.getShowSetupOnFirstLoad(),
        });
        let dismissedBanners = [];
        try {
            dismissedBanners = config_2.default.getEnv('ui.banners.dismissed') ?? [];
        }
        catch {
        }
        this.settings.banners.dismissed = dismissedBanners;
        try {
            this.settings.easyAIWorkflowOnboarded = config_2.default.getEnv('easyAIWorkflowOnboarded') ?? false;
        }
        catch {
            this.settings.easyAIWorkflowOnboarded = false;
        }
        try {
            this.settings.ai.allowSendingParameterValues = await this.aiUsageService.getAiUsageSettings();
        }
        catch {
            this.settings.ai.allowSendingParameterValues = true;
        }
        const isS3Selected = this.binaryDataConfig.mode === 's3';
        const isS3Available = this.binaryDataConfig.availableModes.includes('s3');
        const isS3Licensed = this.license.isBinaryDataS3Licensed();
        const isAiAssistantEnabled = this.license.isAiAssistantEnabled();
        const isAskAiEnabled = this.license.isAskAiEnabled();
        const isAiCreditsEnabled = this.license.isAiCreditsEnabled();
        const isAiBuilderEnabled = this.license.isLicensed(constants_1.LICENSE_FEATURES.AI_BUILDER);
        this.settings.license.planName = this.license.getPlanName();
        this.settings.license.consumerId = this.license.getConsumerId();
        Object.assign(this.settings.enterprise, {
            sharing: this.license.isSharingEnabled(),
            logStreaming: this.license.isLogStreamingEnabled(),
            ldap: this.license.isLdapEnabled(),
            saml: this.license.isSamlEnabled(),
            oidc: this.licenseState.isOidcLicensed(),
            mfaEnforcement: this.licenseState.isMFAEnforcementLicensed(),
            provisioning: false,
            advancedExecutionFilters: this.license.isAdvancedExecutionFiltersEnabled(),
            variables: this.license.isVariablesEnabled(),
            sourceControl: this.license.isSourceControlLicensed(),
            externalSecrets: this.license.isExternalSecretsEnabled(),
            showNonProdBanner: this.license.isLicensed(constants_1.LICENSE_FEATURES.SHOW_NON_PROD_BANNER),
            debugInEditor: this.license.isDebugInEditorLicensed(),
            binaryDataS3: isS3Available && isS3Selected && isS3Licensed,
            workerView: this.license.isWorkerViewLicensed(),
            advancedPermissions: this.license.isAdvancedPermissionsLicensed(),
            workflowDiffs: this.licenseState.isWorkflowDiffsLicensed(),
            namedVersions: this.license.isLicensed(constants_1.LICENSE_FEATURES.NAMED_VERSIONS),
            customRoles: this.licenseState.isCustomRolesLicensed(),
            personalSpacePolicy: this.licenseState.isPersonalSpacePolicyLicensed(),
            dataRedaction: this.licenseState.isDataRedactionLicensed(),
        });
        if (this.license.isLdapEnabled()) {
            Object.assign(this.settings.sso.ldap, {
                loginLabel: this.globalConfig.sso.ldap.loginLabel,
                loginEnabled: this.globalConfig.sso.ldap.loginEnabled,
            });
        }
        if (this.license.isSamlEnabled()) {
            Object.assign(this.settings.sso.saml, {
                loginLabel: (0, sso_helpers_1.getSamlLoginLabel)(),
                loginEnabled: this.globalConfig.sso.saml.loginEnabled,
            });
        }
        if (this.licenseState.isOidcLicensed()) {
            Object.assign(this.settings.sso.oidc, {
                loginEnabled: this.globalConfig.sso.oidc.loginEnabled,
            });
        }
        if (this.license.isVariablesEnabled()) {
            this.settings.variables.limit = this.license.getVariablesLimit();
        }
        if (this.communityPackagesService) {
            this.settings.missingPackages = this.communityPackagesService.hasMissingPackages;
        }
        if (isAiAssistantEnabled) {
            this.settings.aiAssistant.enabled = isAiAssistantEnabled;
            this.settings.aiAssistant.setup =
                !!this.globalConfig.aiAssistant.baseUrl || !!process.env.N8N_AI_ANTHROPIC_KEY;
        }
        if (isAskAiEnabled) {
            this.settings.askAi.enabled = isAskAiEnabled;
        }
        if (isAiCreditsEnabled) {
            this.settings.aiCredits.enabled = isAiCreditsEnabled;
            this.settings.aiCredits.credits = this.license.getAiCredits();
            this.settings.aiCredits.setup = !!this.globalConfig.aiAssistant.baseUrl;
        }
        const isAiGatewayEnabled = this.licenseState.isAiGatewayLicensed() && !!this.globalConfig.aiAssistant.baseUrl;
        if (isAiGatewayEnabled) {
            this.settings.aiGateway = {
                enabled: true,
                budget: this.license.getValue(constants_1.LICENSE_QUOTAS.AI_GATEWAY_BUDGET) ?? 0,
            };
        }
        if (isAiBuilderEnabled) {
            this.settings.aiBuilder.enabled = isAiBuilderEnabled;
            this.settings.aiBuilder.setup =
                !!this.globalConfig.aiAssistant.baseUrl || !!this.globalConfig.aiBuilder.apiKey;
        }
        this.settings.mfa.enabled = this.globalConfig.mfa.enabled;
        this.settings.mfa.enforced = await this.mfaService.isMFAEnforced();
        this.settings.executionMode = this.globalConfig.executions.mode;
        this.settings.binaryDataMode = this.binaryDataConfig.mode;
        this.settings.enterprise.projects.team.limit = this.license.getTeamProjectLimit();
        this.settings.folders.enabled = this.license.isFoldersEnabled();
        this.settings.evaluation.quota = this.licenseState.getMaxWorkflowsWithEvaluations();
        this.settings.envFeatureFlags = this.collectEnvFeatureFlags();
        return this.settings;
    }
    async getPublicSettings(includeMfaSettings) {
        const { defaultLocale, userManagement: { authenticationMethod, showSetupOnFirstLoad, smtpSetup }, sso: { saml: ssoSaml, ldap: ssoLdap, oidc: ssoOidc }, authCookie, previewMode, enterprise: { saml, ldap, oidc }, mfa, communityNodesEnabled, } = await this.getSettings();
        const publicSettings = {
            settingsMode: 'public',
            defaultLocale,
            userManagement: {
                authenticationMethod,
                showSetupOnFirstLoad,
                smtpSetup,
            },
            sso: {
                saml: {
                    loginEnabled: ssoSaml.loginEnabled,
                },
                ldap: ssoLdap,
                oidc: {
                    loginEnabled: ssoOidc.loginEnabled,
                    loginUrl: ssoOidc.loginUrl,
                },
            },
            authCookie,
            previewMode,
            enterprise: { saml, ldap, oidc },
            communityNodesEnabled,
        };
        if (includeMfaSettings) {
            publicSettings.mfa = mfa;
        }
        return publicSettings;
    }
    getModuleSettings() {
        return Object.fromEntries(this.moduleRegistry.settings);
    }
    getNodeVersionIdentifiers(nodes) {
        const identifiers = new Set();
        for (const node of nodes) {
            if (!node?.name || node.version === undefined)
                continue;
            const versions = Array.isArray(node.version) ? node.version : [node.version];
            for (const version of versions) {
                if (version === undefined)
                    continue;
                identifiers.add(`${node.name}@${String(version)}`);
            }
        }
        return Array.from(identifiers);
    }
    async writeStaticJSON(name, data) {
        const { staticCacheDir } = this.instanceSettings;
        const filePath = path_1.default.join(staticCacheDir, `types/${name}.json`);
        const stream = (0, fs_1.createWriteStream)(filePath, 'utf-8');
        return await new Promise((resolve, reject) => {
            stream.on('error', reject);
            stream.on('finish', resolve);
            stream.write('[\n');
            data.forEach((entry, index) => {
                stream.write(JSON.stringify(entry));
                if (index !== data.length - 1)
                    stream.write(',');
                stream.write('\n');
            });
            stream.write(']\n');
            stream.end();
        });
    }
    overwriteCredentialsProperties() {
        const { credentials } = this.loadNodesAndCredentials.types;
        const credentialsOverwrites = this.credentialsOverwrites.getAll();
        const { skipTypes } = this.globalConfig.credentials.overwrite;
        for (const credential of credentials) {
            delete credential.__overwrittenProperties;
            delete credential.__skipManagedCreation;
            const overwrittenProperties = [];
            this.credentialTypes
                .getParentTypes(credential.name)
                .reverse()
                .map((name) => credentialsOverwrites[name])
                .forEach((overwrite) => {
                if (overwrite)
                    overwrittenProperties.push(...Object.keys(overwrite));
            });
            if (credential.name in credentialsOverwrites) {
                overwrittenProperties.push(...Object.keys(credentialsOverwrites[credential.name]));
            }
            if (overwrittenProperties.length) {
                credential.__overwrittenProperties = (0, uniq_1.default)(overwrittenProperties);
            }
            if (skipTypes.includes(credential.name)) {
                credential.__skipManagedCreation = true;
            }
        }
    }
};
exports.FrontendService = FrontendService;
exports.FrontendService = FrontendService = __decorate([
    (0, di_1.Service)(),
    __metadata("design:paramtypes", [config_1.GlobalConfig,
        backend_common_1.Logger,
        load_nodes_and_credentials_1.LoadNodesAndCredentials,
        credential_types_1.CredentialTypes,
        credentials_overwrites_1.CredentialsOverwrites,
        license_1.License,
        email_1.UserManagementMailer,
        n8n_core_1.InstanceSettings,
        url_service_1.UrlService,
        config_1.SecurityConfig,
        push_config_1.PushConfig,
        n8n_core_1.BinaryDataConfig,
        backend_common_1.LicenseState,
        backend_common_1.ModuleRegistry,
        mfa_service_1.MfaService,
        ownership_service_1.OwnershipService,
        ai_usage_service_1.AiUsageService])
], FrontendService);
//# sourceMappingURL=frontend.service.js.map