@ant-design/x-markdown
Version:
placeholder for @ant-design/x-markdown
1,401 lines (1,301 loc) • 8.58 MB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory(require("react"), require("react-dom"), require("antdCssinjs"));
else if(typeof define === 'function' && define.amd)
define([, , ], factory);
else if(typeof exports === 'object')
exports["Mermaid"] = factory(require("react"), require("react-dom"), require("antdCssinjs"));
else
root["Mermaid"] = factory(root["React"], root["ReactDOM"], root["antdCssinjs"]);
})(self, function(__WEBPACK_EXTERNAL_MODULE__868__, __WEBPACK_EXTERNAL_MODULE__1238__, __WEBPACK_EXTERNAL_MODULE__283__) {
return /******/ (function() { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 2745:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.BLANK_URL = exports.relativeFirstCharacters = exports.whitespaceEscapeCharsRegex = exports.urlSchemeRegex = exports.ctrlCharactersRegex = exports.htmlCtrlEntityRegex = exports.htmlEntitiesRegex = exports.invalidProtocolRegex = void 0;
exports.invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im;
exports.htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g;
exports.htmlCtrlEntityRegex = /&(newline|tab);/gi;
exports.ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim;
exports.urlSchemeRegex = /^.+(:|:)/gim;
exports.whitespaceEscapeCharsRegex = /(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g;
exports.relativeFirstCharacters = [".", "/"];
exports.BLANK_URL = "about:blank";
/***/ }),
/***/ 1906:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __webpack_unused_export__;
__webpack_unused_export__ = ({
value: true
});
exports.N = void 0;
var constants_1 = __webpack_require__(2745);
function isRelativeUrlWithoutProtocol(url) {
return constants_1.relativeFirstCharacters.indexOf(url[0]) > -1;
}
function decodeHtmlCharacters(str) {
var removedNullByte = str.replace(constants_1.ctrlCharactersRegex, "");
return removedNullByte.replace(constants_1.htmlEntitiesRegex, function (match, dec) {
return String.fromCharCode(dec);
});
}
function isValidUrl(url) {
return URL.canParse(url);
}
function decodeURI(uri) {
try {
return decodeURIComponent(uri);
} catch (e) {
// Ignoring error
// It is possible that the URI contains a `%` not associated
// with URI/URL-encoding.
return uri;
}
}
function sanitizeUrl(url) {
if (!url) {
return constants_1.BLANK_URL;
}
var charsToDecode;
var decodedUrl = decodeURI(url.trim());
do {
decodedUrl = decodeHtmlCharacters(decodedUrl).replace(constants_1.htmlCtrlEntityRegex, "").replace(constants_1.ctrlCharactersRegex, "").replace(constants_1.whitespaceEscapeCharsRegex, "").trim();
decodedUrl = decodeURI(decodedUrl);
charsToDecode = decodedUrl.match(constants_1.ctrlCharactersRegex) || decodedUrl.match(constants_1.htmlEntitiesRegex) || decodedUrl.match(constants_1.htmlCtrlEntityRegex) || decodedUrl.match(constants_1.whitespaceEscapeCharsRegex);
} while (charsToDecode && charsToDecode.length > 0);
var sanitizedUrl = decodedUrl;
if (!sanitizedUrl) {
return constants_1.BLANK_URL;
}
if (isRelativeUrlWithoutProtocol(sanitizedUrl)) {
return sanitizedUrl;
}
// Remove any leading whitespace before checking the URL scheme
var trimmedUrl = sanitizedUrl.trimStart();
var urlSchemeParseResults = trimmedUrl.match(constants_1.urlSchemeRegex);
if (!urlSchemeParseResults) {
return sanitizedUrl;
}
var urlScheme = urlSchemeParseResults[0].toLowerCase().trim();
if (constants_1.invalidProtocolRegex.test(urlScheme)) {
return constants_1.BLANK_URL;
}
var backSanitized = trimmedUrl.replace(/\\/g, "/");
// Handle special cases for mailto: and custom deep-link protocols
if (urlScheme === "mailto:" || urlScheme.includes("://")) {
return backSanitized;
}
// For http and https URLs, perform additional validation
if (urlScheme === "http:" || urlScheme === "https:") {
if (!isValidUrl(backSanitized)) {
return constants_1.BLANK_URL;
}
var url_1 = new URL(backSanitized);
url_1.protocol = url_1.protocol.toLowerCase();
url_1.hostname = url_1.hostname.toLowerCase();
return url_1.toString();
}
return backSanitized;
}
exports.N = sanitizeUrl;
/***/ }),
/***/ 7150:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
const locale = {
// Options
items_per_page: '/ page',
jump_to: 'Go to',
jump_to_confirm: 'confirm',
page: 'Page',
// Pagination
prev_page: 'Previous Page',
next_page: 'Next Page',
prev_5: 'Previous 5 Pages',
next_5: 'Next 5 Pages',
prev_3: 'Previous 3 Pages',
next_3: 'Next 3 Pages',
page_size: 'Page Size'
};
var _default = exports["default"] = locale;
/***/ }),
/***/ 5989:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports.commonLocale = void 0;
var commonLocale = exports.commonLocale = {
yearFormat: 'YYYY',
dayFormat: 'D',
cellMeridiemFormat: 'A',
monthBeforeYear: true
};
/***/ }),
/***/ 7572:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
var _common = __webpack_require__(5989);
function _typeof(o) {
"@babel/helpers - typeof";
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
return typeof o;
} : function (o) {
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
}, _typeof(o);
}
function ownKeys(e, r) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
r && (o = o.filter(function (r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function _objectSpread(e) {
for (var r = 1; r < arguments.length; r++) {
var t = null != arguments[r] ? arguments[r] : {};
r % 2 ? ownKeys(Object(t), !0).forEach(function (r) {
_defineProperty(e, r, t[r]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
});
}
return e;
}
function _defineProperty(obj, key, value) {
key = _toPropertyKey(key);
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
}
function _toPropertyKey(t) {
var i = _toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : String(i);
}
function _toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
var locale = _objectSpread(_objectSpread({}, _common.commonLocale), {}, {
locale: 'en_US',
today: 'Today',
now: 'Now',
backToToday: 'Back to today',
ok: 'OK',
clear: 'Clear',
week: 'Week',
month: 'Month',
year: 'Year',
timeSelect: 'select time',
dateSelect: 'select date',
weekSelect: 'Choose a week',
monthSelect: 'Choose a month',
yearSelect: 'Choose a year',
decadeSelect: 'Choose a decade',
previousMonth: 'Previous month (PageUp)',
nextMonth: 'Next month (PageDown)',
previousYear: 'Last year (Control + left)',
nextYear: 'Next year (Control + right)',
previousDecade: 'Last decade',
nextDecade: 'Next decade',
previousCentury: 'Last century',
nextCentury: 'Next century'
});
var _default = exports["default"] = locale;
/***/ }),
/***/ 9944:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var _interopRequireDefault = __webpack_require__(7972);
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
var _en_US = _interopRequireDefault(__webpack_require__(460));
var _default = exports["default"] = _en_US.default;
/***/ }),
/***/ 460:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var _interopRequireDefault = __webpack_require__(7972);
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
var _en_US = _interopRequireDefault(__webpack_require__(7572));
var _en_US2 = _interopRequireDefault(__webpack_require__(1268));
// Merge into a locale object
const locale = {
lang: {
placeholder: 'Select date',
yearPlaceholder: 'Select year',
quarterPlaceholder: 'Select quarter',
monthPlaceholder: 'Select month',
weekPlaceholder: 'Select week',
rangePlaceholder: ['Start date', 'End date'],
rangeYearPlaceholder: ['Start year', 'End year'],
rangeQuarterPlaceholder: ['Start quarter', 'End quarter'],
rangeMonthPlaceholder: ['Start month', 'End month'],
rangeWeekPlaceholder: ['Start week', 'End week'],
..._en_US.default
},
timePickerLocale: {
..._en_US2.default
}
};
// All settings at:
// https://github.com/ant-design/ant-design/blob/master/components/date-picker/locale/example.json
var _default = exports["default"] = locale;
/***/ }),
/***/ 1044:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var __webpack_unused_export__;
var _interopRequireDefault = __webpack_require__(7972);
__webpack_unused_export__ = ({
value: true
});
exports.Z = void 0;
var _en_US = _interopRequireDefault(__webpack_require__(7150));
var _en_US2 = _interopRequireDefault(__webpack_require__(9944));
var _en_US3 = _interopRequireDefault(__webpack_require__(460));
var _en_US4 = _interopRequireDefault(__webpack_require__(1268));
const typeTemplate = '${label} is not a valid ${type}';
const localeValues = {
locale: 'en',
Pagination: _en_US.default,
DatePicker: _en_US3.default,
TimePicker: _en_US4.default,
Calendar: _en_US2.default,
global: {
placeholder: 'Please select',
close: 'Close',
sortable: 'sortable'
},
Table: {
filterTitle: 'Filter menu',
filterConfirm: 'OK',
filterReset: 'Reset',
filterEmptyText: 'No filters',
filterCheckAll: 'Select all items',
filterSearchPlaceholder: 'Search in filters',
emptyText: 'No data',
selectAll: 'Select current page',
selectInvert: 'Invert current page',
selectNone: 'Clear all data',
selectionAll: 'Select all data',
sortTitle: 'Sort',
expand: 'Expand row',
collapse: 'Collapse row',
triggerDesc: 'Click to sort descending',
triggerAsc: 'Click to sort ascending',
cancelSort: 'Click to cancel sorting'
},
Tour: {
Next: 'Next',
Previous: 'Previous',
Finish: 'Finish'
},
Modal: {
okText: 'OK',
cancelText: 'Cancel',
justOkText: 'OK'
},
Popconfirm: {
okText: 'OK',
cancelText: 'Cancel'
},
Transfer: {
titles: ['', ''],
searchPlaceholder: 'Search here',
itemUnit: 'item',
itemsUnit: 'items',
remove: 'Remove',
selectCurrent: 'Select current page',
removeCurrent: 'Remove current page',
selectAll: 'Select all data',
deselectAll: 'Deselect all data',
removeAll: 'Remove all data',
selectInvert: 'Invert current page'
},
Upload: {
uploading: 'Uploading...',
removeFile: 'Remove file',
uploadError: 'Upload error',
previewFile: 'Preview file',
downloadFile: 'Download file'
},
Empty: {
description: 'No data'
},
Icon: {
icon: 'icon'
},
Text: {
edit: 'Edit',
copy: 'Copy',
copied: 'Copied',
expand: 'Expand',
collapse: 'Collapse'
},
Form: {
optional: '(optional)',
defaultValidateMessages: {
default: 'Field validation error for ${label}',
required: 'Please enter ${label}',
enum: '${label} must be one of [${enum}]',
whitespace: '${label} cannot be a blank character',
date: {
format: '${label} date format is invalid',
parse: '${label} cannot be converted to a date',
invalid: '${label} is an invalid date'
},
types: {
string: typeTemplate,
method: typeTemplate,
array: typeTemplate,
object: typeTemplate,
number: typeTemplate,
date: typeTemplate,
boolean: typeTemplate,
integer: typeTemplate,
float: typeTemplate,
regexp: typeTemplate,
email: typeTemplate,
url: typeTemplate,
hex: typeTemplate
},
string: {
len: '${label} must be ${len} characters',
min: '${label} must be at least ${min} characters',
max: '${label} must be up to ${max} characters',
range: '${label} must be between ${min}-${max} characters'
},
number: {
len: '${label} must be equal to ${len}',
min: '${label} must be minimum ${min}',
max: '${label} must be maximum ${max}',
range: '${label} must be between ${min}-${max}'
},
array: {
len: 'Must be ${len} ${label}',
min: 'At least ${min} ${label}',
max: 'At most ${max} ${label}',
range: 'The amount of ${label} must be between ${min}-${max}'
},
pattern: {
mismatch: '${label} does not match the pattern ${pattern}'
}
}
},
QRCode: {
expired: 'QR code expired',
refresh: 'Refresh',
scanned: 'Scanned'
},
ColorPicker: {
presetEmpty: 'Empty',
transparent: 'Transparent',
singleColor: 'Single',
gradientColor: 'Gradient'
}
};
var _default = exports.Z = localeValues;
/***/ }),
/***/ 1268:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", ({
value: true
}));
exports["default"] = void 0;
const locale = {
placeholder: 'Select time',
rangePlaceholder: ['Start time', 'End time']
};
var _default = exports["default"] = locale;
/***/ }),
/***/ 2991:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
(function webpackUniversalModuleDefinition(root, factory) {
if (true) module.exports = factory(__webpack_require__(7179));else {}
})(this, function (__WEBPACK_EXTERNAL_MODULE_0__) {
return /******/function (modules) {
// webpackBootstrap
/******/ // The module cache
/******/
var installedModules = {};
/******/
/******/ // The require function
/******/
function __nested_webpack_require_663__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/if (installedModules[moduleId]) {
/******/return installedModules[moduleId].exports;
/******/
}
/******/ // Create a new module (and put it into the cache)
/******/
var module = installedModules[moduleId] = {
/******/i: moduleId,
/******/l: false,
/******/exports: {}
/******/
};
/******/
/******/ // Execute the module function
/******/
modules[moduleId].call(module.exports, module, module.exports, __nested_webpack_require_663__);
/******/
/******/ // Flag the module as loaded
/******/
module.l = true;
/******/
/******/ // Return the exports of the module
/******/
return module.exports;
/******/
}
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/
__nested_webpack_require_663__.m = modules;
/******/
/******/ // expose the module cache
/******/
__nested_webpack_require_663__.c = installedModules;
/******/
/******/ // identity function for calling harmony imports with the correct context
/******/
__nested_webpack_require_663__.i = function (value) {
return value;
};
/******/
/******/ // define getter function for harmony exports
/******/
__nested_webpack_require_663__.d = function (exports, name, getter) {
/******/if (!__nested_webpack_require_663__.o(exports, name)) {
/******/Object.defineProperty(exports, name, {
/******/configurable: false,
/******/enumerable: true,
/******/get: getter
/******/
});
/******/
}
/******/
};
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/
__nested_webpack_require_663__.n = function (module) {
/******/var getter = module && module.__esModule ? /******/function getDefault() {
return module['default'];
} : /******/function getModuleExports() {
return module;
};
/******/
__nested_webpack_require_663__.d(getter, 'a', getter);
/******/
return getter;
/******/
};
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/
__nested_webpack_require_663__.o = function (object, property) {
return Object.prototype.hasOwnProperty.call(object, property);
};
/******/
/******/ // __webpack_public_path__
/******/
__nested_webpack_require_663__.p = "";
/******/
/******/ // Load entry module and return exports
/******/
return __nested_webpack_require_663__(__nested_webpack_require_663__.s = 7);
/******/
}
/************************************************************************/
/******/([( /* 0 */
/***/function (module, exports) {
module.exports = __WEBPACK_EXTERNAL_MODULE_0__;
/***/
}), ( /* 1 */
/***/function (module, exports, __nested_webpack_require_3615__) {
"use strict";
var FDLayoutConstants = __nested_webpack_require_3615__(0).FDLayoutConstants;
function CoSEConstants() {}
//CoSEConstants inherits static props in FDLayoutConstants
for (var prop in FDLayoutConstants) {
CoSEConstants[prop] = FDLayoutConstants[prop];
}
CoSEConstants.DEFAULT_USE_MULTI_LEVEL_SCALING = false;
CoSEConstants.DEFAULT_RADIAL_SEPARATION = FDLayoutConstants.DEFAULT_EDGE_LENGTH;
CoSEConstants.DEFAULT_COMPONENT_SEPERATION = 60;
CoSEConstants.TILE = true;
CoSEConstants.TILING_PADDING_VERTICAL = 10;
CoSEConstants.TILING_PADDING_HORIZONTAL = 10;
CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL = false; // make this true when cose is used incrementally as a part of other non-incremental layout
module.exports = CoSEConstants;
/***/
}), ( /* 2 */
/***/function (module, exports, __nested_webpack_require_4497__) {
"use strict";
var FDLayoutEdge = __nested_webpack_require_4497__(0).FDLayoutEdge;
function CoSEEdge(source, target, vEdge) {
FDLayoutEdge.call(this, source, target, vEdge);
}
CoSEEdge.prototype = Object.create(FDLayoutEdge.prototype);
for (var prop in FDLayoutEdge) {
CoSEEdge[prop] = FDLayoutEdge[prop];
}
module.exports = CoSEEdge;
/***/
}), ( /* 3 */
/***/function (module, exports, __nested_webpack_require_4948__) {
"use strict";
var LGraph = __nested_webpack_require_4948__(0).LGraph;
function CoSEGraph(parent, graphMgr, vGraph) {
LGraph.call(this, parent, graphMgr, vGraph);
}
CoSEGraph.prototype = Object.create(LGraph.prototype);
for (var prop in LGraph) {
CoSEGraph[prop] = LGraph[prop];
}
module.exports = CoSEGraph;
/***/
}), ( /* 4 */
/***/function (module, exports, __nested_webpack_require_5373__) {
"use strict";
var LGraphManager = __nested_webpack_require_5373__(0).LGraphManager;
function CoSEGraphManager(layout) {
LGraphManager.call(this, layout);
}
CoSEGraphManager.prototype = Object.create(LGraphManager.prototype);
for (var prop in LGraphManager) {
CoSEGraphManager[prop] = LGraphManager[prop];
}
module.exports = CoSEGraphManager;
/***/
}), ( /* 5 */
/***/function (module, exports, __nested_webpack_require_5832__) {
"use strict";
var FDLayoutNode = __nested_webpack_require_5832__(0).FDLayoutNode;
var IMath = __nested_webpack_require_5832__(0).IMath;
function CoSENode(gm, loc, size, vNode) {
FDLayoutNode.call(this, gm, loc, size, vNode);
}
CoSENode.prototype = Object.create(FDLayoutNode.prototype);
for (var prop in FDLayoutNode) {
CoSENode[prop] = FDLayoutNode[prop];
}
CoSENode.prototype.move = function () {
var layout = this.graphManager.getLayout();
this.displacementX = layout.coolingFactor * (this.springForceX + this.repulsionForceX + this.gravitationForceX) / this.noOfChildren;
this.displacementY = layout.coolingFactor * (this.springForceY + this.repulsionForceY + this.gravitationForceY) / this.noOfChildren;
if (Math.abs(this.displacementX) > layout.coolingFactor * layout.maxNodeDisplacement) {
this.displacementX = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementX);
}
if (Math.abs(this.displacementY) > layout.coolingFactor * layout.maxNodeDisplacement) {
this.displacementY = layout.coolingFactor * layout.maxNodeDisplacement * IMath.sign(this.displacementY);
}
// a simple node, just move it
if (this.child == null) {
this.moveBy(this.displacementX, this.displacementY);
}
// an empty compound node, again just move it
else if (this.child.getNodes().length == 0) {
this.moveBy(this.displacementX, this.displacementY);
}
// non-empty compound node, propogate movement to children as well
else {
this.propogateDisplacementToChildren(this.displacementX, this.displacementY);
}
layout.totalDisplacement += Math.abs(this.displacementX) + Math.abs(this.displacementY);
this.springForceX = 0;
this.springForceY = 0;
this.repulsionForceX = 0;
this.repulsionForceY = 0;
this.gravitationForceX = 0;
this.gravitationForceY = 0;
this.displacementX = 0;
this.displacementY = 0;
};
CoSENode.prototype.propogateDisplacementToChildren = function (dX, dY) {
var nodes = this.getChild().getNodes();
var node;
for (var i = 0; i < nodes.length; i++) {
node = nodes[i];
if (node.getChild() == null) {
node.moveBy(dX, dY);
node.displacementX += dX;
node.displacementY += dY;
} else {
node.propogateDisplacementToChildren(dX, dY);
}
}
};
CoSENode.prototype.setPred1 = function (pred1) {
this.pred1 = pred1;
};
CoSENode.prototype.getPred1 = function () {
return pred1;
};
CoSENode.prototype.getPred2 = function () {
return pred2;
};
CoSENode.prototype.setNext = function (next) {
this.next = next;
};
CoSENode.prototype.getNext = function () {
return next;
};
CoSENode.prototype.setProcessed = function (processed) {
this.processed = processed;
};
CoSENode.prototype.isProcessed = function () {
return processed;
};
module.exports = CoSENode;
/***/
}), ( /* 6 */
/***/function (module, exports, __nested_webpack_require_8999__) {
"use strict";
var FDLayout = __nested_webpack_require_8999__(0).FDLayout;
var CoSEGraphManager = __nested_webpack_require_8999__(4);
var CoSEGraph = __nested_webpack_require_8999__(3);
var CoSENode = __nested_webpack_require_8999__(5);
var CoSEEdge = __nested_webpack_require_8999__(2);
var CoSEConstants = __nested_webpack_require_8999__(1);
var FDLayoutConstants = __nested_webpack_require_8999__(0).FDLayoutConstants;
var LayoutConstants = __nested_webpack_require_8999__(0).LayoutConstants;
var Point = __nested_webpack_require_8999__(0).Point;
var PointD = __nested_webpack_require_8999__(0).PointD;
var Layout = __nested_webpack_require_8999__(0).Layout;
var Integer = __nested_webpack_require_8999__(0).Integer;
var IGeometry = __nested_webpack_require_8999__(0).IGeometry;
var LGraph = __nested_webpack_require_8999__(0).LGraph;
var Transform = __nested_webpack_require_8999__(0).Transform;
function CoSELayout() {
FDLayout.call(this);
this.toBeTiled = {}; // Memorize if a node is to be tiled or is tiled
}
CoSELayout.prototype = Object.create(FDLayout.prototype);
for (var prop in FDLayout) {
CoSELayout[prop] = FDLayout[prop];
}
CoSELayout.prototype.newGraphManager = function () {
var gm = new CoSEGraphManager(this);
this.graphManager = gm;
return gm;
};
CoSELayout.prototype.newGraph = function (vGraph) {
return new CoSEGraph(null, this.graphManager, vGraph);
};
CoSELayout.prototype.newNode = function (vNode) {
return new CoSENode(this.graphManager, vNode);
};
CoSELayout.prototype.newEdge = function (vEdge) {
return new CoSEEdge(null, null, vEdge);
};
CoSELayout.prototype.initParameters = function () {
FDLayout.prototype.initParameters.call(this, arguments);
if (!this.isSubLayout) {
if (CoSEConstants.DEFAULT_EDGE_LENGTH < 10) {
this.idealEdgeLength = 10;
} else {
this.idealEdgeLength = CoSEConstants.DEFAULT_EDGE_LENGTH;
}
this.useSmartIdealEdgeLengthCalculation = CoSEConstants.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION;
this.springConstant = FDLayoutConstants.DEFAULT_SPRING_STRENGTH;
this.repulsionConstant = FDLayoutConstants.DEFAULT_REPULSION_STRENGTH;
this.gravityConstant = FDLayoutConstants.DEFAULT_GRAVITY_STRENGTH;
this.compoundGravityConstant = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_STRENGTH;
this.gravityRangeFactor = FDLayoutConstants.DEFAULT_GRAVITY_RANGE_FACTOR;
this.compoundGravityRangeFactor = FDLayoutConstants.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR;
// variables for tree reduction support
this.prunedNodesAll = [];
this.growTreeIterations = 0;
this.afterGrowthIterations = 0;
this.isTreeGrowing = false;
this.isGrowthFinished = false;
// variables for cooling
this.coolingCycle = 0;
this.maxCoolingCycle = this.maxIterations / FDLayoutConstants.CONVERGENCE_CHECK_PERIOD;
this.finalTemperature = FDLayoutConstants.CONVERGENCE_CHECK_PERIOD / this.maxIterations;
this.coolingAdjuster = 1;
}
};
CoSELayout.prototype.layout = function () {
var createBendsAsNeeded = LayoutConstants.DEFAULT_CREATE_BENDS_AS_NEEDED;
if (createBendsAsNeeded) {
this.createBendpoints();
this.graphManager.resetAllEdges();
}
this.level = 0;
return this.classicLayout();
};
CoSELayout.prototype.classicLayout = function () {
this.nodesWithGravity = this.calculateNodesToApplyGravitationTo();
this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity);
this.calcNoOfChildrenForAllNodes();
this.graphManager.calcLowestCommonAncestors();
this.graphManager.calcInclusionTreeDepths();
this.graphManager.getRoot().calcEstimatedSize();
this.calcIdealEdgeLengths();
if (!this.incremental) {
var forest = this.getFlatForest();
// The graph associated with this layout is flat and a forest
if (forest.length > 0) {
this.positionNodesRadially(forest);
}
// The graph associated with this layout is not flat or a forest
else {
// Reduce the trees when incremental mode is not enabled and graph is not a forest
this.reduceTrees();
// Update nodes that gravity will be applied
this.graphManager.resetAllNodesToApplyGravitation();
var allNodes = new Set(this.getAllNodes());
var intersection = this.nodesWithGravity.filter(function (x) {
return allNodes.has(x);
});
this.graphManager.setAllNodesToApplyGravitation(intersection);
this.positionNodesRandomly();
}
} else {
if (CoSEConstants.TREE_REDUCTION_ON_INCREMENTAL) {
// Reduce the trees in incremental mode if only this constant is set to true
this.reduceTrees();
// Update nodes that gravity will be applied
this.graphManager.resetAllNodesToApplyGravitation();
var allNodes = new Set(this.getAllNodes());
var intersection = this.nodesWithGravity.filter(function (x) {
return allNodes.has(x);
});
this.graphManager.setAllNodesToApplyGravitation(intersection);
}
}
this.initSpringEmbedder();
this.runSpringEmbedder();
return true;
};
CoSELayout.prototype.tick = function () {
this.totalIterations++;
if (this.totalIterations === this.maxIterations && !this.isTreeGrowing && !this.isGrowthFinished) {
if (this.prunedNodesAll.length > 0) {
this.isTreeGrowing = true;
} else {
return true;
}
}
if (this.totalIterations % FDLayoutConstants.CONVERGENCE_CHECK_PERIOD == 0 && !this.isTreeGrowing && !this.isGrowthFinished) {
if (this.isConverged()) {
if (this.prunedNodesAll.length > 0) {
this.isTreeGrowing = true;
} else {
return true;
}
}
this.coolingCycle++;
if (this.layoutQuality == 0) {
// quality - "draft"
this.coolingAdjuster = this.coolingCycle;
} else if (this.layoutQuality == 1) {
// quality - "default"
this.coolingAdjuster = this.coolingCycle / 3;
}
// cooling schedule is based on http://www.btluke.com/simanf1.html -> cooling schedule 3
this.coolingFactor = Math.max(this.initialCoolingFactor - Math.pow(this.coolingCycle, Math.log(100 * (this.initialCoolingFactor - this.finalTemperature)) / Math.log(this.maxCoolingCycle)) / 100 * this.coolingAdjuster, this.finalTemperature);
this.animationPeriod = Math.ceil(this.initialAnimationPeriod * Math.sqrt(this.coolingFactor));
}
// Operations while tree is growing again
if (this.isTreeGrowing) {
if (this.growTreeIterations % 10 == 0) {
if (this.prunedNodesAll.length > 0) {
this.graphManager.updateBounds();
this.updateGrid();
this.growTree(this.prunedNodesAll);
// Update nodes that gravity will be applied
this.graphManager.resetAllNodesToApplyGravitation();
var allNodes = new Set(this.getAllNodes());
var intersection = this.nodesWithGravity.filter(function (x) {
return allNodes.has(x);
});
this.graphManager.setAllNodesToApplyGravitation(intersection);
this.graphManager.updateBounds();
this.updateGrid();
this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL;
} else {
this.isTreeGrowing = false;
this.isGrowthFinished = true;
}
}
this.growTreeIterations++;
}
// Operations after growth is finished
if (this.isGrowthFinished) {
if (this.isConverged()) {
return true;
}
if (this.afterGrowthIterations % 10 == 0) {
this.graphManager.updateBounds();
this.updateGrid();
}
this.coolingFactor = FDLayoutConstants.DEFAULT_COOLING_FACTOR_INCREMENTAL * ((100 - this.afterGrowthIterations) / 100);
this.afterGrowthIterations++;
}
var gridUpdateAllowed = !this.isTreeGrowing && !this.isGrowthFinished;
var forceToNodeSurroundingUpdate = this.growTreeIterations % 10 == 1 && this.isTreeGrowing || this.afterGrowthIterations % 10 == 1 && this.isGrowthFinished;
this.totalDisplacement = 0;
this.graphManager.updateBounds();
this.calcSpringForces();
this.calcRepulsionForces(gridUpdateAllowed, forceToNodeSurroundingUpdate);
this.calcGravitationalForces();
this.moveNodes();
this.animate();
return false; // Layout is not ended yet return false
};
CoSELayout.prototype.getPositionsData = function () {
var allNodes = this.graphManager.getAllNodes();
var pData = {};
for (var i = 0; i < allNodes.length; i++) {
var rect = allNodes[i].rect;
var id = allNodes[i].id;
pData[id] = {
id: id,
x: rect.getCenterX(),
y: rect.getCenterY(),
w: rect.width,
h: rect.height
};
}
return pData;
};
CoSELayout.prototype.runSpringEmbedder = function () {
this.initialAnimationPeriod = 25;
this.animationPeriod = this.initialAnimationPeriod;
var layoutEnded = false;
// If aminate option is 'during' signal that layout is supposed to start iterating
if (FDLayoutConstants.ANIMATE === 'during') {
this.emit('layoutstarted');
} else {
// If aminate option is 'during' tick() function will be called on index.js
while (!layoutEnded) {
layoutEnded = this.tick();
}
this.graphManager.updateBounds();
}
};
CoSELayout.prototype.calculateNodesToApplyGravitationTo = function () {
var nodeList = [];
var graph;
var graphs = this.graphManager.getGraphs();
var size = graphs.length;
var i;
for (i = 0; i < size; i++) {
graph = graphs[i];
graph.updateConnected();
if (!graph.isConnected) {
nodeList = nodeList.concat(graph.getNodes());
}
}
return nodeList;
};
CoSELayout.prototype.createBendpoints = function () {
var edges = [];
edges = edges.concat(this.graphManager.getAllEdges());
var visited = new Set();
var i;
for (i = 0; i < edges.length; i++) {
var edge = edges[i];
if (!visited.has(edge)) {
var source = edge.getSource();
var target = edge.getTarget();
if (source == target) {
edge.getBendpoints().push(new PointD());
edge.getBendpoints().push(new PointD());
this.createDummyNodesForBendpoints(edge);
visited.add(edge);
} else {
var edgeList = [];
edgeList = edgeList.concat(source.getEdgeListToNode(target));
edgeList = edgeList.concat(target.getEdgeListToNode(source));
if (!visited.has(edgeList[0])) {
if (edgeList.length > 1) {
var k;
for (k = 0; k < edgeList.length; k++) {
var multiEdge = edgeList[k];
multiEdge.getBendpoints().push(new PointD());
this.createDummyNodesForBendpoints(multiEdge);
}
}
edgeList.forEach(function (edge) {
visited.add(edge);
});
}
}
}
if (visited.size == edges.length) {
break;
}
}
};
CoSELayout.prototype.positionNodesRadially = function (forest) {
// We tile the trees to a grid row by row; first tree starts at (0,0)
var currentStartingPoint = new Point(0, 0);
var numberOfColumns = Math.ceil(Math.sqrt(forest.length));
var height = 0;
var currentY = 0;
var currentX = 0;
var point = new PointD(0, 0);
for (var i = 0; i < forest.length; i++) {
if (i % numberOfColumns == 0) {
// Start of a new row, make the x coordinate 0, increment the
// y coordinate with the max height of the previous row
currentX = 0;
currentY = height;
if (i != 0) {
currentY += CoSEConstants.DEFAULT_COMPONENT_SEPERATION;
}
height = 0;
}
var tree = forest[i];
// Find the center of the tree
var centerNode = Layout.findCenterOfTree(tree);
// Set the staring point of the next tree
currentStartingPoint.x = currentX;
currentStartingPoint.y = currentY;
// Do a radial layout starting with the center
point = CoSELayout.radialLayout(tree, centerNode, currentStartingPoint);
if (point.y > height) {
height = Math.floor(point.y);
}
currentX = Math.floor(point.x + CoSEConstants.DEFAULT_COMPONENT_SEPERATION);
}
this.transform(new PointD(LayoutConstants.WORLD_CENTER_X - point.x / 2, LayoutConstants.WORLD_CENTER_Y - point.y / 2));
};
CoSELayout.radialLayout = function (tree, centerNode, startingPoint) {
var radialSep = Math.max(this.maxDiagonalInTree(tree), CoSEConstants.DEFAULT_RADIAL_SEPARATION);
CoSELayout.branchRadialLayout(centerNode, null, 0, 359, 0, radialSep);
var bounds = LGraph.calculateBounds(tree);
var transform = new Transform();
transform.setDeviceOrgX(bounds.getMinX());
transform.setDeviceOrgY(bounds.getMinY());
transform.setWorldOrgX(startingPoint.x);
transform.setWorldOrgY(startingPoint.y);
for (var i = 0; i < tree.length; i++) {
var node = tree[i];
node.transform(transform);
}
var bottomRight = new PointD(bounds.getMaxX(), bounds.getMaxY());
return transform.inverseTransformPoint(bottomRight);
};
CoSELayout.branchRadialLayout = function (node, parentOfNode, startAngle, endAngle, distance, radialSeparation) {
// First, position this node by finding its angle.
var halfInterval = (endAngle - startAngle + 1) / 2;
if (halfInterval < 0) {
halfInterval += 180;
}
var nodeAngle = (halfInterval + startAngle) % 360;
var teta = nodeAngle * IGeometry.TWO_PI / 360;
// Make polar to java cordinate conversion.
var cos_teta = Math.cos(teta);
var x_ = distance * Math.cos(teta);
var y_ = distance * Math.sin(teta);
node.setCenter(x_, y_);
// Traverse all neighbors of this node and recursively call this
// function.
var neighborEdges = [];
neighborEdges = neighborEdges.concat(node.getEdges());
var childCount = neighborEdges.length;
if (parentOfNode != null) {
childCount--;
}
var branchCount = 0;
var incEdgesCount = neighborEdges.length;
var startIndex;
var edges = node.getEdgesBetween(parentOfNode);
// If there are multiple edges, prune them until there remains only one
// edge.
while (edges.length > 1) {
//neighborEdges.remove(edges.remove(0));
var temp = edges[0];
edges.splice(0, 1);
var index = neighborEdges.indexOf(temp);
if (index >= 0) {
neighborEdges.splice(index, 1);
}
incEdgesCount--;
childCount--;
}
if (parentOfNode != null) {
//assert edges.length == 1;
startIndex = (neighborEdges.indexOf(edges[0]) + 1) % incEdgesCount;
} else {
startIndex = 0;
}
var stepAngle = Math.abs(endAngle - startAngle) / childCount;
for (var i = startIndex; branchCount != childCount; i = ++i % incEdgesCount) {
var currentNeighbor = neighborEdges[i].getOtherEnd(node);
// Don't back traverse to root node in current tree.
if (currentNeighbor == parentOfNode) {
continue;
}
var childStartAngle = (startAngle + branchCount * stepAngle) % 360;
var childEndAngle = (childStartAngle + stepAngle) % 360;
CoSELayout.branchRadialLayout(currentNeighbor, node, childStartAngle, childEndAngle, distance + radialSeparation, radialSeparation);
branchCount++;
}
};
CoSELayout.maxDiagonalInTree = function (tree) {
var maxDiagonal = Integer.MIN_VALUE;
for (var i = 0; i < tree.length; i++) {
var node = tree[i];
var diagonal = node.getDiagonal();
if (diagonal > maxDiagonal) {
maxDiagonal = diagonal;
}
}
return maxDiagonal;
};
CoSELayout.prototype.calcRepulsionRange = function () {
// formula is 2 x (level + 1) x idealEdgeLength
return 2 * (this.level + 1) * this.idealEdgeLength;
};
// Tiling methods
// Group zero degree members whose parents are not to be tiled, create dummy parents where needed and fill memberGroups by their dummp parent id's
CoSELayout.prototype.groupZeroDegreeMembers = function () {
var self = this;
// array of [parent_id x oneDegreeNode_id]
var tempMemberGroups = {}; // A temporary map of parent node and its zero degree members
this.memberGroups = {}; // A map of dummy parent node and its zero degree members whose parents are not to be tiled
this.idToDummyNode = {}; // A map of id to dummy node
var zeroDegree = []; // List of zero degree nodes whose parents are not to be tiled
var allNodes = this.graphManager.getAllNodes();
// Fill zero degree list
for (var i = 0; i < allNodes.length; i++) {
var node = allNodes[i];
var parent = node.getParent();
// If a node has zero degree and its parent is not to be tiled if exists add that node to zeroDegres list
if (this.getNodeDegreeWithChildren(node) === 0 && (parent.id == undefined || !this.getToBeTiled(parent))) {
zeroDegree.push(node);
}
}
// Create a map of parent node and its zero degree members
for (var i = 0; i < zeroDegree.length; i++) {
var node = zeroDegree[i]; // Zero degree node itself
var p_id = node.getParent().id; // Parent id
if (typeof tempMemberGroups[p_id] === "undefined") tempMemberGroups[p_id] = [];
tempMemberGroups[p_id] = tempMemberGroups[p_id].concat(node); // Push node to the list belongs to its parent in tempMemberGroups
}
// If there are at least two nodes at a level, create a dummy compound for them
Object.keys(tempMemberGroups).forEach(function (p_id) {
if (tempMemberGroups[p_id].length > 1) {
var dummyCompoundId = "DummyCompound_" + p_id; // The id of dummy compound which will be created soon
self.memberGroups[dummyCompoundId] = tempMemberGroups[p_id]; // Add dummy compound to memberGroups
var parent = tempMemberGroups[p_id][0].getParent(); // The parent of zero degree nodes will be the parent of new dummy compound
// Create a dummy compound with calculated id
var dummyCompound = new CoSENode(self.graphManager);
dummyCompound.id = dummyCompoundId;
dummyCompound.paddingLeft = parent.paddingLeft || 0;
dummyCompound.paddingRight = parent.paddingRight || 0;
dummyCompound.paddingBottom = parent.paddingBottom || 0;
dummyCompound.paddingTop = parent.paddingTop || 0;
self.idToDummyNode[dummyCompoundId] = dummyCompound;
var dummyParentGraph = self.getGraphManager().add(self.newGraph(), dummyCompound);
var parentGraph = parent.getChild();
// Add dummy compound to parent the graph
parentGraph.add(dummyCompound);
// For each zero degree node in this level remove it from its parent graph and add it to the graph of dummy parent
for (var i = 0; i < tempMemberGroups[p_id].length; i++) {
var node = tempMemberGroups[p_id][i];
parentGraph.remove(node);
dummyParentGraph.add(node);
}
}
});
};
CoSELayout.prototype.clearCompounds = function () {
var childGraphMap = {};
var idToNode = {};
// Get compound ordering by finding the inner one first
this.performDFSOnCompounds();
for (var i = 0; i < this.compoundOrder.length; i++) {
idToNode[this.compoundOrder[i].id] = this.compoundOrder[i];
childGraphMap[this.compoundOrder[i].id] = [].concat(this.compoundOrder[i].getChild().getNodes());
// Remove children of compounds
this.graphManager.remove(this.compoundOrder[i].getChild());
this.compoundOrder[i].child = null;
}
this.graphManager.resetAllNodes();
// Tile the removed children
this.tileCompoundMembers(childGraphMap, idToNode);
};
CoSELayout.prototype.clearZeroDegreeMembers = function () {
var self = this;
var tiledZeroDegreePack = this.tiledZeroDegreePack = [];
Object.keys(this.memberGroups).forEach(function (id) {
var compoundNode = self.idToDummyNode[id]; // Get the dummy compound
tiledZeroDegreePack[id] = self.tileNodes(self.memberGroups[id], compoundNode.paddingLeft + compoundNode.paddingRight);
// Set the width and height of the dummy compound as calculated
compoundNode.rect.width = tiledZeroDegreePack[id].width;
compoundNode.rect.height = tiledZeroDegreePack[id].height;
});
};
CoSELayout.prototype.repopulateCompounds = function () {
for (var i = this.compoundOrder.length - 1; i >= 0; i--) {
var lCompoundNode = this.compoundOrder[i];
var id = lCompoundNode.id;
var horizontalMargin = lCompoundNode.paddingLeft;
var verticalMargin = lCompoundNode.paddingTop;
this.adjustLocations(this.tiledMemberPack[id], lCompoundNode.rect.x, lCompoundNode.rect.y, horizontalMargin, verticalMargin);
}
};
CoSELayout.prototype.repopulateZeroDegreeMembers = function () {
var self = this;
var tiledPack = this.tiledZeroDegreePack;
Object.keys(tiledPack).forEach(function (id) {
var compoundNode = self.idToDummyNode[id]; // Get the dummy compound by its id
var horizontalMargin = compoundNode.paddingLeft;
var verticalMargin = compoundNode.paddingTop;
// Adjust the positions of nodes wrt its compound
self.adjustLocations(tiledPack[id], compoundNode.rect.x, compoundNode.rect.y, horizontalMargin, verticalMargin);
});
};
CoSELayout.prototype.getToBeTiled = function (node) {
var id = node.id;
//firstly check the previous results
if (this.toBeTiled[id] != null) {
return this.toBeTiled[id];
}
//only compound nodes are to be tiled
var childGraph = node.getChild();
if (childGraph == null) {
this.toBeTiled[id] = false;
return false;
}
var children = childGraph.getNodes(); // Get the children nodes
//a compound node is not to be tiled if all of its compound children are not to be tiled
for (var i = 0; i < children.length; i++) {
var theChild = children[i];
if (this.getNodeDegree(theChild) > 0) {
this.toBeTiled[id] = false;
return false;
}
//pass the children not having the compound structure
if (theChild.getChild() == null) {
this.toBeTiled[theChild.id] = false;
continue;
}
if (!this.getToBeTiled(theChild)) {
this.toBeTiled[id] = false;
return false;
}
}
this.toBeTiled[id] = true;
return true;
};
// Get degree of a node depending of its edges and independent of its children
CoSELayout.prototype.getNodeDegree = function (node) {
var id = node.id;
var edges = node.getEdges();
var degree = 0;
// For the edges connected
for (var i = 0; i < edges.length; i++) {
var edge = edges[i];
if (edge.getSource().id !== edge.getTarget().id) {
degree = degree + 1;
}
}
return degree;
};
// Get degree of a node with its children
CoSELayout.prototype.getNodeDegreeWithChildren = function (node) {
var degree = this.getNodeDegree(node);
if (node.getChild() == null) {
return degree;
}
var children = node.getChild().getNodes();
for (var i = 0; i < children.length; i++) {
var child = children[i];
degree += this.getNodeDegreeWithChildren(child);
}
return degree;
};
CoSELayout.prototype.performDFSOnCompounds = function () {
this.compoundOrder = [];
this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes());
};
CoSELayout.prototype.fillCompexOrderByDFS = function (children) {
for (var i = 0; i < children.length; i++) {
var child = children[i];
if (child.getChild() != null) {
this.fillCompexOrderByDFS(child.getChild().getNodes());
}
if (this.getToBeTiled(child)) {
this.compoundOrder.push(child);
}
}
};
/**
* This method places each zero degree member wrt given (x,y) coordinates (top left).
*/
CoSELayout.prototype.adjustLocations = function (organization, x, y, compoundHorizontalMargin, compoundVerticalMargin) {
x += compoundHorizontalMargin;
y += compoundVerticalMargin;
var left = x;
for (var i = 0; i < organization.rows.length; i++) {
var row = organization.rows[i];
x = left;
var maxHeight = 0;
for (var j = 0; j < row.length; j++) {
var lnode = row[j];
lnode.rect.x = x; // + lnode.rect.width / 2;
lnode.rect.y = y; // + lnode.rect.height / 2;
x += lnode.rect.width + organization.horizontalPadding;
if (lnode.rect.height > maxHeight) maxHeight = lnode.rect.height;
}
y += maxHeight + organization.verticalPadding;
}
};
CoSELayout.prototype.tileCompoundMembers = function (childGraphMap, idToNode) {
var self = this;
this.tiledMemberPack = [];
Object.keys(childGraphMap).forEach(function (id) {
// Get the compound node
var compoundNode = idToNode[id];
self.tiledMemberPack[id] = self.tileN