ccnetviz
Version:
[](https://travis-ci.org/HelikarLab/ccNetViz) [](https://www.gnu.org/licenses/gpl-3.0) [![semantic-releas
1,883 lines (1,473 loc) • 786 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define([], factory);
else if(typeof exports === 'object')
exports["cytoscape"] = factory();
else
root["cytoscape"] = factory();
})(typeof self !== 'undefined' ? self : this, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(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, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, {
/******/ configurable: false,
/******/ enumerable: true,
/******/ get: getter
/******/ });
/******/ }
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 20);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/*global HTMLElement DocumentTouch */
var window = __webpack_require__(3);
var navigator = window ? window.navigator : null;
var document = window ? window.document : null;
var typeofstr = _typeof('');
var typeofobj = _typeof({});
var typeoffn = _typeof(function () {});
var typeofhtmlele = typeof HTMLElement === 'undefined' ? 'undefined' : _typeof(HTMLElement);
var instanceStr = function instanceStr(obj) {
return obj && obj.instanceString && is.fn(obj.instanceString) ? obj.instanceString() : null;
};
var is = {
defined: function defined(obj) {
return obj != null; // not undefined or null
},
string: function string(obj) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) == typeofstr;
},
fn: function fn(obj) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === typeoffn;
},
array: function array(obj) {
return Array.isArray ? Array.isArray(obj) : obj != null && obj instanceof Array;
},
plainObject: function plainObject(obj) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === typeofobj && !is.array(obj) && obj.constructor === Object;
},
object: function object(obj) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === typeofobj;
},
number: function number(obj) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === _typeof(1) && !isNaN(obj);
},
integer: function integer(obj) {
return is.number(obj) && Math.floor(obj) === obj;
},
bool: function bool(obj) {
return obj != null && (typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) === _typeof(true);
},
htmlElement: function htmlElement(obj) {
if ('undefined' === typeofhtmlele) {
return undefined;
} else {
return null != obj && obj instanceof HTMLElement;
}
},
elementOrCollection: function elementOrCollection(obj) {
return is.element(obj) || is.collection(obj);
},
element: function element(obj) {
return instanceStr(obj) === 'collection' && obj._private.single;
},
collection: function collection(obj) {
return instanceStr(obj) === 'collection' && !obj._private.single;
},
core: function core(obj) {
return instanceStr(obj) === 'core';
},
style: function style(obj) {
return instanceStr(obj) === 'style';
},
stylesheet: function stylesheet(obj) {
return instanceStr(obj) === 'stylesheet';
},
event: function event(obj) {
return instanceStr(obj) === 'event';
},
thread: function thread(obj) {
return instanceStr(obj) === 'thread';
},
fabric: function fabric(obj) {
return instanceStr(obj) === 'fabric';
},
emptyString: function emptyString(obj) {
if (obj === undefined || obj === null) {
// null is empty
return true;
} else if (obj === '' || obj.match(/^\s+$/)) {
return true; // empty string is empty
}
return false; // otherwise, we don't know what we've got
},
nonemptyString: function nonemptyString(obj) {
if (obj && is.string(obj) && obj !== '' && !obj.match(/^\s+$/)) {
return true;
}
return false;
},
domElement: function domElement(obj) {
if (typeof HTMLElement === 'undefined') {
return false; // we're not in a browser so it doesn't matter
} else {
return obj instanceof HTMLElement;
}
},
boundingBox: function boundingBox(obj) {
return is.plainObject(obj) && is.number(obj.x1) && is.number(obj.x2) && is.number(obj.y1) && is.number(obj.y2);
},
promise: function promise(obj) {
return is.object(obj) && is.fn(obj.then);
},
touch: function touch() {
return window && ('ontouchstart' in window || window.DocumentTouch && document instanceof DocumentTouch);
},
gecko: function gecko() {
return window && (typeof InstallTrigger !== 'undefined' || 'MozAppearance' in document.documentElement.style);
},
webkit: function webkit() {
return window && (typeof webkitURL !== 'undefined' || 'WebkitAppearance' in document.documentElement.style);
},
chromium: function chromium() {
return window && typeof chrome !== 'undefined';
},
khtml: function khtml() {
return navigator && navigator.vendor.match(/kde/i); // probably a better way to detect this...
},
khtmlEtc: function khtmlEtc() {
return is.khtml() || is.webkit() || is.chromium();
},
ms: function ms() {
return navigator && navigator.userAgent.match(/msie|trident|edge/i); // probably a better way to detect this...
},
windows: function windows() {
return navigator && navigator.appVersion.match(/Win/i);
},
mac: function mac() {
return navigator && navigator.appVersion.match(/Mac/i);
},
linux: function linux() {
return navigator && navigator.appVersion.match(/Linux/i);
},
unix: function unix() {
return navigator && navigator.appVersion.match(/X11/i);
}
};
module.exports = is;
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*global console */
var is = __webpack_require__(0);
var math = __webpack_require__(2);
var util = {
MAX_INT: Number.MAX_SAFE_INTEGER || 9007199254740991,
trueify: function trueify() {
return true;
},
falsify: function falsify() {
return false;
},
zeroify: function zeroify() {
return 0;
},
noop: function noop() {},
error: function error(msg) {
/* eslint-disable */
if (console.error) {
console.error.apply(console, arguments);
if (console.trace) {
console.trace();
}
} else {
console.log.apply(console, arguments);
if (console.trace) {
console.trace();
}
}
/* eslint-enable */
},
clone: function clone(obj) {
return this.extend({}, obj);
},
// gets a shallow copy of the argument
copy: function copy(obj) {
if (obj == null) {
return obj;
}if (is.array(obj)) {
return obj.slice();
} else if (is.plainObject(obj)) {
return this.clone(obj);
} else {
return obj;
}
},
copyArray: function copyArray(arr) {
return arr.slice();
},
clonePosition: function clonePosition(pos) {
return { x: pos.x, y: pos.y };
},
uuid: function uuid(a, b // placeholders
) {
for ( // loop :)
b = a = ''; // b - result , a - numeric letiable
a++ < 36; //
b += a * 51 & 52 // if "a" is not 9 or 14 or 19 or 24
? // return a random number or 4
(a ^ 15 // if "a" is not 15
? // genetate a random number from 0 to 15
8 ^ Math.random() * (a ^ 20 ? 16 : 4) // unless "a" is 20, in which case a random number from 8 to 11
: 4 // otherwise 4
).toString(16) : '-' // in other cases (if "a" is 9,14,19,24) insert "-"
) {}
return b;
}
};
util.makeBoundingBox = math.makeBoundingBox.bind(math);
util._staticEmptyObject = {};
util.staticEmptyObject = function () {
return util._staticEmptyObject;
};
util.extend = Object.assign != null ? Object.assign.bind(Object) : function (tgt) {
var args = arguments;
for (var i = 1; i < args.length; i++) {
var obj = args[i];
if (obj == null) {
continue;
}
var keys = Object.keys(obj);
for (var j = 0; j < keys.length; j++) {
var k = keys[j];
tgt[k] = obj[k];
}
}
return tgt;
};
util.assign = util.extend;
util.default = function (val, def) {
if (val === undefined) {
return def;
} else {
return val;
}
};
util.removeFromArray = function (arr, ele, manyCopies) {
for (var i = arr.length; i >= 0; i--) {
if (arr[i] === ele) {
arr.splice(i, 1);
if (!manyCopies) {
break;
}
}
}
};
util.clearArray = function (arr) {
arr.splice(0, arr.length);
};
util.push = function (arr, otherArr) {
for (var i = 0; i < otherArr.length; i++) {
var el = otherArr[i];
arr.push(el);
}
};
util.getPrefixedProperty = function (obj, propName, prefix) {
if (prefix) {
propName = this.prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth
}
return obj[propName];
};
util.setPrefixedProperty = function (obj, propName, prefix, value) {
if (prefix) {
propName = this.prependCamel(prefix, propName); // e.g. (labelWidth, source) => sourceLabelWidth
}
obj[propName] = value;
};
[__webpack_require__(21), __webpack_require__(22), { memoize: __webpack_require__(13) }, __webpack_require__(23), __webpack_require__(24), __webpack_require__(25), __webpack_require__(27)].forEach(function (req) {
util.extend(util, req);
});
module.exports = util;
/***/ }),
/* 2 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var math = {};
math.arePositionsSame = function (p1, p2) {
return p1.x === p2.x && p1.y === p2.y;
};
math.copyPosition = function (p) {
return { x: p.x, y: p.y };
};
math.modelToRenderedPosition = function (p, zoom, pan) {
return {
x: p.x * zoom + pan.x,
y: p.y * zoom + pan.y
};
};
math.renderedToModelPosition = function (p, zoom, pan) {
return {
x: (p.x - pan.x) / zoom,
y: (p.y - pan.y) / zoom
};
};
math.array2point = function (arr) {
return {
x: arr[0],
y: arr[1]
};
};
math.deg2rad = function (deg) {
return Math.PI * deg / 180;
};
math.getAngleFromDisp = function (dispX, dispY) {
return Math.atan2(dispY, dispX) - Math.PI / 2;
};
math.log2 = Math.log2 || function (n) {
return Math.log(n) / Math.log(2);
};
math.signum = function (x) {
if (x > 0) {
return 1;
} else if (x < 0) {
return -1;
} else {
return 0;
}
};
math.dist = function (p1, p2) {
return Math.sqrt(math.sqdist(p1, p2));
};
math.sqdist = function (p1, p2) {
var dx = p2.x - p1.x;
var dy = p2.y - p1.y;
return dx * dx + dy * dy;
};
// from http://en.wikipedia.org/wiki/Bézier_curve#Quadratic_curves
math.qbezierAt = function (p0, p1, p2, t) {
return (1 - t) * (1 - t) * p0 + 2 * (1 - t) * t * p1 + t * t * p2;
};
math.qbezierPtAt = function (p0, p1, p2, t) {
return {
x: math.qbezierAt(p0.x, p1.x, p2.x, t),
y: math.qbezierAt(p0.y, p1.y, p2.y, t)
};
};
math.lineAt = function (p0, p1, t, d) {
var vec = {
x: p1.x - p0.x,
y: p1.y - p0.y
};
var vecDist = math.dist(p0, p1);
var normVec = {
x: vec.x / vecDist,
y: vec.y / vecDist
};
t = t == null ? 0 : t;
d = d != null ? d : t * vecDist;
return {
x: p0.x + normVec.x * d,
y: p0.y + normVec.y * d
};
};
math.lineAtDist = function (p0, p1, d) {
return math.lineAt(p0, p1, undefined, d);
};
// get angle at A via cosine law
math.triangleAngle = function (A, B, C) {
var a = math.dist(B, C);
var b = math.dist(A, C);
var c = math.dist(A, B);
return Math.acos((a * a + b * b - c * c) / (2 * a * b));
};
math.bound = function (min, val, max) {
return Math.max(min, Math.min(max, val));
};
// makes a full bb (x1, y1, x2, y2, w, h) from implicit params
math.makeBoundingBox = function (bb) {
if (bb == null) {
return {
x1: Infinity,
y1: Infinity,
x2: -Infinity,
y2: -Infinity,
w: 0,
h: 0
};
} else if (bb.x1 != null && bb.y1 != null) {
if (bb.x2 != null && bb.y2 != null && bb.x2 >= bb.x1 && bb.y2 >= bb.y1) {
return {
x1: bb.x1,
y1: bb.y1,
x2: bb.x2,
y2: bb.y2,
w: bb.x2 - bb.x1,
h: bb.y2 - bb.y1
};
} else if (bb.w != null && bb.h != null && bb.w >= 0 && bb.h >= 0) {
return {
x1: bb.x1,
y1: bb.y1,
x2: bb.x1 + bb.w,
y2: bb.y1 + bb.h,
w: bb.w,
h: bb.h
};
}
}
};
math.updateBoundingBox = function (bb1, bb2) {
// update bb1 with bb2 bounds
bb1.x1 = Math.min(bb1.x1, bb2.x1);
bb1.x2 = Math.max(bb1.x2, bb2.x2);
bb1.w = bb1.x2 - bb1.x1;
bb1.y1 = Math.min(bb1.y1, bb2.y1);
bb1.y2 = Math.max(bb1.y2, bb2.y2);
bb1.h = bb1.y2 - bb1.y1;
};
math.expandBoundingBoxByPoint = function (bb, x, y) {
bb.x1 = Math.min(bb.x1, x);
bb.x2 = Math.max(bb.x2, x);
bb.w = bb.x2 - bb.x1;
bb.y1 = Math.min(bb.y1, y);
bb.y2 = Math.max(bb.y2, y);
bb.h = bb.y2 - bb.y1;
};
math.expandBoundingBox = function (bb, padding) {
bb.x1 -= padding;
bb.x2 += padding;
bb.y1 -= padding;
bb.y2 += padding;
bb.w = bb.x2 - bb.x1;
bb.h = bb.y2 - bb.y1;
return bb;
};
math.boundingBoxesIntersect = function (bb1, bb2) {
// case: one bb to right of other
if (bb1.x1 > bb2.x2) {
return false;
}
if (bb2.x1 > bb1.x2) {
return false;
}
// case: one bb to left of other
if (bb1.x2 < bb2.x1) {
return false;
}
if (bb2.x2 < bb1.x1) {
return false;
}
// case: one bb above other
if (bb1.y2 < bb2.y1) {
return false;
}
if (bb2.y2 < bb1.y1) {
return false;
}
// case: one bb below other
if (bb1.y1 > bb2.y2) {
return false;
}
if (bb2.y1 > bb1.y2) {
return false;
}
// otherwise, must have some overlap
return true;
};
math.inBoundingBox = function (bb, x, y) {
return bb.x1 <= x && x <= bb.x2 && bb.y1 <= y && y <= bb.y2;
};
math.pointInBoundingBox = function (bb, pt) {
return this.inBoundingBox(bb, pt.x, pt.y);
};
math.boundingBoxInBoundingBox = function (bb1, bb2) {
return math.inBoundingBox(bb1, bb2.x1, bb2.y1) && math.inBoundingBox(bb1, bb2.x2, bb2.y2);
};
math.roundRectangleIntersectLine = function (x, y, nodeX, nodeY, width, height, padding) {
var cornerRadius = this.getRoundRectangleRadius(width, height);
var halfWidth = width / 2;
var halfHeight = height / 2;
// Check intersections with straight line segments
var straightLineIntersections = void 0;
// Top segment, left to right
{
var topStartX = nodeX - halfWidth + cornerRadius - padding;
var topStartY = nodeY - halfHeight - padding;
var topEndX = nodeX + halfWidth - cornerRadius + padding;
var topEndY = topStartY;
straightLineIntersections = this.finiteLinesIntersect(x, y, nodeX, nodeY, topStartX, topStartY, topEndX, topEndY, false);
if (straightLineIntersections.length > 0) {
return straightLineIntersections;
}
}
// Right segment, top to bottom
{
var rightStartX = nodeX + halfWidth + padding;
var rightStartY = nodeY - halfHeight + cornerRadius - padding;
var rightEndX = rightStartX;
var rightEndY = nodeY + halfHeight - cornerRadius + padding;
straightLineIntersections = this.finiteLinesIntersect(x, y, nodeX, nodeY, rightStartX, rightStartY, rightEndX, rightEndY, false);
if (straightLineIntersections.length > 0) {
return straightLineIntersections;
}
}
// Bottom segment, left to right
{
var bottomStartX = nodeX - halfWidth + cornerRadius - padding;
var bottomStartY = nodeY + halfHeight + padding;
var bottomEndX = nodeX + halfWidth - cornerRadius + padding;
var bottomEndY = bottomStartY;
straightLineIntersections = this.finiteLinesIntersect(x, y, nodeX, nodeY, bottomStartX, bottomStartY, bottomEndX, bottomEndY, false);
if (straightLineIntersections.length > 0) {
return straightLineIntersections;
}
}
// Left segment, top to bottom
{
var leftStartX = nodeX - halfWidth - padding;
var leftStartY = nodeY - halfHeight + cornerRadius - padding;
var leftEndX = leftStartX;
var leftEndY = nodeY + halfHeight - cornerRadius + padding;
straightLineIntersections = this.finiteLinesIntersect(x, y, nodeX, nodeY, leftStartX, leftStartY, leftEndX, leftEndY, false);
if (straightLineIntersections.length > 0) {
return straightLineIntersections;
}
}
// Check intersections with arc segments
var arcIntersections = void 0;
// Top Left
{
var topLeftCenterX = nodeX - halfWidth + cornerRadius;
var topLeftCenterY = nodeY - halfHeight + cornerRadius;
arcIntersections = this.intersectLineCircle(x, y, nodeX, nodeY, topLeftCenterX, topLeftCenterY, cornerRadius + padding);
// Ensure the intersection is on the desired quarter of the circle
if (arcIntersections.length > 0 && arcIntersections[0] <= topLeftCenterX && arcIntersections[1] <= topLeftCenterY) {
return [arcIntersections[0], arcIntersections[1]];
}
}
// Top Right
{
var topRightCenterX = nodeX + halfWidth - cornerRadius;
var topRightCenterY = nodeY - halfHeight + cornerRadius;
arcIntersections = this.intersectLineCircle(x, y, nodeX, nodeY, topRightCenterX, topRightCenterY, cornerRadius + padding);
// Ensure the intersection is on the desired quarter of the circle
if (arcIntersections.length > 0 && arcIntersections[0] >= topRightCenterX && arcIntersections[1] <= topRightCenterY) {
return [arcIntersections[0], arcIntersections[1]];
}
}
// Bottom Right
{
var bottomRightCenterX = nodeX + halfWidth - cornerRadius;
var bottomRightCenterY = nodeY + halfHeight - cornerRadius;
arcIntersections = this.intersectLineCircle(x, y, nodeX, nodeY, bottomRightCenterX, bottomRightCenterY, cornerRadius + padding);
// Ensure the intersection is on the desired quarter of the circle
if (arcIntersections.length > 0 && arcIntersections[0] >= bottomRightCenterX && arcIntersections[1] >= bottomRightCenterY) {
return [arcIntersections[0], arcIntersections[1]];
}
}
// Bottom Left
{
var bottomLeftCenterX = nodeX - halfWidth + cornerRadius;
var bottomLeftCenterY = nodeY + halfHeight - cornerRadius;
arcIntersections = this.intersectLineCircle(x, y, nodeX, nodeY, bottomLeftCenterX, bottomLeftCenterY, cornerRadius + padding);
// Ensure the intersection is on the desired quarter of the circle
if (arcIntersections.length > 0 && arcIntersections[0] <= bottomLeftCenterX && arcIntersections[1] >= bottomLeftCenterY) {
return [arcIntersections[0], arcIntersections[1]];
}
}
return []; // if nothing
};
math.inLineVicinity = function (x, y, lx1, ly1, lx2, ly2, tolerance) {
var t = tolerance;
var x1 = Math.min(lx1, lx2);
var x2 = Math.max(lx1, lx2);
var y1 = Math.min(ly1, ly2);
var y2 = Math.max(ly1, ly2);
return x1 - t <= x && x <= x2 + t && y1 - t <= y && y <= y2 + t;
};
math.inBezierVicinity = function (x, y, x1, y1, x2, y2, x3, y3, tolerance) {
var bb = {
x1: Math.min(x1, x3, x2) - tolerance,
x2: Math.max(x1, x3, x2) + tolerance,
y1: Math.min(y1, y3, y2) - tolerance,
y2: Math.max(y1, y3, y2) + tolerance
};
// if outside the rough bounding box for the bezier, then it can't be a hit
if (x < bb.x1 || x > bb.x2 || y < bb.y1 || y > bb.y2) {
// console.log('bezier out of rough bb')
return false;
} else {
// console.log('do more expensive check');
return true;
}
};
math.solveQuadratic = function (a, b, c, val) {
c -= val;
var r = b * b - 4 * a * c;
if (r < 0) {
return [];
}
var sqrtR = Math.sqrt(r);
var denom = 2 * a;
var root1 = (-b + sqrtR) / denom;
var root2 = (-b - sqrtR) / denom;
return [root1, root2];
};
math.solveCubic = function (a, b, c, d, result) {
// Solves a cubic function, returns root in form [r1, i1, r2, i2, r3, i3], where
// r is the real component, i is the imaginary component
// An implementation of the Cardano method from the year 1545
// http://en.wikipedia.org/wiki/Cubic_function#The_nature_of_the_roots
b /= a;
c /= a;
d /= a;
var discriminant = void 0,
q = void 0,
r = void 0,
dum1 = void 0,
s = void 0,
t = void 0,
term1 = void 0,
r13 = void 0;
q = (3.0 * c - b * b) / 9.0;
r = -(27.0 * d) + b * (9.0 * c - 2.0 * (b * b));
r /= 54.0;
discriminant = q * q * q + r * r;
result[1] = 0;
term1 = b / 3.0;
if (discriminant > 0) {
s = r + Math.sqrt(discriminant);
s = s < 0 ? -Math.pow(-s, 1.0 / 3.0) : Math.pow(s, 1.0 / 3.0);
t = r - Math.sqrt(discriminant);
t = t < 0 ? -Math.pow(-t, 1.0 / 3.0) : Math.pow(t, 1.0 / 3.0);
result[0] = -term1 + s + t;
term1 += (s + t) / 2.0;
result[4] = result[2] = -term1;
term1 = Math.sqrt(3.0) * (-t + s) / 2;
result[3] = term1;
result[5] = -term1;
return;
}
result[5] = result[3] = 0;
if (discriminant === 0) {
r13 = r < 0 ? -Math.pow(-r, 1.0 / 3.0) : Math.pow(r, 1.0 / 3.0);
result[0] = -term1 + 2.0 * r13;
result[4] = result[2] = -(r13 + term1);
return;
}
q = -q;
dum1 = q * q * q;
dum1 = Math.acos(r / Math.sqrt(dum1));
r13 = 2.0 * Math.sqrt(q);
result[0] = -term1 + r13 * Math.cos(dum1 / 3.0);
result[2] = -term1 + r13 * Math.cos((dum1 + 2.0 * Math.PI) / 3.0);
result[4] = -term1 + r13 * Math.cos((dum1 + 4.0 * Math.PI) / 3.0);
return;
};
math.sqdistToQuadraticBezier = function (x, y, x1, y1, x2, y2, x3, y3) {
// Find minimum distance by using the minimum of the distance
// function between the given point and the curve
// This gives the coefficients of the resulting cubic equation
// whose roots tell us where a possible minimum is
// (Coefficients are divided by 4)
var a = 1.0 * x1 * x1 - 4 * x1 * x2 + 2 * x1 * x3 + 4 * x2 * x2 - 4 * x2 * x3 + x3 * x3 + y1 * y1 - 4 * y1 * y2 + 2 * y1 * y3 + 4 * y2 * y2 - 4 * y2 * y3 + y3 * y3;
var b = 1.0 * 9 * x1 * x2 - 3 * x1 * x1 - 3 * x1 * x3 - 6 * x2 * x2 + 3 * x2 * x3 + 9 * y1 * y2 - 3 * y1 * y1 - 3 * y1 * y3 - 6 * y2 * y2 + 3 * y2 * y3;
var c = 1.0 * 3 * x1 * x1 - 6 * x1 * x2 + x1 * x3 - x1 * x + 2 * x2 * x2 + 2 * x2 * x - x3 * x + 3 * y1 * y1 - 6 * y1 * y2 + y1 * y3 - y1 * y + 2 * y2 * y2 + 2 * y2 * y - y3 * y;
var d = 1.0 * x1 * x2 - x1 * x1 + x1 * x - x2 * x + y1 * y2 - y1 * y1 + y1 * y - y2 * y;
// debug("coefficients: " + a / a + ", " + b / a + ", " + c / a + ", " + d / a);
var roots = [];
// Use the cubic solving algorithm
this.solveCubic(a, b, c, d, roots);
var zeroThreshold = 0.0000001;
var params = [];
for (var index = 0; index < 6; index += 2) {
if (Math.abs(roots[index + 1]) < zeroThreshold && roots[index] >= 0 && roots[index] <= 1.0) {
params.push(roots[index]);
}
}
params.push(1.0);
params.push(0.0);
var minDistanceSquared = -1;
var curX = void 0,
curY = void 0,
distSquared = void 0;
for (var i = 0; i < params.length; i++) {
curX = Math.pow(1.0 - params[i], 2.0) * x1 + 2.0 * (1 - params[i]) * params[i] * x2 + params[i] * params[i] * x3;
curY = Math.pow(1 - params[i], 2.0) * y1 + 2 * (1.0 - params[i]) * params[i] * y2 + params[i] * params[i] * y3;
distSquared = Math.pow(curX - x, 2) + Math.pow(curY - y, 2);
// debug('distance for param ' + params[i] + ": " + Math.sqrt(distSquared));
if (minDistanceSquared >= 0) {
if (distSquared < minDistanceSquared) {
minDistanceSquared = distSquared;
}
} else {
minDistanceSquared = distSquared;
}
}
return minDistanceSquared;
};
math.sqdistToFiniteLine = function (x, y, x1, y1, x2, y2) {
var offset = [x - x1, y - y1];
var line = [x2 - x1, y2 - y1];
var lineSq = line[0] * line[0] + line[1] * line[1];
var hypSq = offset[0] * offset[0] + offset[1] * offset[1];
var dotProduct = offset[0] * line[0] + offset[1] * line[1];
var adjSq = dotProduct * dotProduct / lineSq;
if (dotProduct < 0) {
return hypSq;
}
if (adjSq > lineSq) {
return (x - x2) * (x - x2) + (y - y2) * (y - y2);
}
return hypSq - adjSq;
};
math.pointInsidePolygonPoints = function (x, y, points) {
var x1 = void 0,
y1 = void 0,
x2 = void 0,
y2 = void 0;
var y3 = void 0;
// Intersect with vertical line through (x, y)
var up = 0;
// let down = 0;
for (var i = 0; i < points.length / 2; i++) {
x1 = points[i * 2];
y1 = points[i * 2 + 1];
if (i + 1 < points.length / 2) {
x2 = points[(i + 1) * 2];
y2 = points[(i + 1) * 2 + 1];
} else {
x2 = points[(i + 1 - points.length / 2) * 2];
y2 = points[(i + 1 - points.length / 2) * 2 + 1];
}
if (x1 == x && x2 == x) {
// then ignore
} else if (x1 >= x && x >= x2 || x1 <= x && x <= x2) {
y3 = (x - x1) / (x2 - x1) * (y2 - y1) + y1;
if (y3 > y) {
up++;
}
// if( y3 < y ){
// down++;
// }
} else {
continue;
}
}
if (up % 2 === 0) {
return false;
} else {
return true;
}
};
math.pointInsidePolygon = function (x, y, basePoints, centerX, centerY, width, height, direction, padding) {
//let direction = arguments[6];
var transformedPoints = new Array(basePoints.length);
// Gives negative angle
var angle = void 0;
if (direction[0] != null) {
angle = Math.atan(direction[1] / direction[0]);
if (direction[0] < 0) {
angle = angle + Math.PI / 2;
} else {
angle = -angle - Math.PI / 2;
}
} else {
angle = direction;
}
var cos = Math.cos(-angle);
var sin = Math.sin(-angle);
// console.log("base: " + basePoints);
for (var i = 0; i < transformedPoints.length / 2; i++) {
transformedPoints[i * 2] = width / 2 * (basePoints[i * 2] * cos - basePoints[i * 2 + 1] * sin);
transformedPoints[i * 2 + 1] = height / 2 * (basePoints[i * 2 + 1] * cos + basePoints[i * 2] * sin);
transformedPoints[i * 2] += centerX;
transformedPoints[i * 2 + 1] += centerY;
}
var points = void 0;
if (padding > 0) {
var expandedLineSet = this.expandPolygon(transformedPoints, -padding);
points = this.joinLines(expandedLineSet);
} else {
points = transformedPoints;
}
return math.pointInsidePolygonPoints(x, y, points);
};
math.joinLines = function (lineSet) {
var vertices = new Array(lineSet.length / 2);
var currentLineStartX = void 0,
currentLineStartY = void 0,
currentLineEndX = void 0,
currentLineEndY = void 0;
var nextLineStartX = void 0,
nextLineStartY = void 0,
nextLineEndX = void 0,
nextLineEndY = void 0;
for (var i = 0; i < lineSet.length / 4; i++) {
currentLineStartX = lineSet[i * 4];
currentLineStartY = lineSet[i * 4 + 1];
currentLineEndX = lineSet[i * 4 + 2];
currentLineEndY = lineSet[i * 4 + 3];
if (i < lineSet.length / 4 - 1) {
nextLineStartX = lineSet[(i + 1) * 4];
nextLineStartY = lineSet[(i + 1) * 4 + 1];
nextLineEndX = lineSet[(i + 1) * 4 + 2];
nextLineEndY = lineSet[(i + 1) * 4 + 3];
} else {
nextLineStartX = lineSet[0];
nextLineStartY = lineSet[1];
nextLineEndX = lineSet[2];
nextLineEndY = lineSet[3];
}
var intersection = this.finiteLinesIntersect(currentLineStartX, currentLineStartY, currentLineEndX, currentLineEndY, nextLineStartX, nextLineStartY, nextLineEndX, nextLineEndY, true);
vertices[i * 2] = intersection[0];
vertices[i * 2 + 1] = intersection[1];
}
return vertices;
};
math.expandPolygon = function (points, pad) {
var expandedLineSet = new Array(points.length * 2);
var currentPointX = void 0,
currentPointY = void 0,
nextPointX = void 0,
nextPointY = void 0;
for (var i = 0; i < points.length / 2; i++) {
currentPointX = points[i * 2];
currentPointY = points[i * 2 + 1];
if (i < points.length / 2 - 1) {
nextPointX = points[(i + 1) * 2];
nextPointY = points[(i + 1) * 2 + 1];
} else {
nextPointX = points[0];
nextPointY = points[1];
}
// Current line: [currentPointX, currentPointY] to [nextPointX, nextPointY]
// Assume CCW polygon winding
var offsetX = nextPointY - currentPointY;
var offsetY = -(nextPointX - currentPointX);
// Normalize
var offsetLength = Math.sqrt(offsetX * offsetX + offsetY * offsetY);
var normalizedOffsetX = offsetX / offsetLength;
var normalizedOffsetY = offsetY / offsetLength;
expandedLineSet[i * 4] = currentPointX + normalizedOffsetX * pad;
expandedLineSet[i * 4 + 1] = currentPointY + normalizedOffsetY * pad;
expandedLineSet[i * 4 + 2] = nextPointX + normalizedOffsetX * pad;
expandedLineSet[i * 4 + 3] = nextPointY + normalizedOffsetY * pad;
}
return expandedLineSet;
};
math.intersectLineEllipse = function (x, y, centerX, centerY, ellipseWradius, ellipseHradius) {
var dispX = centerX - x;
var dispY = centerY - y;
dispX /= ellipseWradius;
dispY /= ellipseHradius;
var len = Math.sqrt(dispX * dispX + dispY * dispY);
var newLength = len - 1;
if (newLength < 0) {
return [];
}
var lenProportion = newLength / len;
return [(centerX - x) * lenProportion + x, (centerY - y) * lenProportion + y];
};
math.checkInEllipse = function (x, y, width, height, centerX, centerY, padding) {
x -= centerX;
y -= centerY;
x /= width / 2 + padding;
y /= height / 2 + padding;
return x * x + y * y <= 1;
};
// Returns intersections of increasing distance from line's start point
math.intersectLineCircle = function (x1, y1, x2, y2, centerX, centerY, radius) {
// Calculate d, direction vector of line
var d = [x2 - x1, y2 - y1]; // Direction vector of line
var f = [x1 - centerX, y1 - centerY];
var a = d[0] * d[0] + d[1] * d[1];
var b = 2 * (f[0] * d[0] + f[1] * d[1]);
var c = f[0] * f[0] + f[1] * f[1] - radius * radius;
var discriminant = b * b - 4 * a * c;
if (discriminant < 0) {
return [];
}
var t1 = (-b + Math.sqrt(discriminant)) / (2 * a);
var t2 = (-b - Math.sqrt(discriminant)) / (2 * a);
var tMin = Math.min(t1, t2);
var tMax = Math.max(t1, t2);
var inRangeParams = [];
if (tMin >= 0 && tMin <= 1) {
inRangeParams.push(tMin);
}
if (tMax >= 0 && tMax <= 1) {
inRangeParams.push(tMax);
}
if (inRangeParams.length === 0) {
return [];
}
var nearIntersectionX = inRangeParams[0] * d[0] + x1;
var nearIntersectionY = inRangeParams[0] * d[1] + y1;
if (inRangeParams.length > 1) {
if (inRangeParams[0] == inRangeParams[1]) {
return [nearIntersectionX, nearIntersectionY];
} else {
var farIntersectionX = inRangeParams[1] * d[0] + x1;
var farIntersectionY = inRangeParams[1] * d[1] + y1;
return [nearIntersectionX, nearIntersectionY, farIntersectionX, farIntersectionY];
}
} else {
return [nearIntersectionX, nearIntersectionY];
}
};
math.findCircleNearPoint = function (centerX, centerY, radius, farX, farY) {
var displacementX = farX - centerX;
var displacementY = farY - centerY;
var distance = Math.sqrt(displacementX * displacementX + displacementY * displacementY);
var unitDisplacementX = displacementX / distance;
var unitDisplacementY = displacementY / distance;
return [centerX + unitDisplacementX * radius, centerY + unitDisplacementY * radius];
};
math.findMaxSqDistanceToOrigin = function (points) {
var maxSqDistance = 0.000001;
var sqDistance = void 0;
for (var i = 0; i < points.length / 2; i++) {
sqDistance = points[i * 2] * points[i * 2] + points[i * 2 + 1] * points[i * 2 + 1];
if (sqDistance > maxSqDistance) {
maxSqDistance = sqDistance;
}
}
return maxSqDistance;
};
math.midOfThree = function (a, b, c) {
if (b <= a && a <= c || c <= a && a <= b) {
return a;
} else if (a <= b && b <= c || c <= b && b <= a) {
return b;
} else {
return c;
}
};
// (x1,y1)=>(x2,y2) intersect with (x3,y3)=>(x4,y4)
math.finiteLinesIntersect = function (x1, y1, x2, y2, x3, y3, x4, y4, infiniteLines) {
var dx13 = x1 - x3;
var dx21 = x2 - x1;
var dx43 = x4 - x3;
var dy13 = y1 - y3;
var dy21 = y2 - y1;
var dy43 = y4 - y3;
var ua_t = dx43 * dy13 - dy43 * dx13;
var ub_t = dx21 * dy13 - dy21 * dx13;
var u_b = dy43 * dx21 - dx43 * dy21;
if (u_b !== 0) {
var ua = ua_t / u_b;
var ub = ub_t / u_b;
var flptThreshold = 0.001;
var min = 0 - flptThreshold;
var max = 1 + flptThreshold;
if (min <= ua && ua <= max && min <= ub && ub <= max) {
return [x1 + ua * dx21, y1 + ua * dy21];
} else {
if (!infiniteLines) {
return [];
} else {
return [x1 + ua * dx21, y1 + ua * dy21];
}
}
} else {
if (ua_t === 0 || ub_t === 0) {
// Parallel, coincident lines. Check if overlap
// Check endpoint of second line
if (this.midOfThree(x1, x2, x4) === x4) {
return [x4, y4];
}
// Check start point of second line
if (this.midOfThree(x1, x2, x3) === x3) {
return [x3, y3];
}
// Endpoint of first line
if (this.midOfThree(x3, x4, x2) === x2) {
return [x2, y2];
}
return [];
} else {
// Parallel, non-coincident
return [];
}
}
};
// math.polygonIntersectLine( x, y, basePoints, centerX, centerY, width, height, padding )
// intersect a node polygon (pts transformed)
//
// math.polygonIntersectLine( x, y, basePoints, centerX, centerY )
// intersect the points (no transform)
math.polygonIntersectLine = function (x, y, basePoints, centerX, centerY, width, height, padding) {
var intersections = [];
var intersection = void 0;
var transformedPoints = new Array(basePoints.length);
var doTransform = true;
if (arguments.length === 5) {
doTransform = false;
}
var points = void 0;
if (doTransform) {
for (var i = 0; i < transformedPoints.length / 2; i++) {
transformedPoints[i * 2] = basePoints[i * 2] * width + centerX;
transformedPoints[i * 2 + 1] = basePoints[i * 2 + 1] * height + centerY;
}
if (padding > 0) {
var expandedLineSet = math.expandPolygon(transformedPoints, -padding);
points = math.joinLines(expandedLineSet);
} else {
points = transformedPoints;
}
} else {
points = basePoints;
}
var currentX = void 0,
currentY = void 0,
nextX = void 0,
nextY = void 0;
for (var _i = 0; _i < points.length / 2; _i++) {
currentX = points[_i * 2];
currentY = points[_i * 2 + 1];
if (_i < points.length / 2 - 1) {
nextX = points[(_i + 1) * 2];
nextY = points[(_i + 1) * 2 + 1];
} else {
nextX = points[0];
nextY = points[1];
}
intersection = this.finiteLinesIntersect(x, y, centerX, centerY, currentX, currentY, nextX, nextY);
if (intersection.length !== 0) {
intersections.push(intersection[0], intersection[1]);
}
}
return intersections;
};
math.shortenIntersection = function (intersection, offset, amount) {
var disp = [intersection[0] - offset[0], intersection[1] - offset[1]];
var length = Math.sqrt(disp[0] * disp[0] + disp[1] * disp[1]);
var lenRatio = (length - amount) / length;
if (lenRatio < 0) {
lenRatio = 0.00001;
}
return [offset[0] + lenRatio * disp[0], offset[1] + lenRatio * disp[1]];
};
math.generateUnitNgonPointsFitToSquare = function (sides, rotationRadians) {
var points = math.generateUnitNgonPoints(sides, rotationRadians);
points = math.fitPolygonToSquare(points);
return points;
};
math.fitPolygonToSquare = function (points) {
var x = void 0,
y = void 0;
var sides = points.length / 2;
var minX = Infinity,
minY = Infinity,
maxX = -Infinity,
maxY = -Infinity;
for (var i = 0; i < sides; i++) {
x = points[2 * i];
y = points[2 * i + 1];
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
}
// stretch factors
var sx = 2 / (maxX - minX);
var sy = 2 / (maxY - minY);
for (var _i2 = 0; _i2 < sides; _i2++) {
x = points[2 * _i2] = points[2 * _i2] * sx;
y = points[2 * _i2 + 1] = points[2 * _i2 + 1] * sy;
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
}
if (minY < -1) {
for (var _i3 = 0; _i3 < sides; _i3++) {
y = points[2 * _i3 + 1] = points[2 * _i3 + 1] + (-1 - minY);
}
}
return points;
};
math.generateUnitNgonPoints = function (sides, rotationRadians) {
var increment = 1.0 / sides * 2 * Math.PI;
var startAngle = sides % 2 === 0 ? Math.PI / 2.0 + increment / 2.0 : Math.PI / 2.0;
startAngle += rotationRadians;
var points = new Array(sides * 2);
var currentAngle = void 0;
for (var i = 0; i < sides; i++) {
currentAngle = i * increment + startAngle;
points[2 * i] = Math.cos(currentAngle); // x
points[2 * i + 1] = Math.sin(-currentAngle); // y
}
return points;
};
math.getRoundRectangleRadius = function (width, height) {
// Set the default radius, unless half of width or height is smaller than default
return Math.min(width / 4, height / 4, 8);
};
math.getCutRectangleCornerLength = function () {
return 8;
};
math.bezierPtsToQuadCoeff = function (p0, p1, p2) {
return [p0 - 2 * p1 + p2, 2 * (p1 - p0), p0];
};
math.getBarrelCurveConstants = function (width, height) {
// get curve width, height, and control point position offsets as a percentage of node height / width
return {
heightOffset: Math.min(15, 0.05 * height),
widthOffset: Math.min(100, 0.25 * width),
ctrlPtOffsetPct: 0.05
};
};
module.exports = math;
/***/ }),
/* 3 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
module.exports = typeof window === 'undefined' ? null : window; // eslint-disable-line no-undef
/***/ }),
/* 4 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
// use this module to cherry pick functions into your prototype
// (useful for functions shared between the core and collections, for example)
// e.g.
// let foo = define.foo({ /* params... */ })
var util = __webpack_require__(1);
var define = {};
[__webpack_require__(44), __webpack_require__(46), __webpack_require__(47)].forEach(function (m) {
util.assign(define, m);
});
module.exports = define;
/***/ }),
/* 5 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
/*!
Embeddable Minimum Strictly-Compliant Promises/A+ 1.1.1 Thenable
Copyright (c) 2013-2014 Ralf S. Engelschall (http://engelschall.com)
Licensed under The MIT License (http://opensource.org/licenses/MIT)
*/
/* promise states [Promises/A+ 2.1] */
var STATE_PENDING = 0; /* [Promises/A+ 2.1.1] */
var STATE_FULFILLED = 1; /* [Promises/A+ 2.1.2] */
var STATE_REJECTED = 2; /* [Promises/A+ 2.1.3] */
/* promise object constructor */
var api = function api(executor) {
/* optionally support non-constructor/plain-function call */
if (!(this instanceof api)) return new api(executor);
/* initialize object */
this.id = 'Thenable/1.0.7';
this.state = STATE_PENDING; /* initial state */
this.fulfillValue = undefined; /* initial value */ /* [Promises/A+ 1.3, 2.1.2.2] */
this.rejectReason = undefined; /* initial reason */ /* [Promises/A+ 1.5, 2.1.3.2] */
this.onFulfilled = []; /* initial handlers */
this.onRejected = []; /* initial handlers */
/* provide optional information-hiding proxy */
this.proxy = {
then: this.then.bind(this)
};
/* support optional executor function */
if (typeof executor === 'function') executor.call(this, this.fulfill.bind(this), this.reject.bind(this));
};
/* promise API methods */
api.prototype = {
/* promise resolving methods */
fulfill: function fulfill(value) {
return deliver(this, STATE_FULFILLED, 'fulfillValue', value);
},
reject: function reject(value) {
return deliver(this, STATE_REJECTED, 'rejectReason', value);
},
/* "The then Method" [Promises/A+ 1.1, 1.2, 2.2] */
then: function then(onFulfilled, onRejected) {
var curr = this;
var next = new api(); /* [Promises/A+ 2.2.7] */
curr.onFulfilled.push(resolver(onFulfilled, next, 'fulfill')); /* [Promises/A+ 2.2.2/2.2.6] */
curr.onRejected.push(resolver(onRejected, next, 'reject')); /* [Promises/A+ 2.2.3/2.2.6] */
execute(curr);
return next.proxy; /* [Promises/A+ 2.2.7, 3.3] */
}
};
/* deliver an action */
var deliver = function deliver(curr, state, name, value) {
if (curr.state === STATE_PENDING) {
curr.state = state; /* [Promises/A+ 2.1.2.1, 2.1.3.1] */
curr[name] = value; /* [Promises/A+ 2.1.2.2, 2.1.3.2] */
execute(curr);
}
return curr;
};
/* execute all handlers */
var execute = function execute(curr) {
if (curr.state === STATE_FULFILLED) execute_handlers(curr, 'onFulfilled', curr.fulfillValue);else if (curr.state === STATE_REJECTED) execute_handlers(curr, 'onRejected', curr.rejectReason);
};
/* execute particular set of handlers */
var execute_handlers = function execute_handlers(curr, name, value) {
/* global setImmediate: true */
/* global setTimeout: true */
/* short-circuit processing */
if (curr[name].length === 0) return;
/* iterate over all handlers, exactly once */
var handlers = curr[name];
curr[name] = []; /* [Promises/A+ 2.2.2.3, 2.2.3.3] */
var func = function func() {
for (var i = 0; i < handlers.length; i++) {
handlers[i](value);
} /* [Promises/A+ 2.2.5] */
};
/* execute procedure asynchronously */ /* [Promises/A+ 2.2.4, 3.1] */
if (typeof setImmediate === 'function') setImmediate(func);else setTimeout(func, 0);
};
/* generate a resolver function */
var resolver = function resolver(cb, next, method) {
return function (value) {
if (typeof cb !== 'function') /* [Promises/A+ 2.2.1, 2.2.7.3, 2.2.7.4] */
next[method].call(next, value); /* [Promises/A+ 2.2.7.3, 2.2.7.4] */
else {
var result;
try {
result = cb(value);
} /* [Promises/A+ 2.2.2.1, 2.2.3.1, 2.2.5, 3.2] */
catch (e) {
next.reject(e); /* [Promises/A+ 2.2.7.2] */
return;
}
resolve(next, result); /* [Promises/A+ 2.2.7.1] */
}
};
};
/* "Promise Resolution Procedure" */ /* [Promises/A+ 2.3] */
var resolve = function resolve(promise, x) {
/* sanity check arguments */ /* [Promises/A+ 2.3.1] */
if (promise === x || promise.proxy === x) {
promise.reject(new TypeError('cannot resolve promise with itself'));
return;
}
/* surgically check for a "then" method
(mainly to just call the "getter" of "then" only once) */
var then;
if ((typeof x === 'undefined' ? 'undefined' : _typeof(x)) === 'object' && x !== null || typeof x === 'function') {
try {
then = x.then;
} /* [Promises/A+ 2.3.3.1, 3.5] */
catch (e) {
promise.reject(e); /* [Promises/A+ 2.3.3.2] */
return;
}
}
/* handle own Thenables [Promises/A+ 2.3.2]
and similar "thenables" [Promises/A+ 2.3.3] */
if (typeof then === 'function') {
var resolved = false;
try {
/* call retrieved "then" method */ /* [Promises/A+ 2.3.3.3] */
then.call(x,
/* resolvePromise */ /* [Promises/A+ 2.3.3.3.1] */
function (y) {
if (resolved) return;resolved = true; /* [Promises/A+ 2.3.3.3.3] */
if (y === x) /* [Promises/A+ 3.6] */
promise.reject(new TypeError('circular thenable chain'));else resolve(promise, y);
},
/* rejectPromise */ /* [Promises/A+ 2.3.3.3.2] */
function (r) {
if (resolved) return;resolved = true; /* [Promises/A+ 2.3.3.3.3] */
promise.reject(r);
});
} catch (e) {
if (!resolved) /* [Promises/A+ 2.3.3.3.3] */
promise.reject(e); /* [Promises/A+ 2.3.3.3.4] */
}
return;
}
/* handle other values */
promise.fulfill(x); /* [Promises/A+ 2.3.4, 2.3.3.4] */
};
// so we always have Promise.all()
api.all = function (ps) {
return new api(function (resolveAll, rejectAll) {
var vals = new Array(ps.length);
var doneCount = 0;
var fulfill = function fulfill(i, val) {
vals[i] = val;
doneCount++;
if (doneCount === ps.length) {
resolveAll(vals);
}
};
for (var i = 0; i < ps.length; i++) {
(function (i) {
var p = ps[i];
var isPromise = p != null && p.then != null;
if (isPromise) {
p.then(function (val) {
fulfill(i, val);
}, function (err) {
rejectAll(err);
});
} else {
var val = p;
fulfill(i, val);
}
})(i);
}
});
};
api.resolve = function (val) {
return new api(function (resolve, reject) {
resolve(val);
});
};
api.reject = function (val) {
return new api(function (resolve, reject) {
reject(val);
});
};
module.exports = typeof Promise !== 'undefined' ? Promise : api; // eslint-disable-line no-undef
/***/ }),
/* 6 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var is = __webpack_require__(0);
var util = __webpack_require__(1);
var newQuery = __webpack_require__(10);
var Selector = function Selector(selector) {
var self = this;
self._private = {
selectorText: selector,
invalid: true
};
if (selector == null || is.string(selector) && selector.match(/^\s*$/)) {
self.length = 0;
} else if (selector === '*' || selector === 'edge' || selector === 'node') {
// make single, group-only selectors cheap to make and cheap to filter
self[0] = newQuery();
self[0].group = selector === '*' ? selector : selector + 's';
self[0].groupOnly = true;
self[0].length = 1;
self._private.invalid = false;
self.length = 1;
} else if (is.elementOrCollection(selector)) {
var collection = selector.collection();
self[0] = newQuery();
self[0].collection = collection;
self[0].length = 1;
self.length = 1;
} else if (is.fn(selector)) {
self[0] = newQuery();
self[0].filter = selector;
self[0].length = 1;
self.length = 1;
} else if (is.string(selector)) {
if (!self.parse(selector)) {
return;
}
} else {
util.error('A selector must be created from a string; found ', selector);
return;
}
self._private.invalid = false;
};
var selfn = Selector.prototype;
selfn.valid = function () {
return !this._private.invalid;
};
selfn.invalid = function () {
return this._private.invalid;
};
selfn.text = function () {
return this._private.selectorText;
};
selfn.size = function () {
return this.length;
};
selfn.eq = function (i) {
return this[i];
};
selfn.sameText = function (otherSel) {
return this.text() === otherSel.text();
};
selfn.toString = selfn.selector = function () {
if (this._private.toStringCache != null) {
return this._private.toStringCache;
}
var i = void 0;
var str = '';
var clean = function clean(obj) {
if (obj == null) {
return '';
} else {
return obj;
}
};
var cleanVal = function cleanVal(val) {
if (is.string(val)) {
return '"' + val + '"';
} else {
return clean(val);
}
};
var space = function space(val) {
retu