import { accountLockFields } from './baseFields/accountLock.js';
import { apiKeyFields } from './baseFields/apiKey.js';
import { baseAuthFields } from './baseFields/auth.js';
import { emailFieldConfig } from './baseFields/email.js';
import { usernameFieldConfig } from './baseFields/username.js';
import { verificationFields } from './baseFields/verification.js';
export const getBaseAuthFields = (authConfig)=>{
    const authFields = [];
    if (authConfig.useAPIKey) {
        authFields.push(...apiKeyFields);
    }
    if (!authConfig.disableLocalStrategy) {
        const emailField = {
            ...emailFieldConfig
        };
        let usernameField;
        if (authConfig.loginWithUsername) {
            usernameField = {
                ...usernameFieldConfig
            };
            if (typeof authConfig.loginWithUsername === 'object') {
                if (authConfig.loginWithUsername.requireEmail === false) {
                    emailField.required = false;
                }
                if (authConfig.loginWithUsername.requireUsername === false) {
                    usernameField.required = false;
                }
                if (authConfig.loginWithUsername.allowEmailLogin === false) {
                    emailField.unique = false;
                }
            }
        }
        authFields.push(emailField);
        if (usernameField) {
            authFields.push(usernameField);
        }
        authFields.push(...baseAuthFields);
        if (authConfig.verify) {
            authFields.push(...verificationFields);
        }
        if (authConfig?.maxLoginAttempts && authConfig.maxLoginAttempts > 0) {
            authFields.push(...accountLockFields);
        }
    }
    return authFields;
};

//# sourceMappingURL=getAuthFields.js.map