import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
import _regeneratorRuntime from "@babel/runtime/regenerator";
import { init, plugins } from '@alilc/lowcode-engine';
import { createFetchHandler } from '@alilc/lowcode-datasource-fetch-handler';
import registerDefaultPlugins from './plugins';
import registerDefaultSetters from './setters';
export * from '@alilc/lowcode-engine';
var defaultConfig = {
  // locale: 'zh-CN',
  enableCondition: true,
  enableCanvasLock: true,
  // 默认绑定变量
  supportVariableGlobally: true,
  // simulatorUrl 在当 engine-core.js 同一个父路径下时是不需要配置的！！！
  // 这里因为用的是 alifd cdn，在不同 npm 包，engine-core.js 和 react-simulator-renderer.js 是不同路径
  simulatorUrl: ['https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/css/react-simulator-renderer.css', 'https://alifd.alicdn.com/npm/@alilc/lowcode-react-simulator-renderer@latest/dist/js/react-simulator-renderer.js'],
  requestHandlersMap: {
    fetch: createFetchHandler()
  }
};
export default /*#__PURE__*/(function () {
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(cb, customPlugins, container, config) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return registerDefaultPlugins();
          case 2:
            registerDefaultSetters();

            // 处理外部传入初始化回调
            if (!(typeof cb === 'function')) {
              _context.next = 7;
              break;
            }
            cb.pluginName = 'editorInit';
            _context.next = 7;
            return plugins.register(cb);
          case 7:
            init(container, config || defaultConfig);
          case 8:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return function (_x, _x2, _x3, _x4) {
    return _ref.apply(this, arguments);
  };
})();