elementRoleMap.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
  3. var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
  4. _Object$defineProperty(exports, "__esModule", {
  5. value: true
  6. });
  7. exports.default = void 0;
  8. var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
  9. var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
  10. var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/entries"));
  11. var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
  12. var _stringify = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/json/stringify"));
  13. var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
  14. var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/keys"));
  15. var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
  16. var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
  17. var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/map"));
  18. var _rolesMap = _interopRequireDefault(require("./rolesMap"));
  19. var _context;
  20. var elementRoleMap = new _map.default([]);
  21. (0, _forEach.default)(_context = (0, _toConsumableArray2.default)((0, _keys.default)(_rolesMap.default).call(_rolesMap.default))).call(_context, function (key) {
  22. var role = _rolesMap.default.get(key);
  23. if (role) {
  24. var _context2, _context3;
  25. (0, _forEach.default)(_context2 = (0, _concat.default)(_context3 = []).call(_context3, (0, _toConsumableArray2.default)(role.baseConcepts), (0, _toConsumableArray2.default)(role.relatedConcepts))).call(_context2, function (relation) {
  26. if (relation.module === 'HTML') {
  27. var concept = relation.concept;
  28. if (concept) {
  29. var _context4;
  30. var conceptStr = (0, _stringify.default)(concept);
  31. var roles = ((0, _find.default)(_context4 = (0, _toConsumableArray2.default)((0, _entries.default)(elementRoleMap).call(elementRoleMap))).call(_context4, function (_ref) {
  32. var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
  33. key = _ref2[0],
  34. value = _ref2[1];
  35. return (0, _stringify.default)(key) === conceptStr;
  36. }) || [])[1];
  37. if (!roles) {
  38. roles = new _set.default([]);
  39. }
  40. roles.add(key);
  41. elementRoleMap.set(concept, roles);
  42. }
  43. }
  44. });
  45. }
  46. });
  47. var _default = elementRoleMap;
  48. exports.default = _default;