import { createClientCollectionConfigs } from '../collections/config/client.js';
import { createClientGlobalConfigs } from '../globals/config/client.js';
import { deepCopyObjectSimple } from '../utilities/deepCopyObject.js';
export const serverOnlyAdminConfigProperties = [];
export const serverOnlyConfigProperties = [
    'endpoints',
    'db',
    'editor',
    'plugins',
    'sharp',
    'onInit',
    'secret',
    'hooks',
    'bin',
    'typescript',
    'cors',
    'csrf',
    'email',
    'custom',
    'graphQL',
    'jobs',
    'logger'
];
export const createClientConfig = ({ config, i18n })=>{
    // We can use deepCopySimple here, as the clientConfig should be JSON serializable anyways, since it will be sent from server => client
    const clientConfig = deepCopyObjectSimple(config);
    for (const key of serverOnlyConfigProperties){
        if (key in clientConfig) {
            delete clientConfig[key];
        }
    }
    if ('localization' in clientConfig && clientConfig.localization) {
        for (const locale of clientConfig.localization.locales){
            delete locale.toString;
        }
    }
    if (!clientConfig.admin) {
        clientConfig.admin = {};
    }
    clientConfig.admin.components = null;
    if ('livePreview' in clientConfig.admin && clientConfig.admin.livePreview && 'url' in clientConfig.admin.livePreview) {
        delete clientConfig.admin.livePreview.url;
    }
    clientConfig.collections = createClientCollectionConfigs({
        collections: config.collections,
        defaultIDType: config.db.defaultIDType,
        i18n
    });
    clientConfig.globals = createClientGlobalConfigs({
        defaultIDType: config.db.defaultIDType,
        globals: config.globals,
        i18n
    });
    return clientConfig;
};

//# sourceMappingURL=client.js.map