'use strict';

var echarts = require('./core/echarts.js');
var Component$1 = require('./view/Component.js');
var Chart = require('./view/Chart.js');
var Component = require('./model/Component.js');
var Series = require('./model/Series.js');
var util = require('../../../../zrender@6.0.0/node_modules/zrender/lib/core/util.js');
var impl = require('./core/impl.js');
var zrender = require('../../../../zrender@6.0.0/node_modules/zrender/lib/zrender.js');
var customSeriesRegister = require('./chart/custom/customSeriesRegister.js');

var extensions = [];
var extensionRegisters = {
  registerPreprocessor: echarts.registerPreprocessor,
  registerProcessor: echarts.registerProcessor,
  registerPostInit: echarts.registerPostInit,
  registerPostUpdate: echarts.registerPostUpdate,
  registerUpdateLifecycle: echarts.registerUpdateLifecycle,
  registerAction: echarts.registerAction,
  registerCoordinateSystem: echarts.registerCoordinateSystem,
  registerLayout: echarts.registerLayout,
  registerVisual: echarts.registerVisual,
  registerTransform: echarts.registerTransform,
  registerLoading: echarts.registerLoading,
  registerMap: echarts.registerMap,
  registerImpl: impl.registerImpl,
  PRIORITY: echarts.PRIORITY,
  ComponentModel: Component.default,
  ComponentView: Component$1.default,
  SeriesModel: Series.default,
  ChartView: Chart.default,
  // TODO Use ComponentModel and SeriesModel instead of Constructor
  registerComponentModel: function (ComponentModelClass) {
    Component.default.registerClass(ComponentModelClass);
  },
  registerComponentView: function (ComponentViewClass) {
    Component$1.default.registerClass(ComponentViewClass);
  },
  registerSeriesModel: function (SeriesModelClass) {
    Series.default.registerClass(SeriesModelClass);
  },
  registerChartView: function (ChartViewClass) {
    Chart.default.registerClass(ChartViewClass);
  },
  registerCustomSeries: function (seriesType, renderItem) {
    customSeriesRegister.registerCustomSeries(seriesType, renderItem);
  },
  registerSubTypeDefaulter: function (componentType, defaulter) {
    Component.default.registerSubTypeDefaulter(componentType, defaulter);
  },
  registerPainter: function (painterType, PainterCtor) {
    zrender.registerPainter(painterType, PainterCtor);
  }
};
function use(ext) {
  if (util.isArray(ext)) {
    // use([ChartLine, ChartBar]);
    util.each(ext, function (singleExt) {
      use(singleExt);
    });
    return;
  }
  if (util.indexOf(extensions, ext) >= 0) {
    return;
  }
  extensions.push(ext);
  if (util.isFunction(ext)) {
    ext = {
      install: ext
    };
  }
  ext.install(extensionRegisters);
}

exports.use = use;
