"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
var _exportNames = {};
exports["default"] = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _lowcodeEngine = require("@alilc/lowcode-engine");
Object.keys(_lowcodeEngine).forEach(function (key) {
  if (key === "default" || key === "__esModule") return;
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
  if (key in exports && exports[key] === _lowcodeEngine[key]) return;
  exports[key] = _lowcodeEngine[key];
});
var _lowcodeDatasourceFetchHandler = require("@alilc/lowcode-datasource-fetch-handler");
var _plugins = _interopRequireDefault(require("./plugins"));
var _setters = _interopRequireDefault(require("./setters"));
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: (0, _lowcodeDatasourceFetchHandler.createFetchHandler)()
  }
};
var _default = /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(cb, customPlugins, container, config) {
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return (0, _plugins["default"])();
          case 2:
            (0, _setters["default"])();

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