// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.
/**
 * @packageDocumentation
 * @module docprovider-extension
 */
import { URLExt } from '@jupyterlab/coreutils';
import { IDocumentProviderFactory, ProviderMock, WebSocketProvider } from '@jupyterlab/docprovider';
import { ServerConnection } from '@jupyterlab/services';
/**
 * The default document provider plugin
 */
const docProviderPlugin = {
    id: '@jupyterlab/docprovider-extension:plugin',
    provides: IDocumentProviderFactory,
    activate: (app) => {
        const server = ServerConnection.makeSettings();
        const url = URLExt.join(server.wsUrl, 'api/yjs');
        const factory = (options) => {
            return options.collaborative
                ? new WebSocketProvider(Object.assign(Object.assign({}, options), { url, user: app.serviceManager.user }))
                : new ProviderMock();
        };
        return factory;
    }
};
/**
 * Export the plugins as default.
 */
const plugins = [docProviderPlugin];
export default plugins;
//# sourceMappingURL=index.js.map