// Copyright (c) Trung Le
// Distributed under the terms of the Modified BSD License.
import { IThemeManager } from '@jupyterlab/apputils';
import { IJupyterWidgetRegistry } from '@jupyter-widgets/base';
import * as widgetExports from './widget';
import * as rawWidgetExports from './rawWidget';
import { BaseEChartsWidgetModel } from './baseWidgetModel';
import { BaseEChartsWidgetView } from './baseWidgetView';
import * as subWidgetExport from './option';
import { MODULE_NAME, MODULE_VERSION } from './version';
import { IUpdateManagerToken } from './types';
const EXTENSION_ID = 'ipecharts:plugin';
/**
 * The example plugin.
 */
export const widgetPlugin = {
    id: EXTENSION_ID,
    description: 'A JupyterLab extension.',
    requires: [IJupyterWidgetRegistry, IUpdateManagerToken],
    optional: [IThemeManager],
    activate: activateWidgetExtension,
    autoStart: true
};
/**
 * Activate the widget extension.
 */
function activateWidgetExtension(app, registry, updateManager, themeManager) {
    const allExports = {
        ...widgetExports,
        ...subWidgetExport,
        ...rawWidgetExports
    };
    BaseEChartsWidgetModel.updateManager = updateManager;
    for (const Class of Object.values(allExports)) {
        if (Object.getOwnPropertyDescriptor(Class, 'updateManager')) {
            Class.updateManager = updateManager;
        }
    }
    if (themeManager) {
        BaseEChartsWidgetView.themeManager = themeManager;
    }
    registry.registerWidget({
        name: MODULE_NAME,
        version: MODULE_VERSION,
        exports: allExports
    });
    console.log('ipecharts extension activated');
}
