"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.getProjectSchema = exports.getPackagesJson = void 0;
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var getPackagesJson = exports.getPackagesJson = /*#__PURE__*/function () {
  var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
    var _window$PROJECT_CONFI;
    var packages, url, res, data;
    return _regenerator["default"].wrap(function _callee$(_context) {
      while (1) switch (_context.prev = _context.next) {
        case 0:
          packages = _ref.packages;
          if (!packages) {
            _context.next = 3;
            break;
          }
          return _context.abrupt("return", packages);
        case 3:
          url = ((_window$PROJECT_CONFI = window.PROJECT_CONFIG) === null || _window$PROJECT_CONFI === void 0 ? void 0 : _window$PROJECT_CONFI.packages_list) || 'https://ywfedps.oss-cn-hangzhou.aliyuncs.com/packages_list/1709193635466.json';
          _context.next = 6;
          return fetch(url);
        case 6:
          res = _context.sent;
          _context.next = 9;
          return res.json();
        case 9:
          data = _context.sent;
          return _context.abrupt("return", (data === null || data === void 0 ? void 0 : data.packages) || []);
        case 11:
        case "end":
          return _context.stop();
      }
    }, _callee);
  }));
  return function getPackagesJson(_x) {
    return _ref2.apply(this, arguments);
  };
}();
var getProjectSchema = exports.getProjectSchema = /*#__PURE__*/function () {
  var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref3) {
    var _ref3$url, url, projectSchema, res, data;
    return _regenerator["default"].wrap(function _callee2$(_context2) {
      while (1) switch (_context2.prev = _context2.next) {
        case 0:
          _ref3$url = _ref3.url, url = _ref3$url === void 0 ? 'https://ywfedps.oss-cn-hangzhou.aliyuncs.com/project/ai/v1/page/b2a04394cd.json' : _ref3$url, projectSchema = _ref3.projectSchema;
          if (!projectSchema) {
            _context2.next = 3;
            break;
          }
          return _context2.abrupt("return", projectSchema);
        case 3:
          _context2.next = 5;
          return fetch(url);
        case 5:
          res = _context2.sent;
          _context2.next = 8;
          return res.json();
        case 8:
          data = _context2.sent;
          return _context2.abrupt("return", data);
        case 10:
        case "end":
          return _context2.stop();
      }
    }, _callee2);
  }));
  return function getProjectSchema(_x2) {
    return _ref4.apply(this, arguments);
  };
}();