"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.init = exports["default"] = void 0;

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));

var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));

var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));

var materialUICore = _interopRequireWildcard(require("@material-ui/core"));

var materialUIStyles = _interopRequireWildcard(require("@material-ui/styles"));

var xDatePickers = _interopRequireWildcard(require("@mui/x-date-pickers"));

var muiBase = _interopRequireWildcard(require("@mui/base"));

var muiMaterial = _interopRequireWildcard(require("@mui/material"));

var emotionCore = _interopRequireWildcard(require("@emotion/core"));

var emotionStyled = _interopRequireWildcard(require("@emotion/styled"));

var emotionReact = _interopRequireWildcard(require("@emotion/react"));

var react = _interopRequireWildcard(require("react"));

var reactDom = _interopRequireWildcard(require("react-dom"));

var reactIntl = _interopRequireWildcard(require("react-intl"));

var _dll = require("../dll");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var DLL = {};
var _default = DLL;
exports["default"] = _default;
var externals = {
  '@material-ui/core': materialUICore,
  '@material-ui/styles': materialUIStyles,
  react: react,
  'react-dom': reactDom,
  'react-intl': reactIntl,
  '@emotion/react': emotionReact,
  '@emotion/core': emotionCore,
  '@mui/x-date-pickers': xDatePickers,
  '@emotion/styled': emotionStyled,
  '@mui/base': muiBase,
  '@mui/material': muiMaterial
};

var init = /*#__PURE__*/function () {
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(url) {
    var _i, _Object$entries, _Object$entries$_i, name, module, dllDir, manifestResponse, manifest, linkElement;

    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            for (_i = 0, _Object$entries = Object.entries(externals); _i < _Object$entries.length; _i++) {
              _Object$entries$_i = (0, _slicedToArray2["default"])(_Object$entries[_i], 2), name = _Object$entries$_i[0], module = _Object$entries$_i[1];
              window["".concat(_dll.globalVar, "_").concat(name)] = module;
            }

            dllDir = "".concat(url, "/dll/").concat(_dll.version, "/");
            _context.next = 4;
            return fetch(dllDir + 'manifest.json');

          case 4:
            manifestResponse = _context.sent;
            _context.next = 7;
            return manifestResponse.json();

          case 7:
            manifest = _context.sent;
            _context.next = 10;
            return Promise.resolve("".concat(
            /* webpackIgnore: true */
            dllDir + manifest['main.js'])).then(function (s) {
              return _interopRequireWildcard(require(s));
            });

          case 10:
            linkElement = document.createElement('link');
            linkElement.rel = 'stylesheet';
            linkElement.href = dllDir + manifest['main.css'];
            document.head.appendChild(linkElement);
            console.log(window.__formula);
            Object.assign(DLL, window.__formula);

          case 16:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));

  return function init(_x) {
    return _ref.apply(this, arguments);
  };
}();

exports.init = init;
//# sourceMappingURL=dll.cjs.map