import { AINativeServerModule } from '@codeblitzjs/ide-sumi-core';
import { AINativeModule } from '@opensumi/ide-ai-native/lib/browser';
import { DesignModule } from '@opensumi/ide-design/lib/browser';
import { OpenedEditorModule } from '@opensumi/ide-opened-editor/lib/browser';
import { OutlineModule } from '@opensumi/ide-outline/lib/browser';
function removeModule(modules, module) {
    const index = modules.indexOf(module);
    if (index > -1) {
        modules.splice(index, 1);
    }
}
export function interceptAppOpts(opts, runtimeConfig) {
    var _a;
    const { modules } = opts;
    const newModules = [...modules];
    if ((_a = runtimeConfig.aiNative) === null || _a === void 0 ? void 0 : _a.enable) {
        if (modules.indexOf(AINativeModule) === -1) {
            newModules.push(AINativeModule);
            newModules.push(AINativeServerModule);
        }
    }
    if (opts.useLegacyDesign) {
        // remove design module
        removeModule(newModules, DesignModule);
    }
    if (opts.useSimplifyExplorerPanel) {
        // remove outline module
        removeModule(newModules, OutlineModule);
        // remove opened editor module
        removeModule(newModules, OpenedEditorModule);
    }
    opts.modules = newModules;
    return opts;
}
//# sourceMappingURL=opts.js.map