import { ConfigurationSchema, readConfObject, } from '@jbrowse/core/configuration';
import RpcManager from '@jbrowse/core/rpc/RpcManager';
import { getParent, types } from '@jbrowse/mobx-state-tree';
import { FormatAboutConfigSchemaFactory, FormatDetailsConfigSchemaFactory, HierarchicalConfigSchemaFactory, } from '@jbrowse/product-core';
export default function createConfigModel(pluginManager, assemblyConfigSchemasType) {
    return types
        .model('Configuration', {
        configuration: ConfigurationSchema('Root', {
            rpc: RpcManager.configSchema,
            highResolutionScaling: {
                type: 'number',
                defaultValue: 2,
            },
            formatDetails: FormatDetailsConfigSchemaFactory(),
            formatAbout: FormatAboutConfigSchemaFactory(),
            hierarchical: HierarchicalConfigSchemaFactory(),
            theme: { type: 'frozen', defaultValue: {} },
        }),
        assembly: assemblyConfigSchemasType,
        tracks: types.array(pluginManager.pluggableConfigSchemaType('track')),
        internetAccounts: types.array(pluginManager.pluggableConfigSchemaType('internet account')),
        connections: types.array(pluginManager.pluggableConfigSchemaType('connection')),
        aggregateTextSearchAdapters: types.array(pluginManager.pluggableConfigSchemaType('text search adapter')),
        plugins: types.frozen(),
    })
        .views(self => ({
        get assemblies() {
            return [self.assembly];
        },
        get assemblyName() {
            return readConfObject(self.assembly, 'name');
        },
        get rpcManager() {
            return getParent(self).rpcManager;
        },
    }));
}
