import { loadConfig as loadConfigCap, writeConfig as writeConfigCap } from '@capacitor/cli/dist/config';
export async function loadConfig() {
    const config = await loadConfigCap();
    return {
        config: config.app.extConfig,
        path: config.app.extConfigFilePath,
    };
}
export async function writeConfig(key, config, raw = false) {
    const oldConfig = await loadConfigCap();
    let { extConfig } = oldConfig.app;
    if (extConfig) {
        if (!extConfig.plugins) {
            extConfig.plugins = {
                extConfig: {},
                [key]: {},
            };
        }
        if (!extConfig.plugins[key])
            extConfig.plugins[key] = {};
        if (!raw)
            extConfig.plugins[key] = config.config.plugins?.[key];
        else
            extConfig = config.config;
        writeConfigCap(extConfig, oldConfig.app.extConfigFilePath);
    }
}
export async function writeConfigUpdater(config, raw = false) {
    await writeConfig('CapacitorUpdater', config, raw);
}
//# sourceMappingURL=index.js.map