mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
21921 lines
1.8 MiB
21921 lines
1.8 MiB
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
/**
|
|
* @license
|
|
* Copyright (c) 2012-2013 Chris Pettitt
|
|
*
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
* in the Software without restriction, including without limitation the rights
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
* furnished to do so, subject to the following conditions:
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
* THE SOFTWARE.
|
|
*/
|
|
module.exports = {
|
|
graphlib: require("./lib/graphlib"),
|
|
dagre: require("./lib/dagre"),
|
|
intersect: require("./lib/intersect"),
|
|
render: require("./lib/render"),
|
|
util: require("./lib/util"),
|
|
version: require("./lib/version")
|
|
};
|
|
|
|
},{"./lib/dagre":8,"./lib/graphlib":9,"./lib/intersect":10,"./lib/render":25,"./lib/util":27,"./lib/version":28}],2:[function(require,module,exports){
|
|
var util = require("./util");
|
|
|
|
module.exports = {
|
|
"default": normal,
|
|
"normal": normal,
|
|
"vee": vee,
|
|
"undirected": undirected
|
|
};
|
|
|
|
function normal(parent, id, edge, type) {
|
|
var marker = parent.append("marker")
|
|
.attr("id", id)
|
|
.attr("viewBox", "0 0 10 10")
|
|
.attr("refX", 9)
|
|
.attr("refY", 5)
|
|
.attr("markerUnits", "strokeWidth")
|
|
.attr("markerWidth", 8)
|
|
.attr("markerHeight", 6)
|
|
.attr("orient", "auto");
|
|
|
|
var path = marker.append("path")
|
|
.attr("d", "M 0 0 L 10 5 L 0 10 z")
|
|
.style("stroke-width", 1)
|
|
.style("stroke-dasharray", "1,0");
|
|
util.applyStyle(path, edge[type + "Style"]);
|
|
}
|
|
|
|
function vee(parent, id, edge, type) {
|
|
var marker = parent.append("marker")
|
|
.attr("id", id)
|
|
.attr("viewBox", "0 0 10 10")
|
|
.attr("refX", 9)
|
|
.attr("refY", 5)
|
|
.attr("markerUnits", "strokeWidth")
|
|
.attr("markerWidth", 8)
|
|
.attr("markerHeight", 6)
|
|
.attr("orient", "auto");
|
|
|
|
var path = marker.append("path")
|
|
.attr("d", "M 0 0 L 10 5 L 0 10 L 4 5 z")
|
|
.style("stroke-width", 1)
|
|
.style("stroke-dasharray", "1,0");
|
|
util.applyStyle(path, edge[type + "Style"]);
|
|
}
|
|
|
|
function undirected(parent, id, edge, type) {
|
|
var marker = parent.append("marker")
|
|
.attr("id", id)
|
|
.attr("viewBox", "0 0 10 10")
|
|
.attr("refX", 9)
|
|
.attr("refY", 5)
|
|
.attr("markerUnits", "strokeWidth")
|
|
.attr("markerWidth", 8)
|
|
.attr("markerHeight", 6)
|
|
.attr("orient", "auto");
|
|
|
|
var path = marker.append("path")
|
|
.attr("d", "M 0 5 L 10 5")
|
|
.style("stroke-width", 1)
|
|
.style("stroke-dasharray", "1,0");
|
|
util.applyStyle(path, edge[type + "Style"]);
|
|
}
|
|
|
|
},{"./util":27}],3:[function(require,module,exports){
|
|
var util = require("./util"),
|
|
addLabel = require("./label/add-label");
|
|
|
|
module.exports = createClusters;
|
|
|
|
function createClusters(selection, g) {
|
|
var clusters = g.nodes().filter(function(v) { return util.isSubgraph(g, v); }),
|
|
svgClusters = selection.selectAll("g.cluster")
|
|
.data(clusters, function(v) { return v; });
|
|
|
|
svgClusters.selectAll("*").remove();
|
|
svgClusters.enter()
|
|
.append("g")
|
|
.attr("class", "cluster")
|
|
.attr("id",function(v){
|
|
var node = g.node(v);
|
|
return node.id;
|
|
})
|
|
.style("opacity", 0);
|
|
|
|
util.applyTransition(svgClusters, g)
|
|
.style("opacity", 1);
|
|
|
|
svgClusters.each(function(v) {
|
|
var node = g.node(v),
|
|
thisGroup = d3.select(this),
|
|
labelGroup = thisGroup.append("g").attr("class", "label");
|
|
d3.select(this).append("rect");
|
|
addLabel(labelGroup, node, node.clusterLabelPos);
|
|
});
|
|
|
|
svgClusters.selectAll("rect").each(function(c) {
|
|
var node = g.node(c);
|
|
var domCluster = d3.select(this);
|
|
util.applyStyle(domCluster, node.style);
|
|
});
|
|
|
|
util.applyTransition(svgClusters.exit(), g)
|
|
.style("opacity", 0)
|
|
.remove();
|
|
|
|
return svgClusters;
|
|
}
|
|
|
|
},{"./label/add-label":18,"./util":27}],4:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
addLabel = require("./label/add-label"),
|
|
util = require("./util"),
|
|
d3 = require("./d3");
|
|
|
|
module.exports = createEdgeLabels;
|
|
|
|
function createEdgeLabels(selection, g) {
|
|
var svgEdgeLabels = selection.selectAll("g.edgeLabel")
|
|
.data(g.edges(), function(e) { return util.edgeToId(e); })
|
|
.classed("update", true);
|
|
|
|
svgEdgeLabels.selectAll("*").remove();
|
|
svgEdgeLabels.enter()
|
|
.append("g")
|
|
.classed("edgeLabel", true)
|
|
.style("opacity", 0);
|
|
svgEdgeLabels.each(function(e) {
|
|
var edge = g.edge(e),
|
|
label = addLabel(d3.select(this), g.edge(e), 0, 0).classed("label", true),
|
|
bbox = label.node().getBBox();
|
|
|
|
if (edge.labelId) { label.attr("id", edge.labelId); }
|
|
if (!_.has(edge, "width")) { edge.width = bbox.width; }
|
|
if (!_.has(edge, "height")) { edge.height = bbox.height; }
|
|
});
|
|
|
|
util.applyTransition(svgEdgeLabels.exit(), g)
|
|
.style("opacity", 0)
|
|
.remove();
|
|
|
|
return svgEdgeLabels;
|
|
}
|
|
|
|
},{"./d3":7,"./label/add-label":18,"./lodash":21,"./util":27}],5:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
intersectNode = require("./intersect/intersect-node"),
|
|
util = require("./util"),
|
|
d3 = require("./d3");
|
|
|
|
module.exports = createEdgePaths;
|
|
|
|
function createEdgePaths(selection, g, arrows) {
|
|
var svgPaths = selection.selectAll("g.edgePath")
|
|
.data(g.edges(), function(e) { return util.edgeToId(e); })
|
|
.classed("update", true);
|
|
|
|
enter(svgPaths, g);
|
|
exit(svgPaths, g);
|
|
|
|
util.applyTransition(svgPaths, g)
|
|
.style("opacity", 1);
|
|
|
|
// Save DOM element in the path group, and set ID and class
|
|
svgPaths.each(function(e) {
|
|
var domEdge = d3.select(this);
|
|
var edge = g.edge(e);
|
|
edge.elem = this;
|
|
|
|
if (edge.id) {
|
|
domEdge.attr("id", edge.id);
|
|
}
|
|
|
|
util.applyClass(domEdge, edge["class"],
|
|
(domEdge.classed("update") ? "update " : "") + "edgePath");
|
|
});
|
|
|
|
svgPaths.selectAll("path.path")
|
|
.each(function(e) {
|
|
var edge = g.edge(e);
|
|
edge.arrowheadId = _.uniqueId("arrowhead");
|
|
|
|
var domEdge = d3.select(this)
|
|
.attr("marker-end", function() {
|
|
return "url(#" + edge.arrowheadId + ")";
|
|
})
|
|
.style("fill", "none");
|
|
|
|
util.applyTransition(domEdge, g)
|
|
.attr("d", function(e) { return calcPoints(g, e); });
|
|
|
|
util.applyStyle(domEdge, edge.style);
|
|
});
|
|
|
|
svgPaths.selectAll("defs *").remove();
|
|
svgPaths.selectAll("defs")
|
|
.each(function(e) {
|
|
var edge = g.edge(e),
|
|
arrowhead = arrows[edge.arrowhead];
|
|
arrowhead(d3.select(this), edge.arrowheadId, edge, "arrowhead");
|
|
});
|
|
|
|
return svgPaths;
|
|
}
|
|
|
|
function calcPoints(g, e) {
|
|
var edge = g.edge(e),
|
|
tail = g.node(e.v),
|
|
head = g.node(e.w),
|
|
points = edge.points.slice(1, edge.points.length - 1);
|
|
points.unshift(intersectNode(tail, points[0]));
|
|
points.push(intersectNode(head, points[points.length - 1]));
|
|
|
|
return createLine(edge, points);
|
|
}
|
|
|
|
function createLine(edge, points) {
|
|
var line = d3.svg.line()
|
|
.x(function(d) { return d.x; })
|
|
.y(function(d) { return d.y; });
|
|
|
|
if (_.has(edge, "lineInterpolate")) {
|
|
line.interpolate(edge.lineInterpolate);
|
|
}
|
|
|
|
if (_.has(edge, "lineTension")) {
|
|
line.tension(Number(edge.lineTension));
|
|
}
|
|
|
|
return line(points);
|
|
}
|
|
|
|
function getCoords(elem) {
|
|
var bbox = elem.getBBox(),
|
|
matrix = elem.getTransformToElement(elem.ownerSVGElement)
|
|
.translate(bbox.width / 2, bbox.height / 2);
|
|
return { x: matrix.e, y: matrix.f };
|
|
}
|
|
|
|
function enter(svgPaths, g) {
|
|
var svgPathsEnter = svgPaths.enter()
|
|
.append("g")
|
|
.attr("class", "edgePath")
|
|
.style("opacity", 0);
|
|
svgPathsEnter.append("path")
|
|
.attr("class", "path")
|
|
.attr("d", function(e) {
|
|
var edge = g.edge(e),
|
|
sourceElem = g.node(e.v).elem,
|
|
points = _.range(edge.points.length).map(function() { return getCoords(sourceElem); });
|
|
return createLine(edge, points);
|
|
});
|
|
svgPathsEnter.append("defs");
|
|
}
|
|
|
|
function exit(svgPaths, g) {
|
|
var svgPathExit = svgPaths.exit();
|
|
util.applyTransition(svgPathExit, g)
|
|
.style("opacity", 0)
|
|
.remove();
|
|
|
|
util.applyTransition(svgPathExit.select("path.path"), g)
|
|
.attr("d", function(e) {
|
|
var source = g.node(e.v);
|
|
|
|
if (source) {
|
|
var points = _.range(this.pathSegList.length).map(function() { return source; });
|
|
return createLine({}, points);
|
|
} else {
|
|
return d3.select(this).attr("d");
|
|
}
|
|
});
|
|
}
|
|
|
|
},{"./d3":7,"./intersect/intersect-node":14,"./lodash":21,"./util":27}],6:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
addLabel = require("./label/add-label"),
|
|
util = require("./util"),
|
|
d3 = require("./d3");
|
|
|
|
module.exports = createNodes;
|
|
|
|
function createNodes(selection, g, shapes) {
|
|
var simpleNodes = g.nodes().filter(function(v) { return !util.isSubgraph(g, v); });
|
|
var svgNodes = selection.selectAll("g.node")
|
|
.data(simpleNodes, function(v) { return v; })
|
|
.classed("update", true);
|
|
|
|
svgNodes.selectAll("*").remove();
|
|
svgNodes.enter()
|
|
.append("g")
|
|
.attr("class", "node")
|
|
.style("opacity", 0);
|
|
svgNodes.each(function(v) {
|
|
var node = g.node(v),
|
|
thisGroup = d3.select(this),
|
|
labelGroup = thisGroup.append("g").attr("class", "label"),
|
|
labelDom = addLabel(labelGroup, node),
|
|
shape = shapes[node.shape],
|
|
bbox = _.pick(labelDom.node().getBBox(), "width", "height");
|
|
|
|
node.elem = this;
|
|
|
|
if (node.id) { thisGroup.attr("id", node.id); }
|
|
if (node.labelId) { labelGroup.attr("id", node.labelId); }
|
|
util.applyClass(thisGroup, node["class"],
|
|
(thisGroup.classed("update") ? "update " : "") + "node");
|
|
|
|
if (_.has(node, "width")) { bbox.width = node.width; }
|
|
if (_.has(node, "height")) { bbox.height = node.height; }
|
|
|
|
bbox.width += node.paddingLeft + node.paddingRight;
|
|
bbox.height += node.paddingTop + node.paddingBottom;
|
|
labelGroup.attr("transform", "translate(" +
|
|
((node.paddingLeft - node.paddingRight) / 2) + "," +
|
|
((node.paddingTop - node.paddingBottom) / 2) + ")");
|
|
|
|
var shapeSvg = shape(d3.select(this), bbox, node);
|
|
util.applyStyle(shapeSvg, node.style);
|
|
|
|
var shapeBBox = shapeSvg.node().getBBox();
|
|
node.width = shapeBBox.width;
|
|
node.height = shapeBBox.height;
|
|
});
|
|
|
|
util.applyTransition(svgNodes.exit(), g)
|
|
.style("opacity", 0)
|
|
.remove();
|
|
|
|
return svgNodes;
|
|
}
|
|
|
|
},{"./d3":7,"./label/add-label":18,"./lodash":21,"./util":27}],7:[function(require,module,exports){
|
|
// Stub to get D3 either via NPM or from the global object
|
|
module.exports = window.d3;
|
|
|
|
},{}],8:[function(require,module,exports){
|
|
/* global window */
|
|
|
|
var dagre;
|
|
|
|
if (require) {
|
|
try {
|
|
dagre = require("dagre");
|
|
} catch (e) {}
|
|
}
|
|
|
|
if (!dagre) {
|
|
dagre = window.dagre;
|
|
}
|
|
|
|
module.exports = dagre;
|
|
|
|
},{"dagre":29}],9:[function(require,module,exports){
|
|
/* global window */
|
|
|
|
var graphlib;
|
|
|
|
if (require) {
|
|
try {
|
|
graphlib = require("graphlib");
|
|
} catch (e) {}
|
|
}
|
|
|
|
if (!graphlib) {
|
|
graphlib = window.graphlib;
|
|
}
|
|
|
|
module.exports = graphlib;
|
|
|
|
},{"graphlib":59}],10:[function(require,module,exports){
|
|
module.exports = {
|
|
node: require("./intersect-node"),
|
|
circle: require("./intersect-circle"),
|
|
ellipse: require("./intersect-ellipse"),
|
|
polygon: require("./intersect-polygon"),
|
|
rect: require("./intersect-rect")
|
|
};
|
|
|
|
},{"./intersect-circle":11,"./intersect-ellipse":12,"./intersect-node":14,"./intersect-polygon":15,"./intersect-rect":16}],11:[function(require,module,exports){
|
|
var intersectEllipse = require("./intersect-ellipse");
|
|
|
|
module.exports = intersectCircle;
|
|
|
|
function intersectCircle(node, rx, point) {
|
|
return intersectEllipse(node, rx, rx, point);
|
|
}
|
|
|
|
},{"./intersect-ellipse":12}],12:[function(require,module,exports){
|
|
module.exports = intersectEllipse;
|
|
|
|
function intersectEllipse(node, rx, ry, point) {
|
|
// Formulae from: http://mathworld.wolfram.com/Ellipse-LineIntersection.html
|
|
|
|
var cx = node.x;
|
|
var cy = node.y;
|
|
|
|
var px = cx - point.x;
|
|
var py = cy - point.y;
|
|
|
|
var det = Math.sqrt(rx * rx * py * py + ry * ry * px * px);
|
|
|
|
var dx = Math.abs(rx * ry * px / det);
|
|
if (point.x < cx) {
|
|
dx = -dx;
|
|
}
|
|
var dy = Math.abs(rx * ry * py / det);
|
|
if (point.y < cy) {
|
|
dy = -dy;
|
|
}
|
|
|
|
return {x: cx + dx, y: cy + dy};
|
|
}
|
|
|
|
|
|
},{}],13:[function(require,module,exports){
|
|
module.exports = intersectLine;
|
|
|
|
/*
|
|
* Returns the point at which two lines, p and q, intersect or returns
|
|
* undefined if they do not intersect.
|
|
*/
|
|
function intersectLine(p1, p2, q1, q2) {
|
|
// Algorithm from J. Avro, (ed.) Graphics Gems, No 2, Morgan Kaufmann, 1994,
|
|
// p7 and p473.
|
|
|
|
var a1, a2, b1, b2, c1, c2;
|
|
var r1, r2 , r3, r4;
|
|
var denom, offset, num;
|
|
var x, y;
|
|
|
|
// Compute a1, b1, c1, where line joining points 1 and 2 is F(x,y) = a1 x +
|
|
// b1 y + c1 = 0.
|
|
a1 = p2.y - p1.y;
|
|
b1 = p1.x - p2.x;
|
|
c1 = (p2.x * p1.y) - (p1.x * p2.y);
|
|
|
|
// Compute r3 and r4.
|
|
r3 = ((a1 * q1.x) + (b1 * q1.y) + c1);
|
|
r4 = ((a1 * q2.x) + (b1 * q2.y) + c1);
|
|
|
|
// Check signs of r3 and r4. If both point 3 and point 4 lie on
|
|
// same side of line 1, the line segments do not intersect.
|
|
if ((r3 !== 0) && (r4 !== 0) && sameSign(r3, r4)) {
|
|
return /*DONT_INTERSECT*/;
|
|
}
|
|
|
|
// Compute a2, b2, c2 where line joining points 3 and 4 is G(x,y) = a2 x + b2 y + c2 = 0
|
|
a2 = q2.y - q1.y;
|
|
b2 = q1.x - q2.x;
|
|
c2 = (q2.x * q1.y) - (q1.x * q2.y);
|
|
|
|
// Compute r1 and r2
|
|
r1 = (a2 * p1.x) + (b2 * p1.yy) + c2;
|
|
r2 = (a2 * p2.x) + (b2 * p2.y) + c2;
|
|
|
|
// Check signs of r1 and r2. If both point 1 and point 2 lie
|
|
// on same side of second line segment, the line segments do
|
|
// not intersect.
|
|
if ((r1 !== 0) && (r2 !== 0) && (sameSign(r1, r2))) {
|
|
return /*DONT_INTERSECT*/;
|
|
}
|
|
|
|
// Line segments intersect: compute intersection point.
|
|
denom = (a1 * b2) - (a2 * b1);
|
|
if (denom === 0) {
|
|
return /*COLLINEAR*/;
|
|
}
|
|
|
|
offset = Math.abs(denom / 2);
|
|
|
|
// The denom/2 is to get rounding instead of truncating. It
|
|
// is added or subtracted to the numerator, depending upon the
|
|
// sign of the numerator.
|
|
num = (b1 * c2) - (b2 * c1);
|
|
x = (num < 0) ? ((num - offset) / denom) : ((num + offset) / denom);
|
|
|
|
num = (a2 * c1) - (a1 * c2);
|
|
y = (num < 0) ? ((num - offset) / denom) : ((num + offset) / denom);
|
|
|
|
return { x: x, y: y };
|
|
}
|
|
|
|
function sameSign(r1, r2) {
|
|
return r1 * r2 > 0;
|
|
}
|
|
|
|
},{}],14:[function(require,module,exports){
|
|
module.exports = intersectNode;
|
|
|
|
function intersectNode(node, point) {
|
|
return node.intersect(point);
|
|
}
|
|
|
|
},{}],15:[function(require,module,exports){
|
|
var intersectLine = require("./intersect-line");
|
|
|
|
module.exports = intersectPolygon;
|
|
|
|
/*
|
|
* Returns the point ({x, y}) at which the point argument intersects with the
|
|
* node argument assuming that it has the shape specified by polygon.
|
|
*/
|
|
function intersectPolygon(node, polyPoints, point) {
|
|
var x1 = node.x;
|
|
var y1 = node.y;
|
|
|
|
var intersections = [];
|
|
|
|
var minX = Number.POSITIVE_INFINITY,
|
|
minY = Number.POSITIVE_INFINITY;
|
|
polyPoints.forEach(function(entry) {
|
|
minX = Math.min(minX, entry.x);
|
|
minY = Math.min(minY, entry.y);
|
|
});
|
|
|
|
var left = x1 - node.width / 2 - minX;
|
|
var top = y1 - node.height / 2 - minY;
|
|
|
|
for (var i = 0; i < polyPoints.length; i++) {
|
|
var p1 = polyPoints[i];
|
|
var p2 = polyPoints[i < polyPoints.length - 1 ? i + 1 : 0];
|
|
var intersect = intersectLine(node, point,
|
|
{x: left + p1.x, y: top + p1.y}, {x: left + p2.x, y: top + p2.y});
|
|
if (intersect) {
|
|
intersections.push(intersect);
|
|
}
|
|
}
|
|
|
|
if (!intersections.length) {
|
|
console.log("NO INTERSECTION FOUND, RETURN NODE CENTER", node);
|
|
return node;
|
|
}
|
|
|
|
if (intersections.length > 1) {
|
|
// More intersections, find the one nearest to edge end point
|
|
intersections.sort(function(p, q) {
|
|
var pdx = p.x - point.x,
|
|
pdy = p.y - point.y,
|
|
distp = Math.sqrt(pdx * pdx + pdy * pdy),
|
|
|
|
qdx = q.x - point.x,
|
|
qdy = q.y - point.y,
|
|
distq = Math.sqrt(qdx * qdx + qdy * qdy);
|
|
|
|
return (distp < distq) ? -1 : (distp === distq ? 0 : 1);
|
|
});
|
|
}
|
|
return intersections[0];
|
|
}
|
|
|
|
},{"./intersect-line":13}],16:[function(require,module,exports){
|
|
module.exports = intersectRect;
|
|
|
|
function intersectRect(node, point) {
|
|
var x = node.x;
|
|
var y = node.y;
|
|
|
|
// Rectangle intersection algorithm from:
|
|
// http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes
|
|
var dx = point.x - x;
|
|
var dy = point.y - y;
|
|
var w = node.width / 2;
|
|
var h = node.height / 2;
|
|
|
|
var sx, sy;
|
|
if (Math.abs(dy) * w > Math.abs(dx) * h) {
|
|
// Intersection is top or bottom of rect.
|
|
if (dy < 0) {
|
|
h = -h;
|
|
}
|
|
sx = dy === 0 ? 0 : h * dx / dy;
|
|
sy = h;
|
|
} else {
|
|
// Intersection is left or right of rect.
|
|
if (dx < 0) {
|
|
w = -w;
|
|
}
|
|
sx = w;
|
|
sy = dx === 0 ? 0 : w * dy / dx;
|
|
}
|
|
|
|
return {x: x + sx, y: y + sy};
|
|
}
|
|
|
|
},{}],17:[function(require,module,exports){
|
|
var util = require("../util");
|
|
|
|
module.exports = addHtmlLabel;
|
|
|
|
function addHtmlLabel(root, node) {
|
|
var fo = root
|
|
.append("foreignObject")
|
|
.attr("width", "100000");
|
|
|
|
var div = fo
|
|
.append("xhtml:div");
|
|
|
|
var label = node.label;
|
|
switch(typeof label) {
|
|
case "function":
|
|
div.insert(label);
|
|
break;
|
|
case "object":
|
|
// Currently we assume this is a DOM object.
|
|
div.insert(function() { return label; });
|
|
break;
|
|
default: div.html(label);
|
|
}
|
|
|
|
util.applyStyle(div, node.labelStyle);
|
|
div.style("display", "inline-block");
|
|
// Fix for firefox
|
|
div.style("white-space", "nowrap");
|
|
|
|
// TODO find a better way to get dimensions for foreignObjects...
|
|
var w, h;
|
|
div
|
|
.each(function() {
|
|
w = this.clientWidth;
|
|
h = this.clientHeight;
|
|
});
|
|
|
|
fo
|
|
.attr("width", w)
|
|
.attr("height", h);
|
|
|
|
return fo;
|
|
}
|
|
|
|
},{"../util":27}],18:[function(require,module,exports){
|
|
var addTextLabel = require("./add-text-label"),
|
|
addHtmlLabel = require("./add-html-label"),
|
|
addSVGLabel = require("./add-svg-label");
|
|
|
|
module.exports = addLabel;
|
|
|
|
function addLabel(root, node, location) {
|
|
var label = node.label;
|
|
var labelSvg = root.append("g");
|
|
|
|
// Allow the label to be a string, a function that returns a DOM element, or
|
|
// a DOM element itself.
|
|
if (node.labelType === "svg") {
|
|
addSVGLabel(labelSvg, node);
|
|
} else if (typeof label !== "string" || node.labelType === "html") {
|
|
addHtmlLabel(labelSvg, node);
|
|
} else {
|
|
addTextLabel(labelSvg, node);
|
|
}
|
|
|
|
var labelBBox = labelSvg.node().getBBox();
|
|
switch(location) {
|
|
case "top":
|
|
y = (-node.height / 2);
|
|
break;
|
|
case "bottom":
|
|
y = (node.height / 2) - labelBBox.height;
|
|
break;
|
|
default:
|
|
y = (-labelBBox.height / 2);
|
|
}
|
|
labelSvg.attr("transform",
|
|
"translate(" + (-labelBBox.width / 2) + "," + y + ")");
|
|
|
|
return labelSvg;
|
|
}
|
|
|
|
},{"./add-html-label":17,"./add-svg-label":19,"./add-text-label":20}],19:[function(require,module,exports){
|
|
var util = require("../util");
|
|
|
|
module.exports = addSVGLabel;
|
|
|
|
function addSVGLabel(root, node) {
|
|
var domNode = root;
|
|
|
|
domNode.node().appendChild(node.label);
|
|
|
|
util.applyStyle(domNode, node.labelStyle);
|
|
|
|
return domNode;
|
|
}
|
|
|
|
},{"../util":27}],20:[function(require,module,exports){
|
|
var util = require("../util");
|
|
|
|
module.exports = addTextLabel;
|
|
|
|
/*
|
|
* Attaches a text label to the specified root. Handles escape sequences.
|
|
*/
|
|
function addTextLabel(root, node) {
|
|
var domNode = root.append("text");
|
|
|
|
var lines = processEscapeSequences(node.label).split("\n");
|
|
for (var i = 0; i < lines.length; i++) {
|
|
domNode
|
|
.append("tspan")
|
|
.attr("xml:space", "preserve")
|
|
.attr("dy", "1em")
|
|
.attr("x", "1")
|
|
.text(lines[i]);
|
|
}
|
|
|
|
util.applyStyle(domNode, node.labelStyle);
|
|
|
|
return domNode;
|
|
}
|
|
|
|
function processEscapeSequences(text) {
|
|
var newText = "",
|
|
escaped = false,
|
|
ch;
|
|
for (var i = 0; i < text.length; ++i) {
|
|
ch = text[i];
|
|
if (escaped) {
|
|
switch(ch) {
|
|
case "n": newText += "\n"; break;
|
|
default: newText += ch;
|
|
}
|
|
escaped = false;
|
|
} else if (ch === "\\") {
|
|
escaped = true;
|
|
} else {
|
|
newText += ch;
|
|
}
|
|
}
|
|
return newText;
|
|
}
|
|
|
|
},{"../util":27}],21:[function(require,module,exports){
|
|
/* global window */
|
|
|
|
var lodash;
|
|
|
|
if (require) {
|
|
try {
|
|
lodash = require("lodash");
|
|
} catch (e) {}
|
|
}
|
|
|
|
if (!lodash) {
|
|
lodash = window._;
|
|
}
|
|
|
|
module.exports = lodash;
|
|
|
|
},{"lodash":82}],22:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var util = require("./util"),
|
|
d3 = require("./d3");
|
|
|
|
module.exports = positionClusters;
|
|
|
|
function positionClusters(selection, g) {
|
|
var created = selection.filter(function() { return !d3.select(this).classed("update"); });
|
|
|
|
function translate(v) {
|
|
var node = g.node(v);
|
|
return "translate(" + node.x + "," + node.y + ")";
|
|
}
|
|
|
|
created.attr("transform", translate);
|
|
|
|
util.applyTransition(selection, g)
|
|
.style("opacity", 1)
|
|
.attr("transform", translate);
|
|
|
|
util.applyTransition(created.selectAll("rect"), g)
|
|
.attr("width", function(v) { return g.node(v).width; })
|
|
.attr("height", function(v) { return g.node(v).height; })
|
|
.attr("x", function(v) {
|
|
var node = g.node(v);
|
|
return -node.width / 2;
|
|
})
|
|
.attr("y", function(v) {
|
|
var node = g.node(v);
|
|
return -node.height / 2;
|
|
});
|
|
|
|
}
|
|
|
|
},{"./d3":7,"./util":27}],23:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var util = require("./util"),
|
|
d3 = require("./d3"),
|
|
_ = require("./lodash");
|
|
|
|
module.exports = positionEdgeLabels;
|
|
|
|
function positionEdgeLabels(selection, g) {
|
|
var created = selection.filter(function() { return !d3.select(this).classed("update"); });
|
|
|
|
function translate(e) {
|
|
var edge = g.edge(e);
|
|
return _.has(edge, "x") ? "translate(" + edge.x + "," + edge.y + ")" : "";
|
|
}
|
|
|
|
created.attr("transform", translate);
|
|
|
|
util.applyTransition(selection, g)
|
|
.style("opacity", 1)
|
|
.attr("transform", translate);
|
|
}
|
|
|
|
},{"./d3":7,"./lodash":21,"./util":27}],24:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var util = require("./util"),
|
|
d3 = require("./d3");
|
|
|
|
module.exports = positionNodes;
|
|
|
|
function positionNodes(selection, g) {
|
|
var created = selection.filter(function() { return !d3.select(this).classed("update"); });
|
|
|
|
function translate(v) {
|
|
var node = g.node(v);
|
|
return "translate(" + node.x + "," + node.y + ")";
|
|
}
|
|
|
|
created.attr("transform", translate);
|
|
|
|
util.applyTransition(selection, g)
|
|
.style("opacity", 1)
|
|
.attr("transform", translate);
|
|
}
|
|
|
|
},{"./d3":7,"./util":27}],25:[function(require,module,exports){
|
|
var _ = require("./lodash"),
|
|
layout = require("./dagre").layout;
|
|
|
|
module.exports = render;
|
|
|
|
// This design is based on http://bost.ocks.org/mike/chart/.
|
|
function render() {
|
|
var createNodes = require("./create-nodes"),
|
|
createClusters = require("./create-clusters"),
|
|
createEdgeLabels = require("./create-edge-labels"),
|
|
createEdgePaths = require("./create-edge-paths"),
|
|
positionNodes = require("./position-nodes"),
|
|
positionEdgeLabels = require("./position-edge-labels"),
|
|
positionClusters = require("./position-clusters"),
|
|
shapes = require("./shapes"),
|
|
arrows = require("./arrows");
|
|
|
|
var fn = function(svg, g) {
|
|
preProcessGraph(g);
|
|
|
|
var outputGroup = createOrSelectGroup(svg, "output"),
|
|
clustersGroup = createOrSelectGroup(outputGroup, "clusters"),
|
|
edgePathsGroup = createOrSelectGroup(outputGroup, "edgePaths"),
|
|
edgeLabels = createEdgeLabels(createOrSelectGroup(outputGroup, "edgeLabels"), g),
|
|
nodes = createNodes(createOrSelectGroup(outputGroup, "nodes"), g, shapes);
|
|
|
|
layout(g);
|
|
|
|
positionNodes(nodes, g);
|
|
positionEdgeLabels(edgeLabels, g);
|
|
createEdgePaths(edgePathsGroup, g, arrows);
|
|
|
|
var clusters = createClusters(clustersGroup, g);
|
|
positionClusters(clusters, g);
|
|
|
|
postProcessGraph(g);
|
|
};
|
|
|
|
fn.createNodes = function(value) {
|
|
if (!arguments.length) return createNodes;
|
|
createNodes = value;
|
|
return fn;
|
|
};
|
|
|
|
fn.createClusters = function(value) {
|
|
if (!arguments.length) return createClusters;
|
|
createClusters = value;
|
|
return fn;
|
|
};
|
|
|
|
fn.createEdgeLabels = function(value) {
|
|
if (!arguments.length) return createEdgeLabels;
|
|
createEdgeLabels = value;
|
|
return fn;
|
|
};
|
|
|
|
fn.createEdgePaths = function(value) {
|
|
if (!arguments.length) return createEdgePaths;
|
|
createEdgePaths = value;
|
|
return fn;
|
|
};
|
|
|
|
fn.shapes = function(value) {
|
|
if (!arguments.length) return shapes;
|
|
shapes = value;
|
|
return fn;
|
|
};
|
|
|
|
fn.arrows = function(value) {
|
|
if (!arguments.length) return arrows;
|
|
arrows = value;
|
|
return fn;
|
|
};
|
|
|
|
return fn;
|
|
}
|
|
|
|
var NODE_DEFAULT_ATTRS = {
|
|
paddingLeft: 10,
|
|
paddingRight: 10,
|
|
paddingTop: 10,
|
|
paddingBottom: 10,
|
|
rx: 0,
|
|
ry: 0,
|
|
shape: "rect"
|
|
};
|
|
|
|
var EDGE_DEFAULT_ATTRS = {
|
|
arrowhead: "normal",
|
|
lineInterpolate: "linear"
|
|
};
|
|
|
|
function preProcessGraph(g) {
|
|
g.nodes().forEach(function(v) {
|
|
var node = g.node(v);
|
|
if (!_.has(node, "label") && !g.children(v).length) { node.label = v; }
|
|
|
|
if (_.has(node, "paddingX")) {
|
|
_.defaults(node, {
|
|
paddingLeft: node.paddingX,
|
|
paddingRight: node.paddingX
|
|
});
|
|
}
|
|
|
|
if (_.has(node, "paddingY")) {
|
|
_.defaults(node, {
|
|
paddingTop: node.paddingY,
|
|
paddingBottom: node.paddingY
|
|
});
|
|
}
|
|
|
|
if (_.has(node, "padding")) {
|
|
_.defaults(node, {
|
|
paddingLeft: node.padding,
|
|
paddingRight: node.padding,
|
|
paddingTop: node.padding,
|
|
paddingBottom: node.padding
|
|
});
|
|
}
|
|
|
|
_.defaults(node, NODE_DEFAULT_ATTRS);
|
|
|
|
_.each(["paddingLeft", "paddingRight", "paddingTop", "paddingBottom"], function(k) {
|
|
node[k] = Number(node[k]);
|
|
});
|
|
|
|
// Save dimensions for restore during post-processing
|
|
if (_.has(node, "width")) { node._prevWidth = node.width; }
|
|
if (_.has(node, "height")) { node._prevHeight = node.height; }
|
|
});
|
|
|
|
g.edges().forEach(function(e) {
|
|
var edge = g.edge(e);
|
|
if (!_.has(edge, "label")) { edge.label = ""; }
|
|
_.defaults(edge, EDGE_DEFAULT_ATTRS);
|
|
});
|
|
}
|
|
|
|
function postProcessGraph(g) {
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v);
|
|
|
|
// Restore original dimensions
|
|
if (_.has(node, "_prevWidth")) {
|
|
node.width = node._prevWidth;
|
|
} else {
|
|
delete node.width;
|
|
}
|
|
|
|
if (_.has(node, "_prevHeight")) {
|
|
node.height = node._prevHeight;
|
|
} else {
|
|
delete node.height;
|
|
}
|
|
|
|
delete node._prevWidth;
|
|
delete node._prevHeight;
|
|
});
|
|
}
|
|
|
|
function createOrSelectGroup(root, name) {
|
|
var selection = root.select("g." + name);
|
|
if (selection.empty()) {
|
|
selection = root.append("g").attr("class", name);
|
|
}
|
|
return selection;
|
|
}
|
|
|
|
},{"./arrows":2,"./create-clusters":3,"./create-edge-labels":4,"./create-edge-paths":5,"./create-nodes":6,"./dagre":8,"./lodash":21,"./position-clusters":22,"./position-edge-labels":23,"./position-nodes":24,"./shapes":26}],26:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var intersectRect = require("./intersect/intersect-rect"),
|
|
intersectEllipse = require("./intersect/intersect-ellipse"),
|
|
intersectCircle = require("./intersect/intersect-circle"),
|
|
intersectPolygon = require("./intersect/intersect-polygon");
|
|
|
|
module.exports = {
|
|
rect: rect,
|
|
ellipse: ellipse,
|
|
circle: circle,
|
|
diamond: diamond
|
|
};
|
|
|
|
function rect(parent, bbox, node) {
|
|
var shapeSvg = parent.insert("rect", ":first-child")
|
|
.attr("rx", node.rx)
|
|
.attr("ry", node.ry)
|
|
.attr("x", -bbox.width / 2)
|
|
.attr("y", -bbox.height / 2)
|
|
.attr("width", bbox.width)
|
|
.attr("height", bbox.height);
|
|
|
|
node.intersect = function(point) {
|
|
return intersectRect(node, point);
|
|
};
|
|
|
|
return shapeSvg;
|
|
}
|
|
|
|
function ellipse(parent, bbox, node) {
|
|
var rx = bbox.width / 2,
|
|
ry = bbox.height / 2,
|
|
shapeSvg = parent.insert("ellipse", ":first-child")
|
|
.attr("x", -bbox.width / 2)
|
|
.attr("y", -bbox.height / 2)
|
|
.attr("rx", rx)
|
|
.attr("ry", ry);
|
|
|
|
node.intersect = function(point) {
|
|
return intersectEllipse(node, rx, ry, point);
|
|
};
|
|
|
|
return shapeSvg;
|
|
}
|
|
|
|
function circle(parent, bbox, node) {
|
|
var r = Math.max(bbox.width, bbox.height) / 2,
|
|
shapeSvg = parent.insert("circle", ":first-child")
|
|
.attr("x", -bbox.width / 2)
|
|
.attr("y", -bbox.height / 2)
|
|
.attr("r", r);
|
|
|
|
node.intersect = function(point) {
|
|
return intersectCircle(node, r, point);
|
|
};
|
|
|
|
return shapeSvg;
|
|
}
|
|
|
|
// Circumscribe an ellipse for the bounding box with a diamond shape. I derived
|
|
// the function to calculate the diamond shape from:
|
|
// http://mathforum.org/kb/message.jspa?messageID=3750236
|
|
function diamond(parent, bbox, node) {
|
|
var w = (bbox.width * Math.SQRT2) / 2,
|
|
h = (bbox.height * Math.SQRT2) / 2,
|
|
points = [
|
|
{ x: 0, y: -h },
|
|
{ x: -w, y: 0 },
|
|
{ x: 0, y: h },
|
|
{ x: w, y: 0 }
|
|
],
|
|
shapeSvg = parent.insert("polygon", ":first-child")
|
|
.attr("points", points.map(function(p) { return p.x + "," + p.y; }).join(" "));
|
|
|
|
node.intersect = function(p) {
|
|
return intersectPolygon(node, points, p);
|
|
};
|
|
|
|
return shapeSvg;
|
|
}
|
|
|
|
},{"./intersect/intersect-circle":11,"./intersect/intersect-ellipse":12,"./intersect/intersect-polygon":15,"./intersect/intersect-rect":16}],27:[function(require,module,exports){
|
|
var _ = require("./lodash");
|
|
|
|
// Public utility functions
|
|
module.exports = {
|
|
isSubgraph: isSubgraph,
|
|
edgeToId: edgeToId,
|
|
applyStyle: applyStyle,
|
|
applyClass: applyClass,
|
|
applyTransition: applyTransition
|
|
};
|
|
|
|
/*
|
|
* Returns true if the specified node in the graph is a subgraph node. A
|
|
* subgraph node is one that contains other nodes.
|
|
*/
|
|
function isSubgraph(g, v) {
|
|
return !!g.children(v).length;
|
|
}
|
|
|
|
function edgeToId(e) {
|
|
return escapeId(e.v) + ":" + escapeId(e.w) + ":" + escapeId(e.name);
|
|
}
|
|
|
|
var ID_DELIM = /:/g;
|
|
function escapeId(str) {
|
|
return str ? String(str).replace(ID_DELIM, "\\:") : "";
|
|
}
|
|
|
|
function applyStyle(dom, styleFn) {
|
|
if (styleFn) {
|
|
dom.attr("style", styleFn);
|
|
}
|
|
}
|
|
|
|
function applyClass(dom, classFn, otherClasses) {
|
|
if (classFn) {
|
|
dom
|
|
.attr("class", classFn)
|
|
.attr("class", otherClasses + " " + dom.attr("class"));
|
|
}
|
|
}
|
|
|
|
function applyTransition(selection, g) {
|
|
var graph = g.graph();
|
|
|
|
if (_.isPlainObject(graph)) {
|
|
var transition = graph.transition;
|
|
if (_.isFunction(transition)) {
|
|
return transition(selection);
|
|
}
|
|
}
|
|
|
|
return selection;
|
|
}
|
|
|
|
},{"./lodash":21}],28:[function(require,module,exports){
|
|
module.exports = "0.4.8";
|
|
|
|
},{}],29:[function(require,module,exports){
|
|
/*
|
|
Copyright (c) 2012-2014 Chris Pettitt
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
in the Software without restriction, including without limitation the rights
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
all copies or substantial portions of the Software.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
*/
|
|
|
|
module.exports = {
|
|
graphlib: require("./lib/graphlib"),
|
|
|
|
layout: require("./lib/layout"),
|
|
debug: require("./lib/debug"),
|
|
util: {
|
|
time: require("./lib/util").time,
|
|
notime: require("./lib/util").notime
|
|
},
|
|
version: require("./lib/version")
|
|
};
|
|
|
|
},{"./lib/debug":34,"./lib/graphlib":35,"./lib/layout":37,"./lib/util":57,"./lib/version":58}],30:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
greedyFAS = require("./greedy-fas");
|
|
|
|
module.exports = {
|
|
run: run,
|
|
undo: undo
|
|
};
|
|
|
|
function run(g) {
|
|
var fas = (g.graph().acyclicer === "greedy"
|
|
? greedyFAS(g, weightFn(g))
|
|
: dfsFAS(g));
|
|
_.each(fas, function(e) {
|
|
var label = g.edge(e);
|
|
g.removeEdge(e);
|
|
label.forwardName = e.name;
|
|
label.reversed = true;
|
|
g.setEdge(e.w, e.v, label, _.uniqueId("rev"));
|
|
});
|
|
|
|
function weightFn(g) {
|
|
return function(e) {
|
|
return g.edge(e).weight;
|
|
};
|
|
}
|
|
}
|
|
|
|
function dfsFAS(g) {
|
|
var fas = [],
|
|
stack = {},
|
|
visited = {};
|
|
|
|
function dfs(v) {
|
|
if (_.has(visited, v)) {
|
|
return;
|
|
}
|
|
visited[v] = true;
|
|
stack[v] = true;
|
|
_.each(g.outEdges(v), function(e) {
|
|
if (_.has(stack, e.w)) {
|
|
fas.push(e);
|
|
} else {
|
|
dfs(e.w);
|
|
}
|
|
});
|
|
delete stack[v];
|
|
}
|
|
|
|
_.each(g.nodes(), dfs);
|
|
return fas;
|
|
}
|
|
|
|
function undo(g) {
|
|
_.each(g.edges(), function(e) {
|
|
var label = g.edge(e);
|
|
if (label.reversed) {
|
|
g.removeEdge(e);
|
|
|
|
var forwardName = label.forwardName;
|
|
delete label.reversed;
|
|
delete label.forwardName;
|
|
g.setEdge(e.w, e.v, label, forwardName);
|
|
}
|
|
});
|
|
}
|
|
|
|
},{"./greedy-fas":36,"./lodash":38}],31:[function(require,module,exports){
|
|
var _ = require("./lodash"),
|
|
util = require("./util");
|
|
|
|
module.exports = addBorderSegments;
|
|
|
|
function addBorderSegments(g) {
|
|
function dfs(v) {
|
|
var children = g.children(v),
|
|
node = g.node(v);
|
|
if (children.length) {
|
|
_.each(children, dfs);
|
|
}
|
|
|
|
if (_.has(node, "minRank")) {
|
|
node.borderLeft = [];
|
|
node.borderRight = [];
|
|
for (var rank = node.minRank, maxRank = node.maxRank + 1;
|
|
rank < maxRank;
|
|
++rank) {
|
|
addBorderNode(g, "borderLeft", "_bl", v, node, rank);
|
|
addBorderNode(g, "borderRight", "_br", v, node, rank);
|
|
}
|
|
}
|
|
}
|
|
|
|
_.each(g.children(), dfs);
|
|
}
|
|
|
|
function addBorderNode(g, prop, prefix, sg, sgNode, rank) {
|
|
var label = { width: 0, height: 0, rank: rank, borderType: prop },
|
|
prev = sgNode[prop][rank - 1],
|
|
curr = util.addDummyNode(g, "border", label, prefix);
|
|
sgNode[prop][rank] = curr;
|
|
g.setParent(curr, sg);
|
|
if (prev) {
|
|
g.setEdge(prev, curr, { weight: 1 });
|
|
}
|
|
}
|
|
|
|
},{"./lodash":38,"./util":57}],32:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash");
|
|
|
|
module.exports = {
|
|
adjust: adjust,
|
|
undo: undo
|
|
};
|
|
|
|
function adjust(g) {
|
|
var rankDir = g.graph().rankdir.toLowerCase();
|
|
if (rankDir === "lr" || rankDir === "rl") {
|
|
swapWidthHeight(g);
|
|
}
|
|
}
|
|
|
|
function undo(g) {
|
|
var rankDir = g.graph().rankdir.toLowerCase();
|
|
if (rankDir === "bt" || rankDir === "rl") {
|
|
reverseY(g);
|
|
}
|
|
|
|
if (rankDir === "lr" || rankDir === "rl") {
|
|
swapXY(g);
|
|
swapWidthHeight(g);
|
|
}
|
|
}
|
|
|
|
function swapWidthHeight(g) {
|
|
_.each(g.nodes(), function(v) { swapWidthHeightOne(g.node(v)); });
|
|
_.each(g.edges(), function(e) { swapWidthHeightOne(g.edge(e)); });
|
|
}
|
|
|
|
function swapWidthHeightOne(attrs) {
|
|
var w = attrs.width;
|
|
attrs.width = attrs.height;
|
|
attrs.height = w;
|
|
}
|
|
|
|
function reverseY(g) {
|
|
_.each(g.nodes(), function(v) { reverseYOne(g.node(v)); });
|
|
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
_.each(edge.points, reverseYOne);
|
|
if (_.has(edge, "y")) {
|
|
reverseYOne(edge);
|
|
}
|
|
});
|
|
}
|
|
|
|
function reverseYOne(attrs) {
|
|
attrs.y = -attrs.y;
|
|
}
|
|
|
|
function swapXY(g) {
|
|
_.each(g.nodes(), function(v) { swapXYOne(g.node(v)); });
|
|
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
_.each(edge.points, swapXYOne);
|
|
if (_.has(edge, "x")) {
|
|
swapXYOne(edge);
|
|
}
|
|
});
|
|
}
|
|
|
|
function swapXYOne(attrs) {
|
|
var x = attrs.x;
|
|
attrs.x = attrs.y;
|
|
attrs.y = x;
|
|
}
|
|
|
|
},{"./lodash":38}],33:[function(require,module,exports){
|
|
/*
|
|
* Simple doubly linked list implementation derived from Cormen, et al.,
|
|
* "Introduction to Algorithms".
|
|
*/
|
|
|
|
module.exports = List;
|
|
|
|
function List() {
|
|
var sentinel = {};
|
|
sentinel._next = sentinel._prev = sentinel;
|
|
this._sentinel = sentinel;
|
|
}
|
|
|
|
List.prototype.dequeue = function() {
|
|
var sentinel = this._sentinel,
|
|
entry = sentinel._prev;
|
|
if (entry !== sentinel) {
|
|
unlink(entry);
|
|
return entry;
|
|
}
|
|
};
|
|
|
|
List.prototype.enqueue = function(entry) {
|
|
var sentinel = this._sentinel;
|
|
if (entry._prev && entry._next) {
|
|
unlink(entry);
|
|
}
|
|
entry._next = sentinel._next;
|
|
sentinel._next._prev = entry;
|
|
sentinel._next = entry;
|
|
entry._prev = sentinel;
|
|
};
|
|
|
|
List.prototype.toString = function() {
|
|
var strs = [],
|
|
sentinel = this._sentinel,
|
|
curr = sentinel._prev;
|
|
while (curr !== sentinel) {
|
|
strs.push(JSON.stringify(curr, filterOutLinks));
|
|
curr = curr._prev;
|
|
}
|
|
return "[" + strs.join(", ") + "]";
|
|
};
|
|
|
|
function unlink(entry) {
|
|
entry._prev._next = entry._next;
|
|
entry._next._prev = entry._prev;
|
|
delete entry._next;
|
|
delete entry._prev;
|
|
}
|
|
|
|
function filterOutLinks(k, v) {
|
|
if (k !== "_next" && k !== "_prev") {
|
|
return v;
|
|
}
|
|
}
|
|
|
|
},{}],34:[function(require,module,exports){
|
|
var _ = require("./lodash"),
|
|
util = require("./util"),
|
|
Graph = require("./graphlib").Graph;
|
|
|
|
module.exports = {
|
|
debugOrdering: debugOrdering
|
|
};
|
|
|
|
/* istanbul ignore next */
|
|
function debugOrdering(g) {
|
|
var layerMatrix = util.buildLayerMatrix(g);
|
|
|
|
var h = new Graph({ compound: true, multigraph: true }).setGraph({});
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
h.setNode(v, { label: v });
|
|
h.setParent(v, "layer" + g.node(v).rank);
|
|
});
|
|
|
|
_.each(g.edges(), function(e) {
|
|
h.setEdge(e.v, e.w, {}, e.name);
|
|
});
|
|
|
|
_.each(layerMatrix, function(layer, i) {
|
|
var layerV = "layer" + i;
|
|
h.setNode(layerV, { rank: "same" });
|
|
_.reduce(layer, function(u, v) {
|
|
h.setEdge(u, v, { style: "invis" });
|
|
return v;
|
|
});
|
|
});
|
|
|
|
return h;
|
|
}
|
|
|
|
},{"./graphlib":35,"./lodash":38,"./util":57}],35:[function(require,module,exports){
|
|
module.exports=require(9)
|
|
},{"graphlib":59}],36:[function(require,module,exports){
|
|
var _ = require("./lodash"),
|
|
Graph = require("./graphlib").Graph,
|
|
List = require("./data/list");
|
|
|
|
/*
|
|
* A greedy heuristic for finding a feedback arc set for a graph. A feedback
|
|
* arc set is a set of edges that can be removed to make a graph acyclic.
|
|
* The algorithm comes from: P. Eades, X. Lin, and W. F. Smyth, "A fast and
|
|
* effective heuristic for the feedback arc set problem." This implementation
|
|
* adjusts that from the paper to allow for weighted edges.
|
|
*/
|
|
module.exports = greedyFAS;
|
|
|
|
var DEFAULT_WEIGHT_FN = _.constant(1);
|
|
|
|
function greedyFAS(g, weightFn) {
|
|
if (g.nodeCount() <= 1) {
|
|
return [];
|
|
}
|
|
var state = buildState(g, weightFn || DEFAULT_WEIGHT_FN);
|
|
var results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx);
|
|
|
|
// Expand multi-edges
|
|
return _.flatten(_.map(results, function(e) {
|
|
return g.outEdges(e.v, e.w);
|
|
}), true);
|
|
}
|
|
|
|
function doGreedyFAS(g, buckets, zeroIdx) {
|
|
var results = [],
|
|
sources = buckets[buckets.length - 1],
|
|
sinks = buckets[0];
|
|
|
|
var entry;
|
|
while (g.nodeCount()) {
|
|
while ((entry = sinks.dequeue())) { removeNode(g, buckets, zeroIdx, entry); }
|
|
while ((entry = sources.dequeue())) { removeNode(g, buckets, zeroIdx, entry); }
|
|
if (g.nodeCount()) {
|
|
for (var i = buckets.length - 2; i > 0; --i) {
|
|
entry = buckets[i].dequeue();
|
|
if (entry) {
|
|
results = results.concat(removeNode(g, buckets, zeroIdx, entry, true));
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
function removeNode(g, buckets, zeroIdx, entry, collectPredecessors) {
|
|
var results = collectPredecessors ? [] : undefined;
|
|
|
|
_.each(g.inEdges(entry.v), function(edge) {
|
|
var weight = g.edge(edge),
|
|
uEntry = g.node(edge.v);
|
|
|
|
if (collectPredecessors) {
|
|
results.push({ v: edge.v, w: edge.w });
|
|
}
|
|
|
|
uEntry.out -= weight;
|
|
assignBucket(buckets, zeroIdx, uEntry);
|
|
});
|
|
|
|
_.each(g.outEdges(entry.v), function(edge) {
|
|
var weight = g.edge(edge),
|
|
w = edge.w,
|
|
wEntry = g.node(w);
|
|
wEntry["in"] -= weight;
|
|
assignBucket(buckets, zeroIdx, wEntry);
|
|
});
|
|
|
|
g.removeNode(entry.v);
|
|
|
|
return results;
|
|
}
|
|
|
|
function buildState(g, weightFn) {
|
|
var fasGraph = new Graph(),
|
|
maxIn = 0,
|
|
maxOut = 0;
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
fasGraph.setNode(v, { v: v, "in": 0, out: 0 });
|
|
});
|
|
|
|
// Aggregate weights on nodes, but also sum the weights across multi-edges
|
|
// into a single edge for the fasGraph.
|
|
_.each(g.edges(), function(e) {
|
|
var prevWeight = fasGraph.edge(e.v, e.w) || 0,
|
|
weight = weightFn(e),
|
|
edgeWeight = prevWeight + weight;
|
|
fasGraph.setEdge(e.v, e.w, edgeWeight);
|
|
maxOut = Math.max(maxOut, fasGraph.node(e.v).out += weight);
|
|
maxIn = Math.max(maxIn, fasGraph.node(e.w)["in"] += weight);
|
|
});
|
|
|
|
var buckets = _.range(maxOut + maxIn + 3).map(function() { return new List(); });
|
|
var zeroIdx = maxIn + 1;
|
|
|
|
_.each(fasGraph.nodes(), function(v) {
|
|
assignBucket(buckets, zeroIdx, fasGraph.node(v));
|
|
});
|
|
|
|
return { graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx };
|
|
}
|
|
|
|
function assignBucket(buckets, zeroIdx, entry) {
|
|
if (!entry.out) {
|
|
buckets[0].enqueue(entry);
|
|
} else if (!entry["in"]) {
|
|
buckets[buckets.length - 1].enqueue(entry);
|
|
} else {
|
|
buckets[entry.out - entry["in"] + zeroIdx].enqueue(entry);
|
|
}
|
|
}
|
|
|
|
},{"./data/list":33,"./graphlib":35,"./lodash":38}],37:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
acyclic = require("./acyclic"),
|
|
normalize = require("./normalize"),
|
|
rank = require("./rank"),
|
|
normalizeRanks = require("./util").normalizeRanks,
|
|
parentDummyChains = require("./parent-dummy-chains"),
|
|
removeEmptyRanks = require("./util").removeEmptyRanks,
|
|
nestingGraph = require("./nesting-graph"),
|
|
addBorderSegments = require("./add-border-segments"),
|
|
coordinateSystem = require("./coordinate-system"),
|
|
order = require("./order"),
|
|
position = require("./position"),
|
|
util = require("./util"),
|
|
Graph = require("./graphlib").Graph;
|
|
|
|
module.exports = layout;
|
|
|
|
function layout(g, opts) {
|
|
var time = opts && opts.debugTiming ? util.time : util.notime;
|
|
time("layout", function() {
|
|
var layoutGraph = time(" buildLayoutGraph",
|
|
function() { return buildLayoutGraph(g); });
|
|
time(" runLayout", function() { runLayout(layoutGraph, time); });
|
|
time(" updateInputGraph", function() { updateInputGraph(g, layoutGraph); });
|
|
});
|
|
}
|
|
|
|
function runLayout(g, time) {
|
|
time(" makeSpaceForEdgeLabels", function() { makeSpaceForEdgeLabels(g); });
|
|
time(" removeSelfEdges", function() { removeSelfEdges(g); });
|
|
time(" acyclic", function() { acyclic.run(g); });
|
|
time(" nestingGraph.run", function() { nestingGraph.run(g); });
|
|
time(" rank", function() { rank(util.asNonCompoundGraph(g)); });
|
|
time(" injectEdgeLabelProxies", function() { injectEdgeLabelProxies(g); });
|
|
time(" removeEmptyRanks", function() { removeEmptyRanks(g); });
|
|
time(" nestingGraph.cleanup", function() { nestingGraph.cleanup(g); });
|
|
time(" normalizeRanks", function() { normalizeRanks(g); });
|
|
time(" assignRankMinMax", function() { assignRankMinMax(g); });
|
|
time(" removeEdgeLabelProxies", function() { removeEdgeLabelProxies(g); });
|
|
time(" normalize.run", function() { normalize.run(g); });
|
|
time(" parentDummyChains", function() { parentDummyChains(g); });
|
|
time(" addBorderSegments", function() { addBorderSegments(g); });
|
|
time(" order", function() { order(g); });
|
|
time(" insertSelfEdges", function() { insertSelfEdges(g); });
|
|
time(" adjustCoordinateSystem", function() { coordinateSystem.adjust(g); });
|
|
time(" position", function() { position(g); });
|
|
time(" positionSelfEdges", function() { positionSelfEdges(g); });
|
|
time(" removeBorderNodes", function() { removeBorderNodes(g); });
|
|
time(" normalize.undo", function() { normalize.undo(g); });
|
|
time(" fixupEdgeLabelCoords", function() { fixupEdgeLabelCoords(g); });
|
|
time(" undoCoordinateSystem", function() { coordinateSystem.undo(g); });
|
|
time(" translateGraph", function() { translateGraph(g); });
|
|
time(" assignNodeIntersects", function() { assignNodeIntersects(g); });
|
|
time(" reversePoints", function() { reversePointsForReversedEdges(g); });
|
|
time(" acyclic.undo", function() { acyclic.undo(g); });
|
|
}
|
|
|
|
/*
|
|
* Copies final layout information from the layout graph back to the input
|
|
* graph. This process only copies whitelisted attributes from the layout graph
|
|
* to the input graph, so it serves as a good place to determine what
|
|
* attributes can influence layout.
|
|
*/
|
|
function updateInputGraph(inputGraph, layoutGraph) {
|
|
_.each(inputGraph.nodes(), function(v) {
|
|
var inputLabel = inputGraph.node(v),
|
|
layoutLabel = layoutGraph.node(v);
|
|
|
|
if (inputLabel) {
|
|
inputLabel.x = layoutLabel.x;
|
|
inputLabel.y = layoutLabel.y;
|
|
|
|
if (layoutGraph.children(v).length) {
|
|
inputLabel.width = layoutLabel.width;
|
|
inputLabel.height = layoutLabel.height;
|
|
}
|
|
}
|
|
});
|
|
|
|
_.each(inputGraph.edges(), function(e) {
|
|
var inputLabel = inputGraph.edge(e),
|
|
layoutLabel = layoutGraph.edge(e);
|
|
|
|
inputLabel.points = layoutLabel.points;
|
|
if (_.has(layoutLabel, "x")) {
|
|
inputLabel.x = layoutLabel.x;
|
|
inputLabel.y = layoutLabel.y;
|
|
}
|
|
});
|
|
|
|
inputGraph.graph().width = layoutGraph.graph().width;
|
|
inputGraph.graph().height = layoutGraph.graph().height;
|
|
}
|
|
|
|
var graphNumAttrs = ["nodesep", "edgesep", "ranksep", "marginx", "marginy"],
|
|
graphDefaults = { ranksep: 50, edgesep: 20, nodesep: 50, rankdir: "tb" },
|
|
graphAttrs = ["acyclicer", "ranker", "rankdir", "align"],
|
|
nodeNumAttrs = ["width", "height"],
|
|
nodeDefaults = { width: 0, height: 0 },
|
|
edgeNumAttrs = ["minlen", "weight", "width", "height", "labeloffset"],
|
|
edgeDefaults = {
|
|
minlen: 1, weight: 1, width: 0, height: 0,
|
|
labeloffset: 10, labelpos: "r"
|
|
},
|
|
edgeAttrs = ["labelpos"];
|
|
|
|
/*
|
|
* Constructs a new graph from the input graph, which can be used for layout.
|
|
* This process copies only whitelisted attributes from the input graph to the
|
|
* layout graph. Thus this function serves as a good place to determine what
|
|
* attributes can influence layout.
|
|
*/
|
|
function buildLayoutGraph(inputGraph) {
|
|
var g = new Graph({ multigraph: true, compound: true }),
|
|
graph = canonicalize(inputGraph.graph());
|
|
|
|
g.setGraph(_.merge({},
|
|
graphDefaults,
|
|
selectNumberAttrs(graph, graphNumAttrs),
|
|
_.pick(graph, graphAttrs)));
|
|
|
|
_.each(inputGraph.nodes(), function(v) {
|
|
var node = canonicalize(inputGraph.node(v));
|
|
g.setNode(v, _.defaults(selectNumberAttrs(node, nodeNumAttrs), nodeDefaults));
|
|
g.setParent(v, inputGraph.parent(v));
|
|
});
|
|
|
|
_.each(inputGraph.edges(), function(e) {
|
|
var edge = canonicalize(inputGraph.edge(e));
|
|
g.setEdge(e, _.merge({},
|
|
edgeDefaults,
|
|
selectNumberAttrs(edge, edgeNumAttrs),
|
|
_.pick(edge, edgeAttrs)));
|
|
});
|
|
|
|
return g;
|
|
}
|
|
|
|
/*
|
|
* This idea comes from the Gansner paper: to account for edge labels in our
|
|
* layout we split each rank in half by doubling minlen and halving ranksep.
|
|
* Then we can place labels at these mid-points between nodes.
|
|
*
|
|
* We also add some minimal padding to the width to push the label for the edge
|
|
* away from the edge itself a bit.
|
|
*/
|
|
function makeSpaceForEdgeLabels(g) {
|
|
var graph = g.graph();
|
|
graph.ranksep /= 2;
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
edge.minlen *= 2;
|
|
if (edge.labelpos.toLowerCase() !== "c") {
|
|
if (graph.rankdir === "TB" || graph.rankdir === "BT") {
|
|
edge.width += edge.labeloffset;
|
|
} else {
|
|
edge.height += edge.labeloffset;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
/*
|
|
* Creates temporary dummy nodes that capture the rank in which each edge's
|
|
* label is going to, if it has one of non-zero width and height. We do this
|
|
* so that we can safely remove empty ranks while preserving balance for the
|
|
* label's position.
|
|
*/
|
|
function injectEdgeLabelProxies(g) {
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
if (edge.width && edge.height) {
|
|
var v = g.node(e.v),
|
|
w = g.node(e.w),
|
|
label = { rank: (w.rank - v.rank) / 2 + v.rank, e: e };
|
|
util.addDummyNode(g, "edge-proxy", label, "_ep");
|
|
}
|
|
});
|
|
}
|
|
|
|
function assignRankMinMax(g) {
|
|
var maxRank = 0;
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v);
|
|
if (node.borderTop) {
|
|
node.minRank = g.node(node.borderTop).rank;
|
|
node.maxRank = g.node(node.borderBottom).rank;
|
|
maxRank = _.max(maxRank, node.maxRank);
|
|
}
|
|
});
|
|
g.graph().maxRank = maxRank;
|
|
}
|
|
|
|
function removeEdgeLabelProxies(g) {
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v);
|
|
if (node.dummy === "edge-proxy") {
|
|
g.edge(node.e).labelRank = node.rank;
|
|
g.removeNode(v);
|
|
}
|
|
});
|
|
}
|
|
|
|
function translateGraph(g) {
|
|
var minX = Number.POSITIVE_INFINITY,
|
|
maxX = 0,
|
|
minY = Number.POSITIVE_INFINITY,
|
|
maxY = 0,
|
|
graphLabel = g.graph(),
|
|
marginX = graphLabel.marginx || 0,
|
|
marginY = graphLabel.marginy || 0;
|
|
|
|
function getExtremes(attrs) {
|
|
var x = attrs.x,
|
|
y = attrs.y,
|
|
w = attrs.width,
|
|
h = attrs.height;
|
|
minX = Math.min(minX, x - w / 2);
|
|
maxX = Math.max(maxX, x + w / 2);
|
|
minY = Math.min(minY, y - h / 2);
|
|
maxY = Math.max(maxY, y + h / 2);
|
|
}
|
|
|
|
_.each(g.nodes(), function(v) { getExtremes(g.node(v)); });
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
if (_.has(edge, "x")) {
|
|
getExtremes(edge);
|
|
}
|
|
});
|
|
|
|
minX -= marginX;
|
|
minY -= marginY;
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v);
|
|
node.x -= minX;
|
|
node.y -= minY;
|
|
});
|
|
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
_.each(edge.points, function(p) {
|
|
p.x -= minX;
|
|
p.y -= minY;
|
|
});
|
|
if (_.has(edge, "x")) { edge.x -= minX; }
|
|
if (_.has(edge, "y")) { edge.y -= minY; }
|
|
});
|
|
|
|
graphLabel.width = maxX - minX + marginX;
|
|
graphLabel.height = maxY - minY + marginY;
|
|
}
|
|
|
|
function assignNodeIntersects(g) {
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e),
|
|
nodeV = g.node(e.v),
|
|
nodeW = g.node(e.w),
|
|
p1, p2;
|
|
if (!edge.points) {
|
|
edge.points = [];
|
|
p1 = nodeW;
|
|
p2 = nodeV;
|
|
} else {
|
|
p1 = edge.points[0];
|
|
p2 = edge.points[edge.points.length - 1];
|
|
}
|
|
edge.points.unshift(util.intersectRect(nodeV, p1));
|
|
edge.points.push(util.intersectRect(nodeW, p2));
|
|
});
|
|
}
|
|
|
|
function fixupEdgeLabelCoords(g) {
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
if (_.has(edge, "x")) {
|
|
if (edge.labelpos === "l" || edge.labelpos === "r") {
|
|
edge.width -= edge.labeloffset;
|
|
}
|
|
switch (edge.labelpos) {
|
|
case "l": edge.x -= edge.width / 2 + edge.labeloffset; break;
|
|
case "r": edge.x += edge.width / 2 + edge.labeloffset; break;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function reversePointsForReversedEdges(g) {
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
if (edge.reversed) {
|
|
edge.points.reverse();
|
|
}
|
|
});
|
|
}
|
|
|
|
function removeBorderNodes(g) {
|
|
_.each(g.nodes(), function(v) {
|
|
if (g.children(v).length) {
|
|
var node = g.node(v),
|
|
t = g.node(node.borderTop),
|
|
b = g.node(node.borderBottom),
|
|
l = g.node(_.last(node.borderLeft)),
|
|
r = g.node(_.last(node.borderRight));
|
|
|
|
node.width = Math.abs(r.x - l.x);
|
|
node.height = Math.abs(b.y - t.y);
|
|
node.x = l.x + node.width / 2;
|
|
node.y = t.y + node.height / 2;
|
|
}
|
|
});
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
if (g.node(v).dummy === "border") {
|
|
g.removeNode(v);
|
|
}
|
|
});
|
|
}
|
|
|
|
function removeSelfEdges(g) {
|
|
_.each(g.edges(), function(e) {
|
|
if (e.v === e.w) {
|
|
var node = g.node(e.v);
|
|
if (!node.selfEdges) {
|
|
node.selfEdges = [];
|
|
}
|
|
node.selfEdges.push({ e: e, label: g.edge(e) });
|
|
g.removeEdge(e);
|
|
}
|
|
});
|
|
}
|
|
|
|
function insertSelfEdges(g) {
|
|
var layers = util.buildLayerMatrix(g);
|
|
_.each(layers, function(layer) {
|
|
var orderShift = 0;
|
|
_.each(layer, function(v, i) {
|
|
var node = g.node(v);
|
|
node.order = i + orderShift;
|
|
_.each(node.selfEdges, function(selfEdge) {
|
|
util.addDummyNode(g, "selfedge", {
|
|
width: selfEdge.label.width,
|
|
height: selfEdge.label.height,
|
|
rank: node.rank,
|
|
order: i + (++orderShift),
|
|
e: selfEdge.e,
|
|
label: selfEdge.label
|
|
}, "_se");
|
|
});
|
|
delete node.selfEdges;
|
|
});
|
|
});
|
|
}
|
|
|
|
function positionSelfEdges(g) {
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v);
|
|
if (node.dummy === "selfedge") {
|
|
var selfNode = g.node(node.e.v),
|
|
x = selfNode.x + selfNode.width / 2,
|
|
y = selfNode.y,
|
|
dx = node.x - x,
|
|
dy = selfNode.height / 2;
|
|
g.setEdge(node.e, node.label);
|
|
g.removeNode(v);
|
|
node.label.points = [
|
|
{ x: x + 2 * dx / 3, y: y - dy },
|
|
{ x: x + 5 * dx / 6, y: y - dy },
|
|
{ x: x + dx , y: y },
|
|
{ x: x + 5 * dx / 6, y: y + dy },
|
|
{ x: x + 2 * dx / 3, y: y + dy },
|
|
];
|
|
node.label.x = node.x;
|
|
node.label.y = node.y;
|
|
}
|
|
});
|
|
}
|
|
|
|
function selectNumberAttrs(obj, attrs) {
|
|
return _.mapValues(_.pick(obj, attrs), Number);
|
|
}
|
|
|
|
function canonicalize(attrs) {
|
|
var newAttrs = {};
|
|
_.each(attrs, function(v, k) {
|
|
newAttrs[k.toLowerCase()] = v;
|
|
});
|
|
return newAttrs;
|
|
}
|
|
|
|
},{"./acyclic":30,"./add-border-segments":31,"./coordinate-system":32,"./graphlib":35,"./lodash":38,"./nesting-graph":39,"./normalize":40,"./order":45,"./parent-dummy-chains":50,"./position":52,"./rank":54,"./util":57}],38:[function(require,module,exports){
|
|
module.exports=require(21)
|
|
},{"lodash":82}],39:[function(require,module,exports){
|
|
var _ = require("./lodash"),
|
|
util = require("./util");
|
|
|
|
module.exports = {
|
|
run: run,
|
|
cleanup: cleanup
|
|
};
|
|
|
|
/*
|
|
* A nesting graph creates dummy nodes for the tops and bottoms of subgraphs,
|
|
* adds appropriate edges to ensure that all cluster nodes are placed between
|
|
* these boundries, and ensures that the graph is connected.
|
|
*
|
|
* In addition we ensure, through the use of the minlen property, that nodes
|
|
* and subgraph border nodes to not end up on the same rank.
|
|
*
|
|
* Preconditions:
|
|
*
|
|
* 1. Input graph is a DAG
|
|
* 2. Nodes in the input graph has a minlen attribute
|
|
*
|
|
* Postconditions:
|
|
*
|
|
* 1. Input graph is connected.
|
|
* 2. Dummy nodes are added for the tops and bottoms of subgraphs.
|
|
* 3. The minlen attribute for nodes is adjusted to ensure nodes do not
|
|
* get placed on the same rank as subgraph border nodes.
|
|
*
|
|
* The nesting graph idea comes from Sander, "Layout of Compound Directed
|
|
* Graphs."
|
|
*/
|
|
function run(g) {
|
|
var root = util.addDummyNode(g, "root", {}, "_root"),
|
|
depths = treeDepths(g),
|
|
height = _.max(depths) - 1,
|
|
nodeSep = 2 * height + 1;
|
|
|
|
g.graph().nestingRoot = root;
|
|
|
|
// Multiply minlen by nodeSep to align nodes on non-border ranks.
|
|
_.each(g.edges(), function(e) { g.edge(e).minlen *= nodeSep; });
|
|
|
|
// Calculate a weight that is sufficient to keep subgraphs vertically compact
|
|
var weight = sumWeights(g) + 1;
|
|
|
|
// Create border nodes and link them up
|
|
_.each(g.children(), function(child) {
|
|
dfs(g, root, nodeSep, weight, height, depths, child);
|
|
});
|
|
|
|
// Save the multiplier for node layers for later removal of empty border
|
|
// layers.
|
|
g.graph().nodeRankFactor = nodeSep;
|
|
}
|
|
|
|
function dfs(g, root, nodeSep, weight, height, depths, v) {
|
|
var children = g.children(v);
|
|
if (!children.length) {
|
|
if (v !== root) {
|
|
g.setEdge(root, v, { weight: 0, minlen: nodeSep });
|
|
}
|
|
return;
|
|
}
|
|
|
|
var top = util.addBorderNode(g, "_bt"),
|
|
bottom = util.addBorderNode(g, "_bb"),
|
|
label = g.node(v);
|
|
|
|
g.setParent(top, v);
|
|
label.borderTop = top;
|
|
g.setParent(bottom, v);
|
|
label.borderBottom = bottom;
|
|
|
|
_.each(children, function(child) {
|
|
dfs(g, root, nodeSep, weight, height, depths, child);
|
|
|
|
var childNode = g.node(child),
|
|
childTop = childNode.borderTop ? childNode.borderTop : child,
|
|
childBottom = childNode.borderBottom ? childNode.borderBottom : child,
|
|
thisWeight = childNode.borderTop ? weight : 2 * weight,
|
|
minlen = childTop !== childBottom ? 1 : height - depths[v] + 1;
|
|
|
|
g.setEdge(top, childTop, {
|
|
weight: thisWeight,
|
|
minlen: minlen,
|
|
nestingEdge: true
|
|
});
|
|
|
|
g.setEdge(childBottom, bottom, {
|
|
weight: thisWeight,
|
|
minlen: minlen,
|
|
nestingEdge: true
|
|
});
|
|
});
|
|
|
|
if (!g.parent(v)) {
|
|
g.setEdge(root, top, { weight: 0, minlen: height + depths[v] });
|
|
}
|
|
}
|
|
|
|
function treeDepths(g) {
|
|
var depths = {};
|
|
function dfs(v, depth) {
|
|
var children = g.children(v);
|
|
if (children && children.length) {
|
|
_.each(children, function(child) {
|
|
dfs(child, depth + 1);
|
|
});
|
|
}
|
|
depths[v] = depth;
|
|
}
|
|
_.each(g.children(), function(v) { dfs(v, 1); });
|
|
return depths;
|
|
}
|
|
|
|
function sumWeights(g) {
|
|
return _.reduce(g.edges(), function(acc, e) {
|
|
return acc + g.edge(e).weight;
|
|
}, 0);
|
|
}
|
|
|
|
function cleanup(g) {
|
|
var graphLabel = g.graph();
|
|
g.removeNode(graphLabel.nestingRoot);
|
|
delete graphLabel.nestingRoot;
|
|
_.each(g.edges(), function(e) {
|
|
var edge = g.edge(e);
|
|
if (edge.nestingEdge) {
|
|
g.removeEdge(e);
|
|
}
|
|
});
|
|
}
|
|
|
|
},{"./lodash":38,"./util":57}],40:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
util = require("./util");
|
|
|
|
module.exports = {
|
|
run: run,
|
|
undo: undo
|
|
};
|
|
|
|
/*
|
|
* Breaks any long edges in the graph into short segments that span 1 layer
|
|
* each. This operation is undoable with the denormalize function.
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. The input graph is a DAG.
|
|
* 2. Each node in the graph has a "rank" property.
|
|
*
|
|
* Post-condition:
|
|
*
|
|
* 1. All edges in the graph have a length of 1.
|
|
* 2. Dummy nodes are added where edges have been split into segments.
|
|
* 3. The graph is augmented with a "dummyChains" attribute which contains
|
|
* the first dummy in each chain of dummy nodes produced.
|
|
*/
|
|
function run(g) {
|
|
g.graph().dummyChains = [];
|
|
_.each(g.edges(), function(edge) { normalizeEdge(g, edge); });
|
|
}
|
|
|
|
function normalizeEdge(g, e) {
|
|
var v = e.v,
|
|
vRank = g.node(v).rank,
|
|
w = e.w,
|
|
wRank = g.node(w).rank,
|
|
name = e.name,
|
|
edgeLabel = g.edge(e),
|
|
labelRank = edgeLabel.labelRank;
|
|
|
|
if (wRank === vRank + 1) return;
|
|
|
|
g.removeEdge(e);
|
|
|
|
var dummy, attrs, i;
|
|
for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) {
|
|
edgeLabel.points = [];
|
|
attrs = {
|
|
width: 0, height: 0,
|
|
edgeLabel: edgeLabel, edgeObj: e,
|
|
rank: vRank
|
|
};
|
|
dummy = util.addDummyNode(g, "edge", attrs, "_d");
|
|
if (vRank === labelRank) {
|
|
attrs.width = edgeLabel.width;
|
|
attrs.height = edgeLabel.height;
|
|
attrs.dummy = "edge-label";
|
|
attrs.labelpos = edgeLabel.labelpos;
|
|
}
|
|
g.setEdge(v, dummy, { weight: edgeLabel.weight }, name);
|
|
if (i === 0) {
|
|
g.graph().dummyChains.push(dummy);
|
|
}
|
|
v = dummy;
|
|
}
|
|
|
|
g.setEdge(v, w, { weight: edgeLabel.weight }, name);
|
|
}
|
|
|
|
function undo(g) {
|
|
_.each(g.graph().dummyChains, function(v) {
|
|
var node = g.node(v),
|
|
origLabel = node.edgeLabel,
|
|
w;
|
|
g.setEdge(node.edgeObj, origLabel);
|
|
while (node.dummy) {
|
|
w = g.successors(v)[0];
|
|
g.removeNode(v);
|
|
origLabel.points.push({ x: node.x, y: node.y });
|
|
if (node.dummy === "edge-label") {
|
|
origLabel.x = node.x;
|
|
origLabel.y = node.y;
|
|
origLabel.width = node.width;
|
|
origLabel.height = node.height;
|
|
}
|
|
v = w;
|
|
node = g.node(v);
|
|
}
|
|
});
|
|
}
|
|
|
|
},{"./lodash":38,"./util":57}],41:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = addSubgraphConstraints;
|
|
|
|
function addSubgraphConstraints(g, cg, vs) {
|
|
var prev = {},
|
|
rootPrev;
|
|
|
|
_.each(vs, function(v) {
|
|
var child = g.parent(v),
|
|
parent,
|
|
prevChild;
|
|
while (child) {
|
|
parent = g.parent(child);
|
|
if (parent) {
|
|
prevChild = prev[parent];
|
|
prev[parent] = child;
|
|
} else {
|
|
prevChild = rootPrev;
|
|
rootPrev = child;
|
|
}
|
|
if (prevChild && prevChild !== child) {
|
|
cg.setEdge(prevChild, child);
|
|
return;
|
|
}
|
|
child = parent;
|
|
}
|
|
});
|
|
|
|
/*
|
|
function dfs(v) {
|
|
var children = v ? g.children(v) : g.children();
|
|
if (children.length) {
|
|
var min = Number.POSITIVE_INFINITY,
|
|
subgraphs = [];
|
|
_.each(children, function(child) {
|
|
var childMin = dfs(child);
|
|
if (g.children(child).length) {
|
|
subgraphs.push({ v: child, order: childMin });
|
|
}
|
|
min = Math.min(min, childMin);
|
|
});
|
|
_.reduce(_.sortBy(subgraphs, "order"), function(prev, curr) {
|
|
cg.setEdge(prev.v, curr.v);
|
|
return curr;
|
|
});
|
|
return min;
|
|
}
|
|
return g.node(v).order;
|
|
}
|
|
dfs(undefined);
|
|
*/
|
|
}
|
|
|
|
},{"../lodash":38}],42:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = barycenter;
|
|
|
|
function barycenter(g, movable) {
|
|
return _.map(movable, function(v) {
|
|
var inV = g.inEdges(v);
|
|
if (!inV.length) {
|
|
return { v: v };
|
|
} else {
|
|
var result = _.reduce(inV, function(acc, e) {
|
|
var edge = g.edge(e),
|
|
nodeU = g.node(e.v);
|
|
return {
|
|
sum: acc.sum + (edge.weight * nodeU.order),
|
|
weight: acc.weight + edge.weight
|
|
};
|
|
}, { sum: 0, weight: 0 });
|
|
|
|
return {
|
|
v: v,
|
|
barycenter: result.sum / result.weight,
|
|
weight: result.weight
|
|
};
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
},{"../lodash":38}],43:[function(require,module,exports){
|
|
var _ = require("../lodash"),
|
|
Graph = require("../graphlib").Graph;
|
|
|
|
module.exports = buildLayerGraph;
|
|
|
|
/*
|
|
* Constructs a graph that can be used to sort a layer of nodes. The graph will
|
|
* contain all base and subgraph nodes from the request layer in their original
|
|
* hierarchy and any edges that are incident on these nodes and are of the type
|
|
* requested by the "relationship" parameter.
|
|
*
|
|
* Nodes from the requested rank that do not have parents are assigned a root
|
|
* node in the output graph, which is set in the root graph attribute. This
|
|
* makes it easy to walk the hierarchy of movable nodes during ordering.
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Input graph is a DAG
|
|
* 2. Base nodes in the input graph have a rank attribute
|
|
* 3. Subgraph nodes in the input graph has minRank and maxRank attributes
|
|
* 4. Edges have an assigned weight
|
|
*
|
|
* Post-conditions:
|
|
*
|
|
* 1. Output graph has all nodes in the movable rank with preserved
|
|
* hierarchy.
|
|
* 2. Root nodes in the movable layer are made children of the node
|
|
* indicated by the root attribute of the graph.
|
|
* 3. Non-movable nodes incident on movable nodes, selected by the
|
|
* relationship parameter, are included in the graph (without hierarchy).
|
|
* 4. Edges incident on movable nodes, selected by the relationship
|
|
* parameter, are added to the output graph.
|
|
* 5. The weights for copied edges are aggregated as need, since the output
|
|
* graph is not a multi-graph.
|
|
*/
|
|
function buildLayerGraph(g, rank, relationship) {
|
|
var root = createRootNode(g),
|
|
result = new Graph({ compound: true }).setGraph({ root: root })
|
|
.setDefaultNodeLabel(function(v) { return g.node(v); });
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v),
|
|
parent = g.parent(v);
|
|
|
|
if (node.rank === rank || node.minRank <= rank && rank <= node.maxRank) {
|
|
result.setNode(v);
|
|
result.setParent(v, parent || root);
|
|
|
|
// This assumes we have only short edges!
|
|
_.each(g[relationship](v), function(e) {
|
|
var u = e.v === v ? e.w : e.v,
|
|
edge = result.edge(u, v),
|
|
weight = !_.isUndefined(edge) ? edge.weight : 0;
|
|
result.setEdge(u, v, { weight: g.edge(e).weight + weight });
|
|
});
|
|
|
|
if (_.has(node, "minRank")) {
|
|
result.setNode(v, {
|
|
borderLeft: node.borderLeft[rank],
|
|
borderRight: node.borderRight[rank]
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
return result;
|
|
}
|
|
|
|
function createRootNode(g) {
|
|
var v;
|
|
while (g.hasNode((v = _.uniqueId("_root"))));
|
|
return v;
|
|
}
|
|
|
|
},{"../graphlib":35,"../lodash":38}],44:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = crossCount;
|
|
|
|
/*
|
|
* A function that takes a layering (an array of layers, each with an array of
|
|
* ordererd nodes) and a graph and returns a weighted crossing count.
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Input graph must be simple (not a multigraph), directed, and include
|
|
* only simple edges.
|
|
* 2. Edges in the input graph must have assigned weights.
|
|
*
|
|
* Post-conditions:
|
|
*
|
|
* 1. The graph and layering matrix are left unchanged.
|
|
*
|
|
* This algorithm is derived from Barth, et al., "Bilayer Cross Counting."
|
|
*/
|
|
function crossCount(g, layering) {
|
|
var cc = 0;
|
|
for (var i = 1; i < layering.length; ++i) {
|
|
cc += twoLayerCrossCount(g, layering[i-1], layering[i]);
|
|
}
|
|
return cc;
|
|
}
|
|
|
|
function twoLayerCrossCount(g, northLayer, southLayer) {
|
|
// Sort all of the edges between the north and south layers by their position
|
|
// in the north layer and then the south. Map these edges to the position of
|
|
// their head in the south layer.
|
|
var southPos = _.zipObject(southLayer,
|
|
_.map(southLayer, function (v, i) { return i; }));
|
|
var southEntries = _.flatten(_.map(northLayer, function(v) {
|
|
return _.chain(g.outEdges(v))
|
|
.map(function(e) {
|
|
return { pos: southPos[e.w], weight: g.edge(e).weight };
|
|
})
|
|
.sortBy("pos")
|
|
.value();
|
|
}), true);
|
|
|
|
// Build the accumulator tree
|
|
var firstIndex = 1;
|
|
while (firstIndex < southLayer.length) firstIndex <<= 1;
|
|
var treeSize = 2 * firstIndex - 1;
|
|
firstIndex -= 1;
|
|
var tree = _.map(new Array(treeSize), function() { return 0; });
|
|
|
|
// Calculate the weighted crossings
|
|
var cc = 0;
|
|
_.each(southEntries.forEach(function(entry) {
|
|
var index = entry.pos + firstIndex;
|
|
tree[index] += entry.weight;
|
|
var weightSum = 0;
|
|
while (index > 0) {
|
|
if (index % 2) {
|
|
weightSum += tree[index + 1];
|
|
}
|
|
index = (index - 1) >> 1;
|
|
tree[index] += entry.weight;
|
|
}
|
|
cc += entry.weight * weightSum;
|
|
}));
|
|
|
|
return cc;
|
|
}
|
|
|
|
},{"../lodash":38}],45:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash"),
|
|
initOrder = require("./init-order"),
|
|
crossCount = require("./cross-count"),
|
|
sortSubgraph = require("./sort-subgraph"),
|
|
buildLayerGraph = require("./build-layer-graph"),
|
|
addSubgraphConstraints = require("./add-subgraph-constraints"),
|
|
Graph = require("../graphlib").Graph,
|
|
util = require("../util");
|
|
|
|
module.exports = order;
|
|
|
|
/*
|
|
* Applies heuristics to minimize edge crossings in the graph and sets the best
|
|
* order solution as an order attribute on each node.
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Graph must be DAG
|
|
* 2. Graph nodes must be objects with a "rank" attribute
|
|
* 3. Graph edges must have the "weight" attribute
|
|
*
|
|
* Post-conditions:
|
|
*
|
|
* 1. Graph nodes will have an "order" attribute based on the results of the
|
|
* algorithm.
|
|
*/
|
|
function order(g) {
|
|
var maxRank = util.maxRank(g),
|
|
downLayerGraphs = buildLayerGraphs(g, _.range(1, maxRank + 1), "inEdges"),
|
|
upLayerGraphs = buildLayerGraphs(g, _.range(maxRank - 1, -1, -1), "outEdges");
|
|
|
|
var layering = initOrder(g);
|
|
assignOrder(g, layering);
|
|
|
|
var bestCC = Number.POSITIVE_INFINITY,
|
|
best;
|
|
|
|
for (var i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {
|
|
sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2);
|
|
|
|
layering = util.buildLayerMatrix(g);
|
|
var cc = crossCount(g, layering);
|
|
if (cc < bestCC) {
|
|
lastBest = 0;
|
|
best = _.cloneDeep(layering);
|
|
bestCC = cc;
|
|
}
|
|
}
|
|
|
|
assignOrder(g, best);
|
|
}
|
|
|
|
function buildLayerGraphs(g, ranks, relationship) {
|
|
return _.map(ranks, function(rank) {
|
|
return buildLayerGraph(g, rank, relationship);
|
|
});
|
|
}
|
|
|
|
function sweepLayerGraphs(layerGraphs, biasRight) {
|
|
var cg = new Graph();
|
|
_.each(layerGraphs, function(lg) {
|
|
var root = lg.graph().root;
|
|
var sorted = sortSubgraph(lg, root, cg, biasRight);
|
|
_.each(sorted.vs, function(v, i) {
|
|
lg.node(v).order = i;
|
|
});
|
|
addSubgraphConstraints(lg, cg, sorted.vs);
|
|
});
|
|
}
|
|
|
|
function assignOrder(g, layering) {
|
|
_.each(layering, function(layer) {
|
|
_.each(layer, function(v, i) {
|
|
g.node(v).order = i;
|
|
});
|
|
});
|
|
}
|
|
|
|
},{"../graphlib":35,"../lodash":38,"../util":57,"./add-subgraph-constraints":41,"./build-layer-graph":43,"./cross-count":44,"./init-order":46,"./sort-subgraph":48}],46:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = initOrder;
|
|
|
|
/*
|
|
* Assigns an initial order value for each node by performing a DFS search
|
|
* starting from nodes in the first rank. Nodes are assigned an order in their
|
|
* rank as they are first visited.
|
|
*
|
|
* This approach comes from Gansner, et al., "A Technique for Drawing Directed
|
|
* Graphs."
|
|
*
|
|
* Returns a layering matrix with an array per layer and each layer sorted by
|
|
* the order of its nodes.
|
|
*/
|
|
function initOrder(g) {
|
|
var visited = {},
|
|
simpleNodes = _.filter(g.nodes(), function(v) {
|
|
return !g.children(v).length;
|
|
}),
|
|
maxRank = _.max(_.map(simpleNodes, function(v) { return g.node(v).rank; })),
|
|
layers = _.map(_.range(maxRank + 1), function() { return []; });
|
|
|
|
function dfs(v) {
|
|
if (_.has(visited, v)) return;
|
|
visited[v] = true;
|
|
var node = g.node(v);
|
|
layers[node.rank].push(v);
|
|
_.each(g.successors(v), dfs);
|
|
}
|
|
|
|
var orderedVs = _.sortBy(simpleNodes, function(v) { return g.node(v).rank; });
|
|
_.each(orderedVs, dfs);
|
|
|
|
return layers;
|
|
}
|
|
|
|
},{"../lodash":38}],47:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = resolveConflicts;
|
|
|
|
/*
|
|
* Given a list of entries of the form {v, barycenter, weight} and a
|
|
* constraint graph this function will resolve any conflicts between the
|
|
* constraint graph and the barycenters for the entries. If the barycenters for
|
|
* an entry would violate a constraint in the constraint graph then we coalesce
|
|
* the nodes in the conflict into a new node that respects the contraint and
|
|
* aggregates barycenter and weight information.
|
|
*
|
|
* This implementation is based on the description in Forster, "A Fast and
|
|
* Simple Hueristic for Constrained Two-Level Crossing Reduction," thought it
|
|
* differs in some specific details.
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Each entry has the form {v, barycenter, weight}, or if the node has
|
|
* no barycenter, then {v}.
|
|
*
|
|
* Returns:
|
|
*
|
|
* A new list of entries of the form {vs, i, barycenter, weight}. The list
|
|
* `vs` may either be a singleton or it may be an aggregation of nodes
|
|
* ordered such that they do not violate constraints from the constraint
|
|
* graph. The property `i` is the lowest original index of any of the
|
|
* elements in `vs`.
|
|
*/
|
|
function resolveConflicts(entries, cg) {
|
|
var mappedEntries = {};
|
|
_.each(entries, function(entry, i) {
|
|
var tmp = mappedEntries[entry.v] = {
|
|
indegree: 0,
|
|
"in": [],
|
|
out: [],
|
|
vs: [entry.v],
|
|
i: i
|
|
};
|
|
if (!_.isUndefined(entry.barycenter)) {
|
|
tmp.barycenter = entry.barycenter;
|
|
tmp.weight = entry.weight;
|
|
}
|
|
});
|
|
|
|
_.each(cg.edges(), function(e) {
|
|
var entryV = mappedEntries[e.v],
|
|
entryW = mappedEntries[e.w];
|
|
if (!_.isUndefined(entryV) && !_.isUndefined(entryW)) {
|
|
entryW.indegree++;
|
|
entryV.out.push(mappedEntries[e.w]);
|
|
}
|
|
});
|
|
|
|
var sourceSet = _.filter(mappedEntries, function(entry) {
|
|
return !entry.indegree;
|
|
});
|
|
|
|
return doResolveConflicts(sourceSet);
|
|
}
|
|
|
|
function doResolveConflicts(sourceSet) {
|
|
var entries = [];
|
|
|
|
function handleIn(vEntry) {
|
|
return function(uEntry) {
|
|
if (uEntry.merged) {
|
|
return;
|
|
}
|
|
if (_.isUndefined(uEntry.barycenter) ||
|
|
_.isUndefined(vEntry.barycenter) ||
|
|
uEntry.barycenter >= vEntry.barycenter) {
|
|
mergeEntries(vEntry, uEntry);
|
|
}
|
|
};
|
|
}
|
|
|
|
function handleOut(vEntry) {
|
|
return function(wEntry) {
|
|
wEntry["in"].push(vEntry);
|
|
if (--wEntry.indegree === 0) {
|
|
sourceSet.push(wEntry);
|
|
}
|
|
};
|
|
}
|
|
|
|
while (sourceSet.length) {
|
|
var entry = sourceSet.pop();
|
|
entries.push(entry);
|
|
_.each(entry["in"].reverse(), handleIn(entry));
|
|
_.each(entry.out, handleOut(entry));
|
|
}
|
|
|
|
return _.chain(entries)
|
|
.filter(function(entry) { return !entry.merged; })
|
|
.map(function(entry) {
|
|
return _.pick(entry, ["vs", "i", "barycenter", "weight"]);
|
|
})
|
|
.value();
|
|
}
|
|
|
|
function mergeEntries(target, source) {
|
|
var sum = 0,
|
|
weight = 0;
|
|
|
|
if (target.weight) {
|
|
sum += target.barycenter * target.weight;
|
|
weight += target.weight;
|
|
}
|
|
|
|
if (source.weight) {
|
|
sum += source.barycenter * source.weight;
|
|
weight += source.weight;
|
|
}
|
|
|
|
target.vs = source.vs.concat(target.vs);
|
|
target.barycenter = sum / weight;
|
|
target.weight = weight;
|
|
target.i = Math.min(source.i, target.i);
|
|
source.merged = true;
|
|
}
|
|
|
|
},{"../lodash":38}],48:[function(require,module,exports){
|
|
var _ = require("../lodash"),
|
|
barycenter = require("./barycenter"),
|
|
resolveConflicts = require("./resolve-conflicts"),
|
|
sort = require("./sort");
|
|
|
|
module.exports = sortSubgraph;
|
|
|
|
function sortSubgraph(g, v, cg, biasRight) {
|
|
var movable = g.children(v),
|
|
node = g.node(v),
|
|
bl = node ? node.borderLeft : undefined,
|
|
br = node ? node.borderRight: undefined,
|
|
subgraphs = {};
|
|
|
|
if (bl) {
|
|
movable = _.filter(movable, function(w) {
|
|
return w !== bl && w !== br;
|
|
});
|
|
}
|
|
|
|
var barycenters = barycenter(g, movable);
|
|
_.each(barycenters, function(entry) {
|
|
if (g.children(entry.v).length) {
|
|
var subgraphResult = sortSubgraph(g, entry.v, cg, biasRight);
|
|
subgraphs[entry.v] = subgraphResult;
|
|
if (_.has(subgraphResult, "barycenter")) {
|
|
mergeBarycenters(entry, subgraphResult);
|
|
}
|
|
}
|
|
});
|
|
|
|
var entries = resolveConflicts(barycenters, cg);
|
|
expandSubgraphs(entries, subgraphs);
|
|
|
|
var result = sort(entries, biasRight);
|
|
|
|
if (bl) {
|
|
result.vs = _.flatten([bl, result.vs, br], true);
|
|
if (g.predecessors(bl).length) {
|
|
var blPred = g.node(g.predecessors(bl)[0]),
|
|
brPred = g.node(g.predecessors(br)[0]);
|
|
if (!_.has(result, "barycenter")) {
|
|
result.barycenter = 0;
|
|
result.weight = 0;
|
|
}
|
|
result.barycenter = (result.barycenter * result.weight +
|
|
blPred.order + brPred.order) / (result.weight + 2);
|
|
result.weight += 2;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
function expandSubgraphs(entries, subgraphs) {
|
|
_.each(entries, function(entry) {
|
|
entry.vs = _.flatten(entry.vs.map(function(v) {
|
|
if (subgraphs[v]) {
|
|
return subgraphs[v].vs;
|
|
}
|
|
return v;
|
|
}), true);
|
|
});
|
|
}
|
|
|
|
function mergeBarycenters(target, other) {
|
|
if (!_.isUndefined(target.barycenter)) {
|
|
target.barycenter = (target.barycenter * target.weight +
|
|
other.barycenter * other.weight) /
|
|
(target.weight + other.weight);
|
|
target.weight += other.weight;
|
|
} else {
|
|
target.barycenter = other.barycenter;
|
|
target.weight = other.weight;
|
|
}
|
|
}
|
|
|
|
},{"../lodash":38,"./barycenter":42,"./resolve-conflicts":47,"./sort":49}],49:[function(require,module,exports){
|
|
var _ = require("../lodash"),
|
|
util = require("../util");
|
|
|
|
module.exports = sort;
|
|
|
|
function sort(entries, biasRight) {
|
|
var parts = util.partition(entries, function(entry) {
|
|
return _.has(entry, "barycenter");
|
|
});
|
|
var sortable = parts.lhs,
|
|
unsortable = _.sortBy(parts.rhs, function(entry) { return -entry.i; }),
|
|
vs = [],
|
|
sum = 0,
|
|
weight = 0,
|
|
vsIndex = 0;
|
|
|
|
sortable.sort(compareWithBias(!!biasRight));
|
|
|
|
vsIndex = consumeUnsortable(vs, unsortable, vsIndex);
|
|
|
|
_.each(sortable, function (entry) {
|
|
vsIndex += entry.vs.length;
|
|
vs.push(entry.vs);
|
|
sum += entry.barycenter * entry.weight;
|
|
weight += entry.weight;
|
|
vsIndex = consumeUnsortable(vs, unsortable, vsIndex);
|
|
});
|
|
|
|
var result = { vs: _.flatten(vs, true) };
|
|
if (weight) {
|
|
result.barycenter = sum / weight;
|
|
result.weight = weight;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
function consumeUnsortable(vs, unsortable, index) {
|
|
var last;
|
|
while (unsortable.length && (last = _.last(unsortable)).i <= index) {
|
|
unsortable.pop();
|
|
vs.push(last.vs);
|
|
index++;
|
|
}
|
|
return index;
|
|
}
|
|
|
|
function compareWithBias(bias) {
|
|
return function(entryV, entryW) {
|
|
if (entryV.barycenter < entryW.barycenter) {
|
|
return -1;
|
|
} else if (entryV.barycenter > entryW.barycenter) {
|
|
return 1;
|
|
}
|
|
|
|
return !bias ? entryV.i - entryW.i : entryW.i - entryV.i;
|
|
};
|
|
}
|
|
|
|
},{"../lodash":38,"../util":57}],50:[function(require,module,exports){
|
|
var _ = require("./lodash");
|
|
|
|
module.exports = parentDummyChains;
|
|
|
|
function parentDummyChains(g) {
|
|
var postorderNums = postorder(g);
|
|
|
|
_.each(g.graph().dummyChains, function(v) {
|
|
var node = g.node(v),
|
|
edgeObj = node.edgeObj,
|
|
pathData = findPath(g, postorderNums, edgeObj.v, edgeObj.w),
|
|
path = pathData.path,
|
|
lca = pathData.lca,
|
|
pathIdx = 0,
|
|
pathV = path[pathIdx],
|
|
ascending = true;
|
|
|
|
while (v !== edgeObj.w) {
|
|
node = g.node(v);
|
|
|
|
if (ascending) {
|
|
while ((pathV = path[pathIdx]) !== lca &&
|
|
g.node(pathV).maxRank < node.rank) {
|
|
pathIdx++;
|
|
}
|
|
|
|
if (pathV === lca) {
|
|
ascending = false;
|
|
}
|
|
}
|
|
|
|
if (!ascending) {
|
|
while (pathIdx < path.length - 1 &&
|
|
g.node(pathV = path[pathIdx + 1]).minRank <= node.rank) {
|
|
pathIdx++;
|
|
}
|
|
pathV = path[pathIdx];
|
|
}
|
|
|
|
g.setParent(v, pathV);
|
|
v = g.successors(v)[0];
|
|
}
|
|
});
|
|
}
|
|
|
|
// Find a path from v to w through the lowest common ancestor (LCA). Return the
|
|
// full path and the LCA.
|
|
function findPath(g, postorderNums, v, w) {
|
|
var vPath = [],
|
|
wPath = [],
|
|
low = Math.min(postorderNums[v].low, postorderNums[w].low),
|
|
lim = Math.max(postorderNums[v].lim, postorderNums[w].lim),
|
|
parent,
|
|
lca;
|
|
|
|
// Traverse up from v to find the LCA
|
|
parent = v;
|
|
do {
|
|
parent = g.parent(parent);
|
|
vPath.push(parent);
|
|
} while (parent &&
|
|
(postorderNums[parent].low > low || lim > postorderNums[parent].lim));
|
|
lca = parent;
|
|
|
|
// Traverse from w to LCA
|
|
parent = w;
|
|
while ((parent = g.parent(parent)) !== lca) {
|
|
wPath.push(parent);
|
|
}
|
|
|
|
return { path: vPath.concat(wPath.reverse()), lca: lca };
|
|
}
|
|
|
|
function postorder(g) {
|
|
var result = {},
|
|
lim = 0;
|
|
|
|
function dfs(v) {
|
|
var low = lim;
|
|
_.each(g.children(v), dfs);
|
|
result[v] = { low: low, lim: lim++ };
|
|
}
|
|
_.each(g.children(), dfs);
|
|
|
|
return result;
|
|
}
|
|
|
|
},{"./lodash":38}],51:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash"),
|
|
Graph = require("../graphlib").Graph,
|
|
util = require("../util");
|
|
|
|
/*
|
|
* This module provides coordinate assignment based on Brandes and Köpf, "Fast
|
|
* and Simple Horizontal Coordinate Assignment."
|
|
*/
|
|
|
|
module.exports = {
|
|
positionX: positionX,
|
|
findType1Conflicts: findType1Conflicts,
|
|
findType2Conflicts: findType2Conflicts,
|
|
addConflict: addConflict,
|
|
hasConflict: hasConflict,
|
|
verticalAlignment: verticalAlignment,
|
|
horizontalCompaction: horizontalCompaction,
|
|
alignCoordinates: alignCoordinates,
|
|
findSmallestWidthAlignment: findSmallestWidthAlignment,
|
|
balance: balance
|
|
};
|
|
|
|
/*
|
|
* Marks all edges in the graph with a type-1 conflict with the "type1Conflict"
|
|
* property. A type-1 conflict is one where a non-inner segment crosses an
|
|
* inner segment. An inner segment is an edge with both incident nodes marked
|
|
* with the "dummy" property.
|
|
*
|
|
* This algorithm scans layer by layer, starting with the second, for type-1
|
|
* conflicts between the current layer and the previous layer. For each layer
|
|
* it scans the nodes from left to right until it reaches one that is incident
|
|
* on an inner segment. It then scans predecessors to determine if they have
|
|
* edges that cross that inner segment. At the end a final scan is done for all
|
|
* nodes on the current rank to see if they cross the last visited inner
|
|
* segment.
|
|
*
|
|
* This algorithm (safely) assumes that a dummy node will only be incident on a
|
|
* single node in the layers being scanned.
|
|
*/
|
|
function findType1Conflicts(g, layering) {
|
|
var conflicts = {};
|
|
|
|
function visitLayer(prevLayer, layer) {
|
|
var
|
|
// last visited node in the previous layer that is incident on an inner
|
|
// segment.
|
|
k0 = 0,
|
|
// Tracks the last node in this layer scanned for crossings with a type-1
|
|
// segment.
|
|
scanPos = 0,
|
|
prevLayerLength = prevLayer.length,
|
|
lastNode = _.last(layer);
|
|
|
|
_.each(layer, function(v, i) {
|
|
var w = findOtherInnerSegmentNode(g, v),
|
|
k1 = w ? g.node(w).order : prevLayerLength;
|
|
|
|
if (w || v === lastNode) {
|
|
_.each(layer.slice(scanPos, i +1), function(scanNode) {
|
|
_.each(g.predecessors(scanNode), function(u) {
|
|
var uLabel = g.node(u),
|
|
uPos = uLabel.order;
|
|
if ((uPos < k0 || k1 < uPos) &&
|
|
!(uLabel.dummy && g.node(scanNode).dummy)) {
|
|
addConflict(conflicts, u, scanNode);
|
|
}
|
|
});
|
|
});
|
|
scanPos = i + 1;
|
|
k0 = k1;
|
|
}
|
|
});
|
|
|
|
return layer;
|
|
}
|
|
|
|
_.reduce(layering, visitLayer);
|
|
return conflicts;
|
|
}
|
|
|
|
function findType2Conflicts(g, layering) {
|
|
var conflicts = {};
|
|
|
|
function scan(south, southPos, southEnd, prevNorthBorder, nextNorthBorder) {
|
|
var v;
|
|
_.each(_.range(southPos, southEnd), function(i) {
|
|
v = south[i];
|
|
if (g.node(v).dummy) {
|
|
_.each(g.predecessors(v), function(u) {
|
|
var uNode = g.node(u);
|
|
if (uNode.dummy &&
|
|
(uNode.order < prevNorthBorder || uNode.order > nextNorthBorder)) {
|
|
addConflict(conflicts, u, v);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
function visitLayer(north, south) {
|
|
var prevNorthPos = -1,
|
|
nextNorthPos,
|
|
southPos = 0;
|
|
|
|
_.each(south, function(v, southLookahead) {
|
|
if (g.node(v).dummy === "border") {
|
|
var predecessors = g.predecessors(v);
|
|
if (predecessors.length) {
|
|
nextNorthPos = g.node(predecessors[0]).order;
|
|
scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos);
|
|
southPos = southLookahead;
|
|
prevNorthPos = nextNorthPos;
|
|
}
|
|
}
|
|
scan(south, southPos, south.length, nextNorthPos, north.length);
|
|
});
|
|
|
|
return south;
|
|
}
|
|
|
|
_.reduce(layering, visitLayer);
|
|
return conflicts;
|
|
}
|
|
|
|
function findOtherInnerSegmentNode(g, v) {
|
|
if (g.node(v).dummy) {
|
|
return _.find(g.predecessors(v), function(u) {
|
|
return g.node(u).dummy;
|
|
});
|
|
}
|
|
}
|
|
|
|
function addConflict(conflicts, v, w) {
|
|
if (v > w) {
|
|
var tmp = v;
|
|
v = w;
|
|
w = tmp;
|
|
}
|
|
|
|
var conflictsV = conflicts[v];
|
|
if (!conflictsV) {
|
|
conflicts[v] = conflictsV = {};
|
|
}
|
|
conflictsV[w] = true;
|
|
}
|
|
|
|
function hasConflict(conflicts, v, w) {
|
|
if (v > w) {
|
|
var tmp = v;
|
|
v = w;
|
|
w = tmp;
|
|
}
|
|
return _.has(conflicts[v], w);
|
|
}
|
|
|
|
/*
|
|
* Try to align nodes into vertical "blocks" where possible. This algorithm
|
|
* attempts to align a node with one of its median neighbors. If the edge
|
|
* connecting a neighbor is a type-1 conflict then we ignore that possibility.
|
|
* If a previous node has already formed a block with a node after the node
|
|
* we're trying to form a block with, we also ignore that possibility - our
|
|
* blocks would be split in that scenario.
|
|
*/
|
|
function verticalAlignment(g, layering, conflicts, neighborFn) {
|
|
var root = {},
|
|
align = {},
|
|
pos = {};
|
|
|
|
// We cache the position here based on the layering because the graph and
|
|
// layering may be out of sync. The layering matrix is manipulated to
|
|
// generate different extreme alignments.
|
|
_.each(layering, function(layer) {
|
|
_.each(layer, function(v, order) {
|
|
root[v] = v;
|
|
align[v] = v;
|
|
pos[v] = order;
|
|
});
|
|
});
|
|
|
|
_.each(layering, function(layer) {
|
|
var prevIdx = -1;
|
|
_.each(layer, function(v) {
|
|
var ws = neighborFn(v);
|
|
if (ws.length) {
|
|
ws = _.sortBy(ws, function(w) { return pos[w]; });
|
|
var mp = (ws.length - 1) / 2;
|
|
for (var i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) {
|
|
var w = ws[i];
|
|
if (align[v] === v &&
|
|
prevIdx < pos[w] &&
|
|
!hasConflict(conflicts, v, w)) {
|
|
align[w] = v;
|
|
align[v] = root[v] = root[w];
|
|
prevIdx = pos[w];
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
return { root: root, align: align };
|
|
}
|
|
|
|
function horizontalCompaction(g, layering, root, align, reverseSep) {
|
|
// This portion of the algorithm differs from BK due to a number of problems.
|
|
// Instead of their algorithm we construct a new block graph and do two
|
|
// sweeps. The first sweep places blocks with the smallest possible
|
|
// coordinates. The second sweep removes unused space by moving blocks to the
|
|
// greatest coordinates without violating separation.
|
|
var xs = {},
|
|
blockG = buildBlockGraph(g, layering, root, reverseSep);
|
|
|
|
// First pass, assign smallest coordinates via DFS
|
|
var visited = {};
|
|
function pass1(v) {
|
|
if (!_.has(visited, v)) {
|
|
visited[v] = true;
|
|
xs[v] = _.reduce(blockG.inEdges(v), function(max, e) {
|
|
pass1(e.v);
|
|
return Math.max(max, xs[e.v] + blockG.edge(e));
|
|
}, 0);
|
|
}
|
|
}
|
|
_.each(blockG.nodes(), pass1);
|
|
|
|
var borderType = reverseSep ? "borderLeft" : "borderRight";
|
|
function pass2(v) {
|
|
if (visited[v] !== 2) {
|
|
visited[v]++;
|
|
var node = g.node(v);
|
|
var min = _.reduce(blockG.outEdges(v), function(min, e) {
|
|
pass2(e.w);
|
|
return Math.min(min, xs[e.w] - blockG.edge(e));
|
|
}, Number.POSITIVE_INFINITY);
|
|
if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) {
|
|
xs[v] = Math.max(xs[v], min);
|
|
}
|
|
}
|
|
}
|
|
_.each(blockG.nodes(), pass2);
|
|
|
|
// Assign x coordinates to all nodes
|
|
_.each(align, function(v) {
|
|
xs[v] = xs[root[v]];
|
|
});
|
|
|
|
return xs;
|
|
}
|
|
|
|
|
|
function buildBlockGraph(g, layering, root, reverseSep) {
|
|
var blockGraph = new Graph(),
|
|
graphLabel = g.graph(),
|
|
sepFn = sep(graphLabel.nodesep, graphLabel.edgesep, reverseSep);
|
|
|
|
_.each(layering, function(layer) {
|
|
var u;
|
|
_.each(layer, function(v) {
|
|
var vRoot = root[v];
|
|
blockGraph.setNode(vRoot);
|
|
if (u) {
|
|
var uRoot = root[u],
|
|
prevMax = blockGraph.edge(uRoot, vRoot);
|
|
blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(g, v, u), prevMax || 0));
|
|
}
|
|
u = v;
|
|
});
|
|
});
|
|
|
|
return blockGraph;
|
|
}
|
|
|
|
/*
|
|
* Returns the alignment that has the smallest width of the given alignments.
|
|
*/
|
|
function findSmallestWidthAlignment(g, xss) {
|
|
return _.min(xss, function(xs) {
|
|
var min = _.min(xs, function(x, v) { return x - width(g, v) / 2; }),
|
|
max = _.max(xs, function(x, v) { return x + width(g, v) / 2; });
|
|
return max - min;
|
|
});
|
|
}
|
|
|
|
/*
|
|
* Align the coordinates of each of the layout alignments such that
|
|
* left-biased alignments have their minimum coordinate at the same point as
|
|
* the minimum coordinate of the smallest width alignment and right-biased
|
|
* alignments have their maximum coordinate at the same point as the maximum
|
|
* coordinate of the smallest width alignment.
|
|
*/
|
|
function alignCoordinates(xss, alignTo) {
|
|
var alignToMin = _.min(alignTo),
|
|
alignToMax = _.max(alignTo);
|
|
|
|
_.each(["u", "d"], function(vert) {
|
|
_.each(["l", "r"], function(horiz) {
|
|
var alignment = vert + horiz,
|
|
xs = xss[alignment],
|
|
delta;
|
|
if (xs === alignTo) return;
|
|
|
|
delta = horiz === "l" ? alignToMin - _.min(xs) : alignToMax - _.max(xs);
|
|
|
|
if (delta) {
|
|
xss[alignment] = _.mapValues(xs, function(x) { return x + delta; });
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function balance(xss, align) {
|
|
return _.mapValues(xss.ul, function(ignore, v) {
|
|
if (align) {
|
|
return xss[align.toLowerCase()][v];
|
|
} else {
|
|
var xs = _.sortBy(_.pluck(xss, v));
|
|
return (xs[1] + xs[2]) / 2;
|
|
}
|
|
});
|
|
}
|
|
|
|
function positionX(g) {
|
|
var layering = util.buildLayerMatrix(g),
|
|
conflicts = _.merge(findType1Conflicts(g, layering),
|
|
findType2Conflicts(g, layering));
|
|
|
|
var xss = {},
|
|
adjustedLayering;
|
|
_.each(["u", "d"], function(vert) {
|
|
adjustedLayering = vert === "u" ? layering : _.values(layering).reverse();
|
|
_.each(["l", "r"], function(horiz) {
|
|
if (horiz === "r") {
|
|
adjustedLayering = _.map(adjustedLayering, function(inner) {
|
|
return _.values(inner).reverse();
|
|
});
|
|
}
|
|
|
|
var neighborFn = _.bind(vert === "u" ? g.predecessors : g.successors, g);
|
|
var align = verticalAlignment(g, adjustedLayering, conflicts, neighborFn);
|
|
var xs = horizontalCompaction(g, adjustedLayering,
|
|
align.root, align.align,
|
|
horiz === "r");
|
|
if (horiz === "r") {
|
|
xs = _.mapValues(xs, function(x) { return -x; });
|
|
}
|
|
xss[vert + horiz] = xs;
|
|
});
|
|
});
|
|
|
|
var smallestWidth = findSmallestWidthAlignment(g, xss);
|
|
alignCoordinates(xss, smallestWidth);
|
|
return balance(xss, g.graph().align);
|
|
}
|
|
|
|
function sep(nodeSep, edgeSep, reverseSep) {
|
|
return function(g, v, w) {
|
|
var vLabel = g.node(v),
|
|
wLabel = g.node(w),
|
|
sum = 0,
|
|
delta;
|
|
|
|
sum += vLabel.width / 2;
|
|
if (_.has(vLabel, "labelpos")) {
|
|
switch (vLabel.labelpos.toLowerCase()) {
|
|
case "l": delta = -vLabel.width / 2; break;
|
|
case "r": delta = vLabel.width / 2; break;
|
|
}
|
|
}
|
|
if (delta) {
|
|
sum += reverseSep ? delta : -delta;
|
|
}
|
|
delta = 0;
|
|
|
|
sum += (vLabel.dummy ? edgeSep : nodeSep) / 2;
|
|
sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;
|
|
|
|
sum += wLabel.width / 2;
|
|
if (_.has(wLabel, "labelpos")) {
|
|
switch (wLabel.labelpos.toLowerCase()) {
|
|
case "l": delta = wLabel.width / 2; break;
|
|
case "r": delta = -wLabel.width / 2; break;
|
|
}
|
|
}
|
|
if (delta) {
|
|
sum += reverseSep ? delta : -delta;
|
|
}
|
|
delta = 0;
|
|
|
|
return sum;
|
|
};
|
|
}
|
|
|
|
function width(g, v) {
|
|
return g.node(v).width;
|
|
}
|
|
|
|
},{"../graphlib":35,"../lodash":38,"../util":57}],52:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash"),
|
|
util = require("../util"),
|
|
positionX = require("./bk").positionX;
|
|
|
|
module.exports = position;
|
|
|
|
function position(g) {
|
|
g = util.asNonCompoundGraph(g);
|
|
|
|
positionY(g);
|
|
_.each(positionX(g), function(x, v) {
|
|
g.node(v).x = x;
|
|
});
|
|
}
|
|
|
|
function positionY(g) {
|
|
var layering = util.buildLayerMatrix(g),
|
|
rankSep = g.graph().ranksep,
|
|
prevY = 0;
|
|
_.each(layering, function(layer) {
|
|
var maxHeight = _.max(_.map(layer, function(v) { return g.node(v).height; }));
|
|
_.each(layer, function(v) {
|
|
g.node(v).y = prevY + maxHeight / 2;
|
|
});
|
|
prevY += maxHeight + rankSep;
|
|
});
|
|
}
|
|
|
|
|
|
},{"../lodash":38,"../util":57,"./bk":51}],53:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash"),
|
|
Graph = require("../graphlib").Graph,
|
|
slack = require("./util").slack;
|
|
|
|
module.exports = feasibleTree;
|
|
|
|
/*
|
|
* Constructs a spanning tree with tight edges and adjusted the input node's
|
|
* ranks to achieve this. A tight edge is one that is has a length that matches
|
|
* its "minlen" attribute.
|
|
*
|
|
* The basic structure for this function is derived from Gansner, et al., "A
|
|
* Technique for Drawing Directed Graphs."
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Graph must be a DAG.
|
|
* 2. Graph must be connected.
|
|
* 3. Graph must have at least one node.
|
|
* 5. Graph nodes must have been previously assigned a "rank" property that
|
|
* respects the "minlen" property of incident edges.
|
|
* 6. Graph edges must have a "minlen" property.
|
|
*
|
|
* Post-conditions:
|
|
*
|
|
* - Graph nodes will have their rank adjusted to ensure that all edges are
|
|
* tight.
|
|
*
|
|
* Returns a tree (undirected graph) that is constructed using only "tight"
|
|
* edges.
|
|
*/
|
|
function feasibleTree(g) {
|
|
var t = new Graph({ directed: false });
|
|
|
|
// Choose arbitrary node from which to start our tree
|
|
var start = g.nodes()[0],
|
|
size = g.nodeCount();
|
|
t.setNode(start, {});
|
|
|
|
var edge, delta;
|
|
while (tightTree(t, g) < size) {
|
|
edge = findMinSlackEdge(t, g);
|
|
delta = t.hasNode(edge.v) ? slack(g, edge) : -slack(g, edge);
|
|
shiftRanks(t, g, delta);
|
|
}
|
|
|
|
return t;
|
|
}
|
|
|
|
/*
|
|
* Finds a maximal tree of tight edges and returns the number of nodes in the
|
|
* tree.
|
|
*/
|
|
function tightTree(t, g) {
|
|
function dfs(v) {
|
|
_.each(g.nodeEdges(v), function(e) {
|
|
var edgeV = e.v,
|
|
w = (v === edgeV) ? e.w : edgeV;
|
|
if (!t.hasNode(w) && !slack(g, e)) {
|
|
t.setNode(w, {});
|
|
t.setEdge(v, w, {});
|
|
dfs(w);
|
|
}
|
|
});
|
|
}
|
|
|
|
_.each(t.nodes(), dfs);
|
|
return t.nodeCount();
|
|
}
|
|
|
|
/*
|
|
* Finds the edge with the smallest slack that is incident on tree and returns
|
|
* it.
|
|
*/
|
|
function findMinSlackEdge(t, g) {
|
|
return _.min(g.edges(), function(e) {
|
|
if (t.hasNode(e.v) !== t.hasNode(e.w)) {
|
|
return slack(g, e);
|
|
}
|
|
});
|
|
}
|
|
|
|
function shiftRanks(t, g, delta) {
|
|
_.each(t.nodes(), function(v) {
|
|
g.node(v).rank += delta;
|
|
});
|
|
}
|
|
|
|
},{"../graphlib":35,"../lodash":38,"./util":56}],54:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var rankUtil = require("./util"),
|
|
longestPath = rankUtil.longestPath,
|
|
feasibleTree = require("./feasible-tree"),
|
|
networkSimplex = require("./network-simplex");
|
|
|
|
module.exports = rank;
|
|
|
|
/*
|
|
* Assigns a rank to each node in the input graph that respects the "minlen"
|
|
* constraint specified on edges between nodes.
|
|
*
|
|
* This basic structure is derived from Gansner, et al., "A Technique for
|
|
* Drawing Directed Graphs."
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Graph must be a connected DAG
|
|
* 2. Graph nodes must be objects
|
|
* 3. Graph edges must have "weight" and "minlen" attributes
|
|
*
|
|
* Post-conditions:
|
|
*
|
|
* 1. Graph nodes will have a "rank" attribute based on the results of the
|
|
* algorithm. Ranks can start at any index (including negative), we'll
|
|
* fix them up later.
|
|
*/
|
|
function rank(g) {
|
|
switch(g.graph().ranker) {
|
|
case "network-simplex": networkSimplexRanker(g); break;
|
|
case "tight-tree": tightTreeRanker(g); break;
|
|
case "longest-path": longestPathRanker(g); break;
|
|
default: networkSimplexRanker(g);
|
|
}
|
|
}
|
|
|
|
// A fast and simple ranker, but results are far from optimal.
|
|
var longestPathRanker = longestPath;
|
|
|
|
function tightTreeRanker(g) {
|
|
longestPath(g);
|
|
feasibleTree(g);
|
|
}
|
|
|
|
function networkSimplexRanker(g) {
|
|
networkSimplex(g);
|
|
}
|
|
|
|
},{"./feasible-tree":53,"./network-simplex":55,"./util":56}],55:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash"),
|
|
feasibleTree = require("./feasible-tree"),
|
|
slack = require("./util").slack,
|
|
initRank = require("./util").longestPath,
|
|
preorder = require("../graphlib").alg.preorder,
|
|
postorder = require("../graphlib").alg.postorder,
|
|
simplify = require("../util").simplify;
|
|
|
|
module.exports = networkSimplex;
|
|
|
|
// Expose some internals for testing purposes
|
|
networkSimplex.initLowLimValues = initLowLimValues;
|
|
networkSimplex.initCutValues = initCutValues;
|
|
networkSimplex.calcCutValue = calcCutValue;
|
|
networkSimplex.leaveEdge = leaveEdge;
|
|
networkSimplex.enterEdge = enterEdge;
|
|
networkSimplex.exchangeEdges = exchangeEdges;
|
|
|
|
/*
|
|
* The network simplex algorithm assigns ranks to each node in the input graph
|
|
* and iteratively improves the ranking to reduce the length of edges.
|
|
*
|
|
* Preconditions:
|
|
*
|
|
* 1. The input graph must be a DAG.
|
|
* 2. All nodes in the graph must have an object value.
|
|
* 3. All edges in the graph must have "minlen" and "weight" attributes.
|
|
*
|
|
* Postconditions:
|
|
*
|
|
* 1. All nodes in the graph will have an assigned "rank" attribute that has
|
|
* been optimized by the network simplex algorithm. Ranks start at 0.
|
|
*
|
|
*
|
|
* A rough sketch of the algorithm is as follows:
|
|
*
|
|
* 1. Assign initial ranks to each node. We use the longest path algorithm,
|
|
* which assigns ranks to the lowest position possible. In general this
|
|
* leads to very wide bottom ranks and unnecessarily long edges.
|
|
* 2. Construct a feasible tight tree. A tight tree is one such that all
|
|
* edges in the tree have no slack (difference between length of edge
|
|
* and minlen for the edge). This by itself greatly improves the assigned
|
|
* rankings by shorting edges.
|
|
* 3. Iteratively find edges that have negative cut values. Generally a
|
|
* negative cut value indicates that the edge could be removed and a new
|
|
* tree edge could be added to produce a more compact graph.
|
|
*
|
|
* Much of the algorithms here are derived from Gansner, et al., "A Technique
|
|
* for Drawing Directed Graphs." The structure of the file roughly follows the
|
|
* structure of the overall algorithm.
|
|
*/
|
|
function networkSimplex(g) {
|
|
g = simplify(g);
|
|
initRank(g);
|
|
var t = feasibleTree(g);
|
|
initLowLimValues(t);
|
|
initCutValues(t, g);
|
|
|
|
var e, f;
|
|
while ((e = leaveEdge(t))) {
|
|
f = enterEdge(t, g, e);
|
|
exchangeEdges(t, g, e, f);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Initializes cut values for all edges in the tree.
|
|
*/
|
|
function initCutValues(t, g) {
|
|
var vs = postorder(t, t.nodes());
|
|
vs = vs.slice(0, vs.length - 1);
|
|
_.each(vs, function(v) {
|
|
assignCutValue(t, g, v);
|
|
});
|
|
}
|
|
|
|
function assignCutValue(t, g, child) {
|
|
var childLab = t.node(child),
|
|
parent = childLab.parent;
|
|
t.edge(child, parent).cutvalue = calcCutValue(t, g, child);
|
|
}
|
|
|
|
/*
|
|
* Given the tight tree, its graph, and a child in the graph calculate and
|
|
* return the cut value for the edge between the child and its parent.
|
|
*/
|
|
function calcCutValue(t, g, child) {
|
|
var childLab = t.node(child),
|
|
parent = childLab.parent,
|
|
// True if the child is on the tail end of the edge in the directed graph
|
|
childIsTail = true,
|
|
// The graph's view of the tree edge we're inspecting
|
|
graphEdge = g.edge(child, parent),
|
|
// The accumulated cut value for the edge between this node and its parent
|
|
cutValue = 0;
|
|
|
|
if (!graphEdge) {
|
|
childIsTail = false;
|
|
graphEdge = g.edge(parent, child);
|
|
}
|
|
|
|
cutValue = graphEdge.weight;
|
|
|
|
_.each(g.nodeEdges(child), function(e) {
|
|
var isOutEdge = e.v === child,
|
|
other = isOutEdge ? e.w : e.v;
|
|
|
|
if (other !== parent) {
|
|
var pointsToHead = isOutEdge === childIsTail,
|
|
otherWeight = g.edge(e).weight;
|
|
|
|
cutValue += pointsToHead ? otherWeight : -otherWeight;
|
|
if (isTreeEdge(t, child, other)) {
|
|
var otherCutValue = t.edge(child, other).cutvalue;
|
|
cutValue += pointsToHead ? -otherCutValue : otherCutValue;
|
|
}
|
|
}
|
|
});
|
|
|
|
return cutValue;
|
|
}
|
|
|
|
function initLowLimValues(tree, root) {
|
|
if (arguments.length < 2) {
|
|
root = tree.nodes()[0];
|
|
}
|
|
dfsAssignLowLim(tree, {}, 1, root);
|
|
}
|
|
|
|
function dfsAssignLowLim(tree, visited, nextLim, v, parent) {
|
|
var low = nextLim,
|
|
label = tree.node(v);
|
|
|
|
visited[v] = true;
|
|
_.each(tree.neighbors(v), function(w) {
|
|
if (!_.has(visited, w)) {
|
|
nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);
|
|
}
|
|
});
|
|
|
|
label.low = low;
|
|
label.lim = nextLim++;
|
|
if (parent) {
|
|
label.parent = parent;
|
|
} else {
|
|
// TODO should be able to remove this when we incrementally update low lim
|
|
delete label.parent;
|
|
}
|
|
|
|
return nextLim;
|
|
}
|
|
|
|
function leaveEdge(tree) {
|
|
return _.find(tree.edges(), function(e) {
|
|
return tree.edge(e).cutvalue < 0;
|
|
});
|
|
}
|
|
|
|
function enterEdge(t, g, edge) {
|
|
var v = edge.v,
|
|
w = edge.w;
|
|
|
|
// For the rest of this function we assume that v is the tail and w is the
|
|
// head, so if we don't have this edge in the graph we should flip it to
|
|
// match the correct orientation.
|
|
if (!g.hasEdge(v, w)) {
|
|
v = edge.w;
|
|
w = edge.v;
|
|
}
|
|
|
|
var vLabel = t.node(v),
|
|
wLabel = t.node(w),
|
|
tailLabel = vLabel,
|
|
flip = false;
|
|
|
|
// If the root is in the tail of the edge then we need to flip the logic that
|
|
// checks for the head and tail nodes in the candidates function below.
|
|
if (vLabel.lim > wLabel.lim) {
|
|
tailLabel = wLabel;
|
|
flip = true;
|
|
}
|
|
|
|
var candidates = _.filter(g.edges(), function(edge) {
|
|
return flip === isDescendant(t, t.node(edge.v), tailLabel) &&
|
|
flip !== isDescendant(t, t.node(edge.w), tailLabel);
|
|
});
|
|
|
|
return _.min(candidates, function(edge) { return slack(g, edge); });
|
|
}
|
|
|
|
function exchangeEdges(t, g, e, f) {
|
|
var v = e.v,
|
|
w = e.w;
|
|
t.removeEdge(v, w);
|
|
t.setEdge(f.v, f.w, {});
|
|
initLowLimValues(t);
|
|
initCutValues(t, g);
|
|
updateRanks(t, g);
|
|
}
|
|
|
|
function updateRanks(t, g) {
|
|
var root = _.find(t.nodes(), function(v) { return !g.node(v).parent; }),
|
|
vs = preorder(t, root);
|
|
vs = vs.slice(1);
|
|
_.each(vs, function(v) {
|
|
var parent = t.node(v).parent,
|
|
edge = g.edge(v, parent),
|
|
flipped = false;
|
|
|
|
if (!edge) {
|
|
edge = g.edge(parent, v);
|
|
flipped = true;
|
|
}
|
|
|
|
g.node(v).rank = g.node(parent).rank + (flipped ? edge.minlen : -edge.minlen);
|
|
});
|
|
}
|
|
|
|
/*
|
|
* Returns true if the edge is in the tree.
|
|
*/
|
|
function isTreeEdge(tree, u, v) {
|
|
return tree.hasEdge(u, v);
|
|
}
|
|
|
|
/*
|
|
* Returns true if the specified node is descendant of the root node per the
|
|
* assigned low and lim attributes in the tree.
|
|
*/
|
|
function isDescendant(tree, vLabel, rootLabel) {
|
|
return rootLabel.low <= vLabel.lim && vLabel.lim <= rootLabel.lim;
|
|
}
|
|
|
|
},{"../graphlib":35,"../lodash":38,"../util":57,"./feasible-tree":53,"./util":56}],56:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = {
|
|
longestPath: longestPath,
|
|
slack: slack
|
|
};
|
|
|
|
/*
|
|
* Initializes ranks for the input graph using the longest path algorithm. This
|
|
* algorithm scales well and is fast in practice, it yields rather poor
|
|
* solutions. Nodes are pushed to the lowest layer possible, leaving the bottom
|
|
* ranks wide and leaving edges longer than necessary. However, due to its
|
|
* speed, this algorithm is good for getting an initial ranking that can be fed
|
|
* into other algorithms.
|
|
*
|
|
* This algorithm does not normalize layers because it will be used by other
|
|
* algorithms in most cases. If using this algorithm directly, be sure to
|
|
* run normalize at the end.
|
|
*
|
|
* Pre-conditions:
|
|
*
|
|
* 1. Input graph is a DAG.
|
|
* 2. Input graph node labels can be assigned properties.
|
|
*
|
|
* Post-conditions:
|
|
*
|
|
* 1. Each node will be assign an (unnormalized) "rank" property.
|
|
*/
|
|
function longestPath(g) {
|
|
var visited = {};
|
|
|
|
function dfs(v) {
|
|
var label = g.node(v);
|
|
if (_.has(visited, v)) {
|
|
return label.rank;
|
|
}
|
|
visited[v] = true;
|
|
|
|
var rank = _.min(_.map(g.outEdges(v), function(e) {
|
|
return dfs(e.w) - g.edge(e).minlen;
|
|
}));
|
|
|
|
if (rank === Number.POSITIVE_INFINITY) {
|
|
rank = 0;
|
|
}
|
|
|
|
return (label.rank = rank);
|
|
}
|
|
|
|
_.each(g.sources(), dfs);
|
|
}
|
|
|
|
/*
|
|
* Returns the amount of slack for the given edge. The slack is defined as the
|
|
* difference between the length of the edge and its minimum length.
|
|
*/
|
|
function slack(g, e) {
|
|
return g.node(e.w).rank - g.node(e.v).rank - g.edge(e).minlen;
|
|
}
|
|
|
|
},{"../lodash":38}],57:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash"),
|
|
Graph = require("./graphlib").Graph;
|
|
|
|
module.exports = {
|
|
addDummyNode: addDummyNode,
|
|
simplify: simplify,
|
|
asNonCompoundGraph: asNonCompoundGraph,
|
|
successorWeights: successorWeights,
|
|
predecessorWeights: predecessorWeights,
|
|
intersectRect: intersectRect,
|
|
buildLayerMatrix: buildLayerMatrix,
|
|
normalizeRanks: normalizeRanks,
|
|
removeEmptyRanks: removeEmptyRanks,
|
|
addBorderNode: addBorderNode,
|
|
maxRank: maxRank,
|
|
partition: partition,
|
|
time: time,
|
|
notime: notime
|
|
};
|
|
|
|
/*
|
|
* Adds a dummy node to the graph and return v.
|
|
*/
|
|
function addDummyNode(g, type, attrs, name) {
|
|
var v;
|
|
do {
|
|
v = _.uniqueId(name);
|
|
} while (g.hasNode(v));
|
|
|
|
attrs.dummy = type;
|
|
g.setNode(v, attrs);
|
|
return v;
|
|
}
|
|
|
|
/*
|
|
* Returns a new graph with only simple edges. Handles aggregation of data
|
|
* associated with multi-edges.
|
|
*/
|
|
function simplify(g) {
|
|
var simplified = new Graph().setGraph(g.graph());
|
|
_.each(g.nodes(), function(v) { simplified.setNode(v, g.node(v)); });
|
|
_.each(g.edges(), function(e) {
|
|
var simpleLabel = simplified.edge(e.v, e.w) || { weight: 0, minlen: 1 },
|
|
label = g.edge(e);
|
|
simplified.setEdge(e.v, e.w, {
|
|
weight: simpleLabel.weight + label.weight,
|
|
minlen: Math.max(simpleLabel.minlen, label.minlen)
|
|
});
|
|
});
|
|
return simplified;
|
|
}
|
|
|
|
function asNonCompoundGraph(g) {
|
|
var simplified = new Graph({ multigraph: g.isMultigraph() }).setGraph(g.graph());
|
|
_.each(g.nodes(), function(v) {
|
|
if (!g.children(v).length) {
|
|
simplified.setNode(v, g.node(v));
|
|
}
|
|
});
|
|
_.each(g.edges(), function(e) {
|
|
simplified.setEdge(e, g.edge(e));
|
|
});
|
|
return simplified;
|
|
}
|
|
|
|
function successorWeights(g) {
|
|
var weightMap = _.map(g.nodes(), function(v) {
|
|
var sucs = {};
|
|
_.each(g.outEdges(v), function(e) {
|
|
sucs[e.w] = (sucs[e.w] || 0) + g.edge(e).weight;
|
|
});
|
|
return sucs;
|
|
});
|
|
return _.zipObject(g.nodes(), weightMap);
|
|
}
|
|
|
|
function predecessorWeights(g) {
|
|
var weightMap = _.map(g.nodes(), function(v) {
|
|
var preds = {};
|
|
_.each(g.inEdges(v), function(e) {
|
|
preds[e.v] = (preds[e.v] || 0) + g.edge(e).weight;
|
|
});
|
|
return preds;
|
|
});
|
|
return _.zipObject(g.nodes(), weightMap);
|
|
}
|
|
|
|
/*
|
|
* Finds where a line starting at point ({x, y}) would intersect a rectangle
|
|
* ({x, y, width, height}) if it were pointing at the rectangle's center.
|
|
*/
|
|
function intersectRect(rect, point) {
|
|
var x = rect.x;
|
|
var y = rect.y;
|
|
|
|
// Rectangle intersection algorithm from:
|
|
// http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes
|
|
var dx = point.x - x;
|
|
var dy = point.y - y;
|
|
var w = rect.width / 2;
|
|
var h = rect.height / 2;
|
|
|
|
if (!dx && !dy) {
|
|
throw new Error("Not possible to find intersection inside of the rectangle");
|
|
}
|
|
|
|
var sx, sy;
|
|
if (Math.abs(dy) * w > Math.abs(dx) * h) {
|
|
// Intersection is top or bottom of rect.
|
|
if (dy < 0) {
|
|
h = -h;
|
|
}
|
|
sx = h * dx / dy;
|
|
sy = h;
|
|
} else {
|
|
// Intersection is left or right of rect.
|
|
if (dx < 0) {
|
|
w = -w;
|
|
}
|
|
sx = w;
|
|
sy = w * dy / dx;
|
|
}
|
|
|
|
return { x: x + sx, y: y + sy };
|
|
}
|
|
|
|
/*
|
|
* Given a DAG with each node assigned "rank" and "order" properties, this
|
|
* function will produce a matrix with the ids of each node.
|
|
*/
|
|
function buildLayerMatrix(g) {
|
|
var layering = _.map(_.range(maxRank(g) + 1), function() { return []; });
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v),
|
|
rank = node.rank;
|
|
if (!_.isUndefined(rank)) {
|
|
layering[rank][node.order] = v;
|
|
}
|
|
});
|
|
return layering;
|
|
}
|
|
|
|
/*
|
|
* Adjusts the ranks for all nodes in the graph such that all nodes v have
|
|
* rank(v) >= 0 and at least one node w has rank(w) = 0.
|
|
*/
|
|
function normalizeRanks(g) {
|
|
var min = _.min(_.map(g.nodes(), function(v) { return g.node(v).rank; }));
|
|
_.each(g.nodes(), function(v) {
|
|
var node = g.node(v);
|
|
if (_.has(node, "rank")) {
|
|
node.rank -= min;
|
|
}
|
|
});
|
|
}
|
|
|
|
function removeEmptyRanks(g) {
|
|
// Ranks may not start at 0, so we need to offset them
|
|
var offset = _.min(_.map(g.nodes(), function(v) { return g.node(v).rank; }));
|
|
|
|
var layers = [];
|
|
_.each(g.nodes(), function(v) {
|
|
var rank = g.node(v).rank - offset;
|
|
if (!_.has(layers, rank)) {
|
|
layers[rank] = [];
|
|
}
|
|
layers[rank].push(v);
|
|
});
|
|
|
|
var delta = 0,
|
|
nodeRankFactor = g.graph().nodeRankFactor;
|
|
_.each(layers, function(vs, i) {
|
|
if (_.isUndefined(vs) && i % nodeRankFactor !== 0) {
|
|
--delta;
|
|
} else if (delta) {
|
|
_.each(vs, function(v) { g.node(v).rank += delta; });
|
|
}
|
|
});
|
|
}
|
|
|
|
function addBorderNode(g, prefix, rank, order) {
|
|
var node = {
|
|
width: 0,
|
|
height: 0
|
|
};
|
|
if (arguments.length >= 4) {
|
|
node.rank = rank;
|
|
node.order = order;
|
|
}
|
|
return addDummyNode(g, "border", node, prefix);
|
|
}
|
|
|
|
function maxRank(g) {
|
|
return _.max(_.map(g.nodes(), function(v) {
|
|
var rank = g.node(v).rank;
|
|
if (!_.isUndefined(rank)) {
|
|
return rank;
|
|
}
|
|
}));
|
|
}
|
|
|
|
/*
|
|
* Partition a collection into two groups: `lhs` and `rhs`. If the supplied
|
|
* function returns true for an entry it goes into `lhs`. Otherwise it goes
|
|
* into `rhs.
|
|
*/
|
|
function partition(collection, fn) {
|
|
var result = { lhs: [], rhs: [] };
|
|
_.each(collection, function(value) {
|
|
if (fn(value)) {
|
|
result.lhs.push(value);
|
|
} else {
|
|
result.rhs.push(value);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/*
|
|
* Returns a new function that wraps `fn` with a timer. The wrapper logs the
|
|
* time it takes to execute the function.
|
|
*/
|
|
function time(name, fn) {
|
|
var start = _.now();
|
|
try {
|
|
return fn();
|
|
} finally {
|
|
console.log(name + " time: " + (_.now() - start) + "ms");
|
|
}
|
|
}
|
|
|
|
function notime(name, fn) {
|
|
return fn();
|
|
}
|
|
|
|
},{"./graphlib":35,"./lodash":38}],58:[function(require,module,exports){
|
|
module.exports = "0.7.2";
|
|
|
|
},{}],59:[function(require,module,exports){
|
|
/**
|
|
* Copyright (c) 2014, Chris Pettitt
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions are met:
|
|
*
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
* list of conditions and the following disclaimer.
|
|
*
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
* and/or other materials provided with the distribution.
|
|
*
|
|
* 3. Neither the name of the copyright holder nor the names of its contributors
|
|
* may be used to endorse or promote products derived from this software without
|
|
* specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
var lib = require("./lib");
|
|
|
|
module.exports = {
|
|
Graph: lib.Graph,
|
|
json: require("./lib/json"),
|
|
alg: require("./lib/alg"),
|
|
version: lib.version
|
|
};
|
|
|
|
},{"./lib":75,"./lib/alg":66,"./lib/json":76}],60:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = components;
|
|
|
|
function components(g) {
|
|
var visited = {},
|
|
cmpts = [],
|
|
cmpt;
|
|
|
|
function dfs(v) {
|
|
if (_.has(visited, v)) return;
|
|
visited[v] = true;
|
|
cmpt.push(v);
|
|
_.each(g.successors(v), dfs);
|
|
_.each(g.predecessors(v), dfs);
|
|
}
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
cmpt = [];
|
|
dfs(v);
|
|
if (cmpt.length) {
|
|
cmpts.push(cmpt);
|
|
}
|
|
});
|
|
|
|
return cmpts;
|
|
}
|
|
|
|
},{"../lodash":77}],61:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = dfs;
|
|
|
|
/*
|
|
* A helper that preforms a pre- or post-order traversal on the input graph
|
|
* and returns the nodes in the order they were visited. This algorithm treats
|
|
* the input as undirected.
|
|
*
|
|
* Order must be one of "pre" or "post".
|
|
*/
|
|
function dfs(g, vs, order) {
|
|
if (!_.isArray(vs)) {
|
|
vs = [vs];
|
|
}
|
|
|
|
var acc = [],
|
|
visited = {};
|
|
_.each(vs, function(v) {
|
|
if (!g.hasNode(v)) {
|
|
throw new Error("Graph does not have node: " + v);
|
|
}
|
|
|
|
doDfs(g, v, order === "post", visited, acc);
|
|
});
|
|
return acc;
|
|
}
|
|
|
|
function doDfs(g, v, postorder, visited, acc) {
|
|
if (!_.has(visited, v)) {
|
|
visited[v] = true;
|
|
|
|
if (!postorder) { acc.push(v); }
|
|
_.each(g.neighbors(v), function(w) {
|
|
doDfs(g, w, postorder, visited, acc);
|
|
});
|
|
if (postorder) { acc.push(v); }
|
|
}
|
|
}
|
|
|
|
},{"../lodash":77}],62:[function(require,module,exports){
|
|
var dijkstra = require("./dijkstra"),
|
|
_ = require("../lodash");
|
|
|
|
module.exports = dijkstraAll;
|
|
|
|
function dijkstraAll(g, weightFunc, edgeFunc) {
|
|
return _.transform(g.nodes(), function(acc, v) {
|
|
acc[v] = dijkstra(g, v, weightFunc, edgeFunc);
|
|
}, {});
|
|
}
|
|
|
|
},{"../lodash":77,"./dijkstra":63}],63:[function(require,module,exports){
|
|
var _ = require("../lodash"),
|
|
PriorityQueue = require("../data/priority-queue");
|
|
|
|
module.exports = dijkstra;
|
|
|
|
var DEFAULT_WEIGHT_FUNC = _.constant(1);
|
|
|
|
function dijkstra(g, source, weightFn, edgeFn) {
|
|
return runDijkstra(g, String(source),
|
|
weightFn || DEFAULT_WEIGHT_FUNC,
|
|
edgeFn || function(v) { return g.outEdges(v); });
|
|
}
|
|
|
|
function runDijkstra(g, source, weightFn, edgeFn) {
|
|
var results = {},
|
|
pq = new PriorityQueue(),
|
|
v, vEntry;
|
|
|
|
var updateNeighbors = function(edge) {
|
|
var w = edge.v !== v ? edge.v : edge.w,
|
|
wEntry = results[w],
|
|
weight = weightFn(edge),
|
|
distance = vEntry.distance + weight;
|
|
|
|
if (weight < 0) {
|
|
throw new Error("dijkstra does not allow negative edge weights. " +
|
|
"Bad edge: " + edge + " Weight: " + weight);
|
|
}
|
|
|
|
if (distance < wEntry.distance) {
|
|
wEntry.distance = distance;
|
|
wEntry.predecessor = v;
|
|
pq.decrease(w, distance);
|
|
}
|
|
};
|
|
|
|
g.nodes().forEach(function(v) {
|
|
var distance = v === source ? 0 : Number.POSITIVE_INFINITY;
|
|
results[v] = { distance: distance };
|
|
pq.add(v, distance);
|
|
});
|
|
|
|
while (pq.size() > 0) {
|
|
v = pq.removeMin();
|
|
vEntry = results[v];
|
|
if (vEntry.distance === Number.POSITIVE_INFINITY) {
|
|
break;
|
|
}
|
|
|
|
edgeFn(v).forEach(updateNeighbors);
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
},{"../data/priority-queue":73,"../lodash":77}],64:[function(require,module,exports){
|
|
var _ = require("../lodash"),
|
|
tarjan = require("./tarjan");
|
|
|
|
module.exports = findCycles;
|
|
|
|
function findCycles(g) {
|
|
return _.filter(tarjan(g), function(cmpt) {
|
|
return cmpt.length > 1 || (cmpt.length === 1 && g.hasEdge(cmpt[0], cmpt[0]));
|
|
});
|
|
}
|
|
|
|
},{"../lodash":77,"./tarjan":71}],65:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = floydWarshall;
|
|
|
|
var DEFAULT_WEIGHT_FUNC = _.constant(1);
|
|
|
|
function floydWarshall(g, weightFn, edgeFn) {
|
|
return runFloydWarshall(g,
|
|
weightFn || DEFAULT_WEIGHT_FUNC,
|
|
edgeFn || function(v) { return g.outEdges(v); });
|
|
}
|
|
|
|
function runFloydWarshall(g, weightFn, edgeFn) {
|
|
var results = {},
|
|
nodes = g.nodes();
|
|
|
|
nodes.forEach(function(v) {
|
|
results[v] = {};
|
|
results[v][v] = { distance: 0 };
|
|
nodes.forEach(function(w) {
|
|
if (v !== w) {
|
|
results[v][w] = { distance: Number.POSITIVE_INFINITY };
|
|
}
|
|
});
|
|
edgeFn(v).forEach(function(edge) {
|
|
var w = edge.v === v ? edge.w : edge.v,
|
|
d = weightFn(edge);
|
|
results[v][w] = { distance: d, predecessor: v };
|
|
});
|
|
});
|
|
|
|
nodes.forEach(function(k) {
|
|
var rowK = results[k];
|
|
nodes.forEach(function(i) {
|
|
var rowI = results[i];
|
|
nodes.forEach(function(j) {
|
|
var ik = rowI[k];
|
|
var kj = rowK[j];
|
|
var ij = rowI[j];
|
|
var altDistance = ik.distance + kj.distance;
|
|
if (altDistance < ij.distance) {
|
|
ij.distance = altDistance;
|
|
ij.predecessor = kj.predecessor;
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
return results;
|
|
}
|
|
|
|
},{"../lodash":77}],66:[function(require,module,exports){
|
|
module.exports = {
|
|
components: require("./components"),
|
|
dijkstra: require("./dijkstra"),
|
|
dijkstraAll: require("./dijkstra-all"),
|
|
findCycles: require("./find-cycles"),
|
|
floydWarshall: require("./floyd-warshall"),
|
|
isAcyclic: require("./is-acyclic"),
|
|
postorder: require("./postorder"),
|
|
preorder: require("./preorder"),
|
|
prim: require("./prim"),
|
|
tarjan: require("./tarjan"),
|
|
topsort: require("./topsort")
|
|
};
|
|
|
|
},{"./components":60,"./dijkstra":63,"./dijkstra-all":62,"./find-cycles":64,"./floyd-warshall":65,"./is-acyclic":67,"./postorder":68,"./preorder":69,"./prim":70,"./tarjan":71,"./topsort":72}],67:[function(require,module,exports){
|
|
var topsort = require("./topsort");
|
|
|
|
module.exports = isAcyclic;
|
|
|
|
function isAcyclic(g) {
|
|
try {
|
|
topsort(g);
|
|
} catch (e) {
|
|
if (e instanceof topsort.CycleException) {
|
|
return false;
|
|
}
|
|
throw e;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
},{"./topsort":72}],68:[function(require,module,exports){
|
|
var dfs = require("./dfs");
|
|
|
|
module.exports = postorder;
|
|
|
|
function postorder(g, vs) {
|
|
return dfs(g, vs, "post");
|
|
}
|
|
|
|
},{"./dfs":61}],69:[function(require,module,exports){
|
|
var dfs = require("./dfs");
|
|
|
|
module.exports = preorder;
|
|
|
|
function preorder(g, vs) {
|
|
return dfs(g, vs, "pre");
|
|
}
|
|
|
|
},{"./dfs":61}],70:[function(require,module,exports){
|
|
var _ = require("../lodash"),
|
|
Graph = require("../graph"),
|
|
PriorityQueue = require("../data/priority-queue");
|
|
|
|
module.exports = prim;
|
|
|
|
function prim(g, weightFunc) {
|
|
var result = new Graph(),
|
|
parents = {},
|
|
pq = new PriorityQueue(),
|
|
v;
|
|
|
|
function updateNeighbors(edge) {
|
|
var w = edge.v === v ? edge.w : edge.v,
|
|
pri = pq.priority(w);
|
|
if (pri !== undefined) {
|
|
var edgeWeight = weightFunc(edge);
|
|
if (edgeWeight < pri) {
|
|
parents[w] = v;
|
|
pq.decrease(w, edgeWeight);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (g.nodeCount() === 0) {
|
|
return result;
|
|
}
|
|
|
|
_.each(g.nodes(), function(v) {
|
|
pq.add(v, Number.POSITIVE_INFINITY);
|
|
result.setNode(v);
|
|
});
|
|
|
|
// Start from an arbitrary node
|
|
pq.decrease(g.nodes()[0], 0);
|
|
|
|
var init = false;
|
|
while (pq.size() > 0) {
|
|
v = pq.removeMin();
|
|
if (_.has(parents, v)) {
|
|
result.setEdge(v, parents[v]);
|
|
} else if (init) {
|
|
throw new Error("Input graph is not connected: " + g);
|
|
} else {
|
|
init = true;
|
|
}
|
|
|
|
g.nodeEdges(v).forEach(updateNeighbors);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
},{"../data/priority-queue":73,"../graph":74,"../lodash":77}],71:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = tarjan;
|
|
|
|
function tarjan(g) {
|
|
var index = 0,
|
|
stack = [],
|
|
visited = {}, // node id -> { onStack, lowlink, index }
|
|
results = [];
|
|
|
|
function dfs(v) {
|
|
var entry = visited[v] = {
|
|
onStack: true,
|
|
lowlink: index,
|
|
index: index++
|
|
};
|
|
stack.push(v);
|
|
|
|
g.successors(v).forEach(function(w) {
|
|
if (!_.has(visited, w)) {
|
|
dfs(w);
|
|
entry.lowlink = Math.min(entry.lowlink, visited[w].lowlink);
|
|
} else if (visited[w].onStack) {
|
|
entry.lowlink = Math.min(entry.lowlink, visited[w].index);
|
|
}
|
|
});
|
|
|
|
if (entry.lowlink === entry.index) {
|
|
var cmpt = [],
|
|
w;
|
|
do {
|
|
w = stack.pop();
|
|
visited[w].onStack = false;
|
|
cmpt.push(w);
|
|
} while (v !== w);
|
|
results.push(cmpt);
|
|
}
|
|
}
|
|
|
|
g.nodes().forEach(function(v) {
|
|
if (!_.has(visited, v)) {
|
|
dfs(v);
|
|
}
|
|
});
|
|
|
|
return results;
|
|
}
|
|
|
|
},{"../lodash":77}],72:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = topsort;
|
|
topsort.CycleException = CycleException;
|
|
|
|
function topsort(g) {
|
|
var visited = {},
|
|
stack = {},
|
|
results = [];
|
|
|
|
function visit(node) {
|
|
if (_.has(stack, node)) {
|
|
throw new CycleException();
|
|
}
|
|
|
|
if (!_.has(visited, node)) {
|
|
stack[node] = true;
|
|
visited[node] = true;
|
|
_.each(g.predecessors(node), visit);
|
|
delete stack[node];
|
|
results.push(node);
|
|
}
|
|
}
|
|
|
|
_.each(g.sinks(), visit);
|
|
|
|
if (_.size(visited) !== g.nodeCount()) {
|
|
throw new CycleException();
|
|
}
|
|
|
|
return results;
|
|
}
|
|
|
|
function CycleException() {}
|
|
|
|
},{"../lodash":77}],73:[function(require,module,exports){
|
|
var _ = require("../lodash");
|
|
|
|
module.exports = PriorityQueue;
|
|
|
|
/**
|
|
* A min-priority queue data structure. This algorithm is derived from Cormen,
|
|
* et al., "Introduction to Algorithms". The basic idea of a min-priority
|
|
* queue is that you can efficiently (in O(1) time) get the smallest key in
|
|
* the queue. Adding and removing elements takes O(log n) time. A key can
|
|
* have its priority decreased in O(log n) time.
|
|
*/
|
|
function PriorityQueue() {
|
|
this._arr = [];
|
|
this._keyIndices = {};
|
|
}
|
|
|
|
/**
|
|
* Returns the number of elements in the queue. Takes `O(1)` time.
|
|
*/
|
|
PriorityQueue.prototype.size = function() {
|
|
return this._arr.length;
|
|
};
|
|
|
|
/**
|
|
* Returns the keys that are in the queue. Takes `O(n)` time.
|
|
*/
|
|
PriorityQueue.prototype.keys = function() {
|
|
return this._arr.map(function(x) { return x.key; });
|
|
};
|
|
|
|
/**
|
|
* Returns `true` if **key** is in the queue and `false` if not.
|
|
*/
|
|
PriorityQueue.prototype.has = function(key) {
|
|
return _.has(this._keyIndices, key);
|
|
};
|
|
|
|
/**
|
|
* Returns the priority for **key**. If **key** is not present in the queue
|
|
* then this function returns `undefined`. Takes `O(1)` time.
|
|
*
|
|
* @param {Object} key
|
|
*/
|
|
PriorityQueue.prototype.priority = function(key) {
|
|
var index = this._keyIndices[key];
|
|
if (index !== undefined) {
|
|
return this._arr[index].priority;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Returns the key for the minimum element in this queue. If the queue is
|
|
* empty this function throws an Error. Takes `O(1)` time.
|
|
*/
|
|
PriorityQueue.prototype.min = function() {
|
|
if (this.size() === 0) {
|
|
throw new Error("Queue underflow");
|
|
}
|
|
return this._arr[0].key;
|
|
};
|
|
|
|
/**
|
|
* Inserts a new key into the priority queue. If the key already exists in
|
|
* the queue this function returns `false`; otherwise it will return `true`.
|
|
* Takes `O(n)` time.
|
|
*
|
|
* @param {Object} key the key to add
|
|
* @param {Number} priority the initial priority for the key
|
|
*/
|
|
PriorityQueue.prototype.add = function(key, priority) {
|
|
var keyIndices = this._keyIndices;
|
|
key = String(key);
|
|
if (!_.has(keyIndices, key)) {
|
|
var arr = this._arr;
|
|
var index = arr.length;
|
|
keyIndices[key] = index;
|
|
arr.push({key: key, priority: priority});
|
|
this._decrease(index);
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Removes and returns the smallest key in the queue. Takes `O(log n)` time.
|
|
*/
|
|
PriorityQueue.prototype.removeMin = function() {
|
|
this._swap(0, this._arr.length - 1);
|
|
var min = this._arr.pop();
|
|
delete this._keyIndices[min.key];
|
|
this._heapify(0);
|
|
return min.key;
|
|
};
|
|
|
|
/**
|
|
* Decreases the priority for **key** to **priority**. If the new priority is
|
|
* greater than the previous priority, this function will throw an Error.
|
|
*
|
|
* @param {Object} key the key for which to raise priority
|
|
* @param {Number} priority the new priority for the key
|
|
*/
|
|
PriorityQueue.prototype.decrease = function(key, priority) {
|
|
var index = this._keyIndices[key];
|
|
if (priority > this._arr[index].priority) {
|
|
throw new Error("New priority is greater than current priority. " +
|
|
"Key: " + key + " Old: " + this._arr[index].priority + " New: " + priority);
|
|
}
|
|
this._arr[index].priority = priority;
|
|
this._decrease(index);
|
|
};
|
|
|
|
PriorityQueue.prototype._heapify = function(i) {
|
|
var arr = this._arr;
|
|
var l = 2 * i,
|
|
r = l + 1,
|
|
largest = i;
|
|
if (l < arr.length) {
|
|
largest = arr[l].priority < arr[largest].priority ? l : largest;
|
|
if (r < arr.length) {
|
|
largest = arr[r].priority < arr[largest].priority ? r : largest;
|
|
}
|
|
if (largest !== i) {
|
|
this._swap(i, largest);
|
|
this._heapify(largest);
|
|
}
|
|
}
|
|
};
|
|
|
|
PriorityQueue.prototype._decrease = function(index) {
|
|
var arr = this._arr;
|
|
var priority = arr[index].priority;
|
|
var parent;
|
|
while (index !== 0) {
|
|
parent = index >> 1;
|
|
if (arr[parent].priority < priority) {
|
|
break;
|
|
}
|
|
this._swap(index, parent);
|
|
index = parent;
|
|
}
|
|
};
|
|
|
|
PriorityQueue.prototype._swap = function(i, j) {
|
|
var arr = this._arr;
|
|
var keyIndices = this._keyIndices;
|
|
var origArrI = arr[i];
|
|
var origArrJ = arr[j];
|
|
arr[i] = origArrJ;
|
|
arr[j] = origArrI;
|
|
keyIndices[origArrJ.key] = i;
|
|
keyIndices[origArrI.key] = j;
|
|
};
|
|
|
|
},{"../lodash":77}],74:[function(require,module,exports){
|
|
"use strict";
|
|
|
|
var _ = require("./lodash");
|
|
|
|
module.exports = Graph;
|
|
|
|
var DEFAULT_EDGE_NAME = "\x00",
|
|
GRAPH_NODE = "\x00",
|
|
EDGE_KEY_DELIM = "\x01";
|
|
|
|
// Implementation notes:
|
|
//
|
|
// * Node id query functions should return string ids for the nodes
|
|
// * Edge id query functions should return an "edgeObj", edge object, that is
|
|
// composed of enough information to uniquely identify an edge: {v, w, name}.
|
|
// * Internally we use an "edgeId", a stringified form of the edgeObj, to
|
|
// reference edges. This is because we need a performant way to look these
|
|
// edges up and, object properties, which have string keys, are the closest
|
|
// we're going to get to a performant hashtable in JavaScript.
|
|
|
|
function Graph(opts) {
|
|
this._isDirected = _.has(opts, "directed") ? opts.directed : true;
|
|
this._isMultigraph = _.has(opts, "multigraph") ? opts.multigraph : false;
|
|
this._isCompound = _.has(opts, "compound") ? opts.compound : false;
|
|
|
|
// Label for the graph itself
|
|
this._label = undefined;
|
|
|
|
// Defaults to be set when creating a new node
|
|
this._defaultNodeLabelFn = _.constant(undefined);
|
|
|
|
// Defaults to be set when creating a new edge
|
|
this._defaultEdgeLabelFn = _.constant(undefined);
|
|
|
|
// v -> label
|
|
this._nodes = {};
|
|
|
|
if (this._isCompound) {
|
|
// v -> parent
|
|
this._parent = {};
|
|
|
|
// v -> children
|
|
this._children = {};
|
|
this._children[GRAPH_NODE] = {};
|
|
}
|
|
|
|
// v -> edgeObj
|
|
this._in = {};
|
|
|
|
// u -> v -> Number
|
|
this._preds = {};
|
|
|
|
// v -> edgeObj
|
|
this._out = {};
|
|
|
|
// v -> w -> Number
|
|
this._sucs = {};
|
|
|
|
// e -> edgeObj
|
|
this._edgeObjs = {};
|
|
|
|
// e -> label
|
|
this._edgeLabels = {};
|
|
}
|
|
|
|
/* Number of nodes in the graph. Should only be changed by the implementation. */
|
|
Graph.prototype._nodeCount = 0;
|
|
|
|
/* Number of edges in the graph. Should only be changed by the implementation. */
|
|
Graph.prototype._edgeCount = 0;
|
|
|
|
|
|
/* === Graph functions ========= */
|
|
|
|
Graph.prototype.isDirected = function() {
|
|
return this._isDirected;
|
|
};
|
|
|
|
Graph.prototype.isMultigraph = function() {
|
|
return this._isMultigraph;
|
|
};
|
|
|
|
Graph.prototype.isCompound = function() {
|
|
return this._isCompound;
|
|
};
|
|
|
|
Graph.prototype.setGraph = function(label) {
|
|
this._label = label;
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.graph = function() {
|
|
return this._label;
|
|
};
|
|
|
|
|
|
/* === Node functions ========== */
|
|
|
|
Graph.prototype.setDefaultNodeLabel = function(newDefault) {
|
|
if (!_.isFunction(newDefault)) {
|
|
newDefault = _.constant(newDefault);
|
|
}
|
|
this._defaultNodeLabelFn = newDefault;
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.nodeCount = function() {
|
|
return this._nodeCount;
|
|
};
|
|
|
|
Graph.prototype.nodes = function() {
|
|
return _.keys(this._nodes);
|
|
};
|
|
|
|
Graph.prototype.sources = function() {
|
|
return _.filter(this.nodes(), function(v) {
|
|
return _.isEmpty(this._in[v]);
|
|
}, this);
|
|
};
|
|
|
|
Graph.prototype.sinks = function() {
|
|
return _.filter(this.nodes(), function(v) {
|
|
return _.isEmpty(this._out[v]);
|
|
}, this);
|
|
};
|
|
|
|
Graph.prototype.setNodes = function(vs, value) {
|
|
var args = arguments;
|
|
_.each(vs, function(v) {
|
|
if (args.length > 1) {
|
|
this.setNode(v, value);
|
|
} else {
|
|
this.setNode(v);
|
|
}
|
|
}, this);
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.setNode = function(v, value) {
|
|
if (_.has(this._nodes, v)) {
|
|
if (arguments.length > 1) {
|
|
this._nodes[v] = value;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
|
|
if (this._isCompound) {
|
|
this._parent[v] = GRAPH_NODE;
|
|
this._children[v] = {};
|
|
this._children[GRAPH_NODE][v] = true;
|
|
}
|
|
this._in[v] = {};
|
|
this._preds[v] = {};
|
|
this._out[v] = {};
|
|
this._sucs[v] = {};
|
|
++this._nodeCount;
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.node = function(v) {
|
|
return this._nodes[v];
|
|
};
|
|
|
|
Graph.prototype.hasNode = function(v) {
|
|
return _.has(this._nodes, v);
|
|
};
|
|
|
|
Graph.prototype.removeNode = function(v) {
|
|
var self = this;
|
|
if (_.has(this._nodes, v)) {
|
|
var removeEdge = function(e) { self.removeEdge(self._edgeObjs[e]); };
|
|
delete this._nodes[v];
|
|
if (this._isCompound) {
|
|
this._removeFromParentsChildList(v);
|
|
delete this._parent[v];
|
|
_.each(this.children(v), function(child) {
|
|
this.setParent(child);
|
|
}, this);
|
|
delete this._children[v];
|
|
}
|
|
_.each(_.keys(this._in[v]), removeEdge);
|
|
delete this._in[v];
|
|
delete this._preds[v];
|
|
_.each(_.keys(this._out[v]), removeEdge);
|
|
delete this._out[v];
|
|
delete this._sucs[v];
|
|
--this._nodeCount;
|
|
}
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.setParent = function(v, parent) {
|
|
if (!this._isCompound) {
|
|
throw new Error("Cannot set parent in a non-compound graph");
|
|
}
|
|
|
|
if (_.isUndefined(parent)) {
|
|
parent = GRAPH_NODE;
|
|
} else {
|
|
// Coerce parent to string
|
|
parent += "";
|
|
for (var ancestor = parent;
|
|
!_.isUndefined(ancestor);
|
|
ancestor = this.parent(ancestor)) {
|
|
if (ancestor === v) {
|
|
throw new Error("Setting " + parent+ " as parent of " + v +
|
|
" would create create a cycle");
|
|
}
|
|
}
|
|
|
|
this.setNode(parent);
|
|
}
|
|
|
|
this.setNode(v);
|
|
this._removeFromParentsChildList(v);
|
|
this._parent[v] = parent;
|
|
this._children[parent][v] = true;
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype._removeFromParentsChildList = function(v) {
|
|
delete this._children[this._parent[v]][v];
|
|
};
|
|
|
|
Graph.prototype.parent = function(v) {
|
|
if (this._isCompound) {
|
|
var parent = this._parent[v];
|
|
if (parent !== GRAPH_NODE) {
|
|
return parent;
|
|
}
|
|
}
|
|
};
|
|
|
|
Graph.prototype.children = function(v) {
|
|
if (_.isUndefined(v)) {
|
|
v = GRAPH_NODE;
|
|
}
|
|
|
|
if (this._isCompound) {
|
|
var children = this._children[v];
|
|
if (children) {
|
|
return _.keys(children);
|
|
}
|
|
} else if (v === GRAPH_NODE) {
|
|
return this.nodes();
|
|
} else if (this.hasNode(v)) {
|
|
return [];
|
|
}
|
|
};
|
|
|
|
Graph.prototype.predecessors = function(v) {
|
|
var predsV = this._preds[v];
|
|
if (predsV) {
|
|
return _.keys(predsV);
|
|
}
|
|
};
|
|
|
|
Graph.prototype.successors = function(v) {
|
|
var sucsV = this._sucs[v];
|
|
if (sucsV) {
|
|
return _.keys(sucsV);
|
|
}
|
|
};
|
|
|
|
Graph.prototype.neighbors = function(v) {
|
|
var preds = this.predecessors(v);
|
|
if (preds) {
|
|
return _.union(preds, this.successors(v));
|
|
}
|
|
};
|
|
|
|
/* === Edge functions ========== */
|
|
|
|
Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
|
|
if (!_.isFunction(newDefault)) {
|
|
newDefault = _.constant(newDefault);
|
|
}
|
|
this._defaultEdgeLabelFn = newDefault;
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.edgeCount = function() {
|
|
return this._edgeCount;
|
|
};
|
|
|
|
Graph.prototype.edges = function() {
|
|
return _.values(this._edgeObjs);
|
|
};
|
|
|
|
Graph.prototype.setPath = function(vs, value) {
|
|
var self = this,
|
|
args = arguments;
|
|
_.reduce(vs, function(v, w) {
|
|
if (args.length > 1) {
|
|
self.setEdge(v, w, value);
|
|
} else {
|
|
self.setEdge(v, w);
|
|
}
|
|
return w;
|
|
});
|
|
return this;
|
|
};
|
|
|
|
/*
|
|
* setEdge(v, w, [value, [name]])
|
|
* setEdge({ v, w, [name] }, [value])
|
|
*/
|
|
Graph.prototype.setEdge = function() {
|
|
var v, w, name, value,
|
|
valueSpecified = false;
|
|
|
|
if (_.isPlainObject(arguments[0])) {
|
|
v = arguments[0].v;
|
|
w = arguments[0].w;
|
|
name = arguments[0].name;
|
|
if (arguments.length === 2) {
|
|
value = arguments[1];
|
|
valueSpecified = true;
|
|
}
|
|
} else {
|
|
v = arguments[0];
|
|
w = arguments[1];
|
|
name = arguments[3];
|
|
if (arguments.length > 2) {
|
|
value = arguments[2];
|
|
valueSpecified = true;
|
|
}
|
|
}
|
|
|
|
v = "" + v;
|
|
w = "" + w;
|
|
if (!_.isUndefined(name)) {
|
|
name = "" + name;
|
|
}
|
|
|
|
var e = edgeArgsToId(this._isDirected, v, w, name);
|
|
if (_.has(this._edgeLabels, e)) {
|
|
if (valueSpecified) {
|
|
this._edgeLabels[e] = value;
|
|
}
|
|
return this;
|
|
}
|
|
|
|
if (!_.isUndefined(name) && !this._isMultigraph) {
|
|
throw new Error("Cannot set a named edge when isMultigraph = false");
|
|
}
|
|
|
|
// It didn't exist, so we need to create it.
|
|
// First ensure the nodes exist.
|
|
this.setNode(v);
|
|
this.setNode(w);
|
|
|
|
this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
|
|
|
|
var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
|
|
// Ensure we add undirected edges in a consistent way.
|
|
v = edgeObj.v;
|
|
w = edgeObj.w;
|
|
|
|
Object.freeze(edgeObj);
|
|
this._edgeObjs[e] = edgeObj;
|
|
incrementOrInitEntry(this._preds[w], v);
|
|
incrementOrInitEntry(this._sucs[v], w);
|
|
this._in[w][e] = edgeObj;
|
|
this._out[v][e] = edgeObj;
|
|
this._edgeCount++;
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.edge = function(v, w, name) {
|
|
var e = (arguments.length === 1
|
|
? edgeObjToId(this._isDirected, arguments[0])
|
|
: edgeArgsToId(this._isDirected, v, w, name));
|
|
return this._edgeLabels[e];
|
|
};
|
|
|
|
Graph.prototype.hasEdge = function(v, w, name) {
|
|
var e = (arguments.length === 1
|
|
? edgeObjToId(this._isDirected, arguments[0])
|
|
: edgeArgsToId(this._isDirected, v, w, name));
|
|
return _.has(this._edgeLabels, e);
|
|
};
|
|
|
|
Graph.prototype.removeEdge = function(v, w, name) {
|
|
var e = (arguments.length === 1
|
|
? edgeObjToId(this._isDirected, arguments[0])
|
|
: edgeArgsToId(this._isDirected, v, w, name)),
|
|
edge = this._edgeObjs[e];
|
|
if (edge) {
|
|
v = edge.v;
|
|
w = edge.w;
|
|
delete this._edgeLabels[e];
|
|
delete this._edgeObjs[e];
|
|
decrementOrRemoveEntry(this._preds[w], v);
|
|
decrementOrRemoveEntry(this._sucs[v], w);
|
|
delete this._in[w][e];
|
|
delete this._out[v][e];
|
|
this._edgeCount--;
|
|
}
|
|
return this;
|
|
};
|
|
|
|
Graph.prototype.inEdges = function(v, u) {
|
|
var inV = this._in[v];
|
|
if (inV) {
|
|
var edges = _.values(inV);
|
|
if (!u) {
|
|
return edges;
|
|
}
|
|
return _.filter(edges, function(edge) { return edge.v === u; });
|
|
}
|
|
};
|
|
|
|
Graph.prototype.outEdges = function(v, w) {
|
|
var outV = this._out[v];
|
|
if (outV) {
|
|
var edges = _.values(outV);
|
|
if (!w) {
|
|
return edges;
|
|
}
|
|
return _.filter(edges, function(edge) { return edge.w === w; });
|
|
}
|
|
};
|
|
|
|
Graph.prototype.nodeEdges = function(v, w) {
|
|
var inEdges = this.inEdges(v, w);
|
|
if (inEdges) {
|
|
return inEdges.concat(this.outEdges(v, w));
|
|
}
|
|
};
|
|
|
|
function incrementOrInitEntry(map, k) {
|
|
if (_.has(map, k)) {
|
|
map[k]++;
|
|
} else {
|
|
map[k] = 1;
|
|
}
|
|
}
|
|
|
|
function decrementOrRemoveEntry(map, k) {
|
|
if (!--map[k]) { delete map[k]; }
|
|
}
|
|
|
|
function edgeArgsToId(isDirected, v, w, name) {
|
|
if (!isDirected && v > w) {
|
|
var tmp = v;
|
|
v = w;
|
|
w = tmp;
|
|
}
|
|
return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +
|
|
(_.isUndefined(name) ? DEFAULT_EDGE_NAME : name);
|
|
}
|
|
|
|
function edgeArgsToObj(isDirected, v, w, name) {
|
|
if (!isDirected && v > w) {
|
|
var tmp = v;
|
|
v = w;
|
|
w = tmp;
|
|
}
|
|
var edgeObj = { v: v, w: w };
|
|
if (name) {
|
|
edgeObj.name = name;
|
|
}
|
|
return edgeObj;
|
|
}
|
|
|
|
function edgeObjToId(isDirected, edgeObj) {
|
|
return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
|
|
}
|
|
|
|
},{"./lodash":77}],75:[function(require,module,exports){
|
|
// Includes only the "core" of graphlib
|
|
module.exports = {
|
|
Graph: require("./graph"),
|
|
version: require("./version")
|
|
};
|
|
|
|
},{"./graph":74,"./version":78}],76:[function(require,module,exports){
|
|
var _ = require("./lodash"),
|
|
Graph = require("./graph");
|
|
|
|
module.exports = {
|
|
write: write,
|
|
read: read
|
|
};
|
|
|
|
function write(g) {
|
|
var json = {
|
|
options: {
|
|
directed: g.isDirected(),
|
|
multigraph: g.isMultigraph(),
|
|
compound: g.isCompound()
|
|
},
|
|
nodes: writeNodes(g),
|
|
edges: writeEdges(g)
|
|
};
|
|
if (!_.isUndefined(g.graph())) {
|
|
json.value = _.clone(g.graph());
|
|
}
|
|
return json;
|
|
}
|
|
|
|
function writeNodes(g) {
|
|
return _.map(g.nodes(), function(v) {
|
|
var nodeValue = g.node(v),
|
|
parent = g.parent(v),
|
|
node = { v: v };
|
|
if (!_.isUndefined(nodeValue)) {
|
|
node.value = nodeValue;
|
|
}
|
|
if (!_.isUndefined(parent)) {
|
|
node.parent = parent;
|
|
}
|
|
return node;
|
|
});
|
|
}
|
|
|
|
function writeEdges(g) {
|
|
return _.map(g.edges(), function(e) {
|
|
var edgeValue = g.edge(e),
|
|
edge = { v: e.v, w: e.w };
|
|
if (!_.isUndefined(e.name)) {
|
|
edge.name = e.name;
|
|
}
|
|
if (!_.isUndefined(edgeValue)) {
|
|
edge.value = edgeValue;
|
|
}
|
|
return edge;
|
|
});
|
|
}
|
|
|
|
function read(json) {
|
|
var g = new Graph(json.options).setGraph(json.value);
|
|
_.each(json.nodes, function(entry) {
|
|
g.setNode(entry.v, entry.value);
|
|
if (entry.parent) {
|
|
g.setParent(entry.v, entry.parent);
|
|
}
|
|
});
|
|
_.each(json.edges, function(entry) {
|
|
g.setEdge({ v: entry.v, w: entry.w, name: entry.name }, entry.value);
|
|
});
|
|
return g;
|
|
}
|
|
|
|
},{"./graph":74,"./lodash":77}],77:[function(require,module,exports){
|
|
/* global window */
|
|
|
|
var lodash;
|
|
|
|
if (typeof require === "function") {
|
|
try {
|
|
lodash = require("lodash");
|
|
} catch (e) {}
|
|
}
|
|
|
|
if (!lodash) {
|
|
lodash = window._;
|
|
}
|
|
|
|
module.exports = lodash;
|
|
|
|
},{"lodash":82}],78:[function(require,module,exports){
|
|
module.exports = '1.0.4';
|
|
|
|
},{}],79:[function(require,module,exports){
|
|
|
|
},{}],80:[function(require,module,exports){
|
|
(function (process){
|
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
|
// copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
// persons to whom the Software is furnished to do so, subject to the
|
|
// following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be included
|
|
// in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
// resolves . and .. elements in a path array with directory names there
|
|
// must be no slashes, empty elements, or device names (c:\) in the array
|
|
// (so also no leading and trailing slashes - it does not distinguish
|
|
// relative and absolute paths)
|
|
function normalizeArray(parts, allowAboveRoot) {
|
|
// if the path tries to go above the root, `up` ends up > 0
|
|
var up = 0;
|
|
for (var i = parts.length - 1; i >= 0; i--) {
|
|
var last = parts[i];
|
|
if (last === '.') {
|
|
parts.splice(i, 1);
|
|
} else if (last === '..') {
|
|
parts.splice(i, 1);
|
|
up++;
|
|
} else if (up) {
|
|
parts.splice(i, 1);
|
|
up--;
|
|
}
|
|
}
|
|
|
|
// if the path is allowed to go above the root, restore leading ..s
|
|
if (allowAboveRoot) {
|
|
for (; up--; up) {
|
|
parts.unshift('..');
|
|
}
|
|
}
|
|
|
|
return parts;
|
|
}
|
|
|
|
// Split a filename into [root, dir, basename, ext], unix version
|
|
// 'root' is just a slash, or nothing.
|
|
var splitPathRe =
|
|
/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
|
|
var splitPath = function(filename) {
|
|
return splitPathRe.exec(filename).slice(1);
|
|
};
|
|
|
|
// path.resolve([from ...], to)
|
|
// posix version
|
|
exports.resolve = function() {
|
|
var resolvedPath = '',
|
|
resolvedAbsolute = false;
|
|
|
|
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
var path = (i >= 0) ? arguments[i] : process.cwd();
|
|
|
|
// Skip empty and invalid entries
|
|
if (typeof path !== 'string') {
|
|
throw new TypeError('Arguments to path.resolve must be strings');
|
|
} else if (!path) {
|
|
continue;
|
|
}
|
|
|
|
resolvedPath = path + '/' + resolvedPath;
|
|
resolvedAbsolute = path.charAt(0) === '/';
|
|
}
|
|
|
|
// At this point the path should be resolved to a full absolute path, but
|
|
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
|
|
// Normalize the path
|
|
resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {
|
|
return !!p;
|
|
}), !resolvedAbsolute).join('/');
|
|
|
|
return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';
|
|
};
|
|
|
|
// path.normalize(path)
|
|
// posix version
|
|
exports.normalize = function(path) {
|
|
var isAbsolute = exports.isAbsolute(path),
|
|
trailingSlash = substr(path, -1) === '/';
|
|
|
|
// Normalize the path
|
|
path = normalizeArray(filter(path.split('/'), function(p) {
|
|
return !!p;
|
|
}), !isAbsolute).join('/');
|
|
|
|
if (!path && !isAbsolute) {
|
|
path = '.';
|
|
}
|
|
if (path && trailingSlash) {
|
|
path += '/';
|
|
}
|
|
|
|
return (isAbsolute ? '/' : '') + path;
|
|
};
|
|
|
|
// posix version
|
|
exports.isAbsolute = function(path) {
|
|
return path.charAt(0) === '/';
|
|
};
|
|
|
|
// posix version
|
|
exports.join = function() {
|
|
var paths = Array.prototype.slice.call(arguments, 0);
|
|
return exports.normalize(filter(paths, function(p, index) {
|
|
if (typeof p !== 'string') {
|
|
throw new TypeError('Arguments to path.join must be strings');
|
|
}
|
|
return p;
|
|
}).join('/'));
|
|
};
|
|
|
|
|
|
// path.relative(from, to)
|
|
// posix version
|
|
exports.relative = function(from, to) {
|
|
from = exports.resolve(from).substr(1);
|
|
to = exports.resolve(to).substr(1);
|
|
|
|
function trim(arr) {
|
|
var start = 0;
|
|
for (; start < arr.length; start++) {
|
|
if (arr[start] !== '') break;
|
|
}
|
|
|
|
var end = arr.length - 1;
|
|
for (; end >= 0; end--) {
|
|
if (arr[end] !== '') break;
|
|
}
|
|
|
|
if (start > end) return [];
|
|
return arr.slice(start, end - start + 1);
|
|
}
|
|
|
|
var fromParts = trim(from.split('/'));
|
|
var toParts = trim(to.split('/'));
|
|
|
|
var length = Math.min(fromParts.length, toParts.length);
|
|
var samePartsLength = length;
|
|
for (var i = 0; i < length; i++) {
|
|
if (fromParts[i] !== toParts[i]) {
|
|
samePartsLength = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
var outputParts = [];
|
|
for (var i = samePartsLength; i < fromParts.length; i++) {
|
|
outputParts.push('..');
|
|
}
|
|
|
|
outputParts = outputParts.concat(toParts.slice(samePartsLength));
|
|
|
|
return outputParts.join('/');
|
|
};
|
|
|
|
exports.sep = '/';
|
|
exports.delimiter = ':';
|
|
|
|
exports.dirname = function(path) {
|
|
var result = splitPath(path),
|
|
root = result[0],
|
|
dir = result[1];
|
|
|
|
if (!root && !dir) {
|
|
// No dirname whatsoever
|
|
return '.';
|
|
}
|
|
|
|
if (dir) {
|
|
// It has a dirname, strip trailing slash
|
|
dir = dir.substr(0, dir.length - 1);
|
|
}
|
|
|
|
return root + dir;
|
|
};
|
|
|
|
|
|
exports.basename = function(path, ext) {
|
|
var f = splitPath(path)[2];
|
|
// TODO: make this comparison case-insensitive on windows?
|
|
if (ext && f.substr(-1 * ext.length) === ext) {
|
|
f = f.substr(0, f.length - ext.length);
|
|
}
|
|
return f;
|
|
};
|
|
|
|
|
|
exports.extname = function(path) {
|
|
return splitPath(path)[3];
|
|
};
|
|
|
|
function filter (xs, f) {
|
|
if (xs.filter) return xs.filter(f);
|
|
var res = [];
|
|
for (var i = 0; i < xs.length; i++) {
|
|
if (f(xs[i], i, xs)) res.push(xs[i]);
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// String.prototype.substr - negative index don't work in IE8
|
|
var substr = 'ab'.substr(-1) === 'b'
|
|
? function (str, start, len) { return str.substr(start, len) }
|
|
: function (str, start, len) {
|
|
if (start < 0) start = str.length + start;
|
|
return str.substr(start, len);
|
|
}
|
|
;
|
|
|
|
}).call(this,require("1YiZ5S"))
|
|
},{"1YiZ5S":81}],81:[function(require,module,exports){
|
|
// shim for using process in browser
|
|
|
|
var process = module.exports = {};
|
|
|
|
process.nextTick = (function () {
|
|
var canSetImmediate = typeof window !== 'undefined'
|
|
&& window.setImmediate;
|
|
var canPost = typeof window !== 'undefined'
|
|
&& window.postMessage && window.addEventListener
|
|
;
|
|
|
|
if (canSetImmediate) {
|
|
return function (f) { return window.setImmediate(f) };
|
|
}
|
|
|
|
if (canPost) {
|
|
var queue = [];
|
|
window.addEventListener('message', function (ev) {
|
|
var source = ev.source;
|
|
if ((source === window || source === null) && ev.data === 'process-tick') {
|
|
ev.stopPropagation();
|
|
if (queue.length > 0) {
|
|
var fn = queue.shift();
|
|
fn();
|
|
}
|
|
}
|
|
}, true);
|
|
|
|
return function nextTick(fn) {
|
|
queue.push(fn);
|
|
window.postMessage('process-tick', '*');
|
|
};
|
|
}
|
|
|
|
return function nextTick(fn) {
|
|
setTimeout(fn, 0);
|
|
};
|
|
})();
|
|
|
|
process.title = 'browser';
|
|
process.browser = true;
|
|
process.env = {};
|
|
process.argv = [];
|
|
|
|
function noop() {}
|
|
|
|
process.on = noop;
|
|
process.addListener = noop;
|
|
process.once = noop;
|
|
process.off = noop;
|
|
process.removeListener = noop;
|
|
process.removeAllListeners = noop;
|
|
process.emit = noop;
|
|
|
|
process.binding = function (name) {
|
|
throw new Error('process.binding is not supported');
|
|
}
|
|
|
|
// TODO(shtylman)
|
|
process.cwd = function () { return '/' };
|
|
process.chdir = function (dir) {
|
|
throw new Error('process.chdir is not supported');
|
|
};
|
|
|
|
},{}],82:[function(require,module,exports){
|
|
(function (global){
|
|
/**
|
|
* @license
|
|
* Lo-Dash 2.4.2 (Custom Build) <https://lodash.com/>
|
|
* Build: `lodash modern -o ./dist/lodash.js`
|
|
* Copyright 2012-2013 The Dojo Foundation <http://dojofoundation.org/>
|
|
* Based on Underscore.js 1.5.2 <http://underscorejs.org/LICENSE>
|
|
* Copyright 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
* Available under MIT license <https://lodash.com/license>
|
|
*/
|
|
;(function() {
|
|
|
|
/** Used as a safe reference for `undefined` in pre ES5 environments */
|
|
var undefined;
|
|
|
|
/** Used to pool arrays and objects used internally */
|
|
var arrayPool = [],
|
|
objectPool = [];
|
|
|
|
/** Used to generate unique IDs */
|
|
var idCounter = 0;
|
|
|
|
/** Used to prefix keys to avoid issues with `__proto__` and properties on `Object.prototype` */
|
|
var keyPrefix = +new Date + '';
|
|
|
|
/** Used as the size when optimizations are enabled for large arrays */
|
|
var largeArraySize = 75;
|
|
|
|
/** Used as the max size of the `arrayPool` and `objectPool` */
|
|
var maxPoolSize = 40;
|
|
|
|
/** Used to detect and test whitespace */
|
|
var whitespace = (
|
|
// whitespace
|
|
' \t\x0B\f\xA0\ufeff' +
|
|
|
|
// line terminators
|
|
'\n\r\u2028\u2029' +
|
|
|
|
// unicode category "Zs" space separators
|
|
'\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000'
|
|
);
|
|
|
|
/** Used to match empty string literals in compiled template source */
|
|
var reEmptyStringLeading = /\b__p \+= '';/g,
|
|
reEmptyStringMiddle = /\b(__p \+=) '' \+/g,
|
|
reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
|
|
|
|
/**
|
|
* Used to match ES6 template delimiters
|
|
* http://people.mozilla.org/~jorendorff/es6-draft.html#sec-literals-string-literals
|
|
*/
|
|
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
|
|
|
|
/** Used to match regexp flags from their coerced string values */
|
|
var reFlags = /\w*$/;
|
|
|
|
/** Used to detected named functions */
|
|
var reFuncName = /^\s*function[ \n\r\t]+\w/;
|
|
|
|
/** Used to match "interpolate" template delimiters */
|
|
var reInterpolate = /<%=([\s\S]+?)%>/g;
|
|
|
|
/** Used to match leading whitespace and zeros to be removed */
|
|
var reLeadingSpacesAndZeros = RegExp('^[' + whitespace + ']*0+(?=.$)');
|
|
|
|
/** Used to ensure capturing order of template delimiters */
|
|
var reNoMatch = /($^)/;
|
|
|
|
/** Used to detect functions containing a `this` reference */
|
|
var reThis = /\bthis\b/;
|
|
|
|
/** Used to match unescaped characters in compiled string literals */
|
|
var reUnescapedString = /['\n\r\t\u2028\u2029\\]/g;
|
|
|
|
/** Used to assign default `context` object properties */
|
|
var contextProps = [
|
|
'Array', 'Boolean', 'Date', 'Function', 'Math', 'Number', 'Object',
|
|
'RegExp', 'String', '_', 'attachEvent', 'clearTimeout', 'isFinite', 'isNaN',
|
|
'parseInt', 'setTimeout'
|
|
];
|
|
|
|
/** Used to make template sourceURLs easier to identify */
|
|
var templateCounter = 0;
|
|
|
|
/** `Object#toString` result shortcuts */
|
|
var argsClass = '[object Arguments]',
|
|
arrayClass = '[object Array]',
|
|
boolClass = '[object Boolean]',
|
|
dateClass = '[object Date]',
|
|
funcClass = '[object Function]',
|
|
numberClass = '[object Number]',
|
|
objectClass = '[object Object]',
|
|
regexpClass = '[object RegExp]',
|
|
stringClass = '[object String]';
|
|
|
|
/** Used to identify object classifications that `_.clone` supports */
|
|
var cloneableClasses = {};
|
|
cloneableClasses[funcClass] = false;
|
|
cloneableClasses[argsClass] = cloneableClasses[arrayClass] =
|
|
cloneableClasses[boolClass] = cloneableClasses[dateClass] =
|
|
cloneableClasses[numberClass] = cloneableClasses[objectClass] =
|
|
cloneableClasses[regexpClass] = cloneableClasses[stringClass] = true;
|
|
|
|
/** Used as an internal `_.debounce` options object */
|
|
var debounceOptions = {
|
|
'leading': false,
|
|
'maxWait': 0,
|
|
'trailing': false
|
|
};
|
|
|
|
/** Used as the property descriptor for `__bindData__` */
|
|
var descriptor = {
|
|
'configurable': false,
|
|
'enumerable': false,
|
|
'value': null,
|
|
'writable': false
|
|
};
|
|
|
|
/** Used to determine if values are of the language type Object */
|
|
var objectTypes = {
|
|
'boolean': false,
|
|
'function': true,
|
|
'object': true,
|
|
'number': false,
|
|
'string': false,
|
|
'undefined': false
|
|
};
|
|
|
|
/** Used to escape characters for inclusion in compiled string literals */
|
|
var stringEscapes = {
|
|
'\\': '\\',
|
|
"'": "'",
|
|
'\n': 'n',
|
|
'\r': 'r',
|
|
'\t': 't',
|
|
'\u2028': 'u2028',
|
|
'\u2029': 'u2029'
|
|
};
|
|
|
|
/** Used as a reference to the global object */
|
|
var root = (objectTypes[typeof window] && window) || this;
|
|
|
|
/** Detect free variable `exports` */
|
|
var freeExports = objectTypes[typeof exports] && exports && !exports.nodeType && exports;
|
|
|
|
/** Detect free variable `module` */
|
|
var freeModule = objectTypes[typeof module] && module && !module.nodeType && module;
|
|
|
|
/** Detect the popular CommonJS extension `module.exports` */
|
|
var moduleExports = freeModule && freeModule.exports === freeExports && freeExports;
|
|
|
|
/** Detect free variable `global` from Node.js or Browserified code and use it as `root` */
|
|
var freeGlobal = objectTypes[typeof global] && global;
|
|
if (freeGlobal && (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal)) {
|
|
root = freeGlobal;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* The base implementation of `_.indexOf` without support for binary searches
|
|
* or `fromIndex` constraints.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to search.
|
|
* @param {*} value The value to search for.
|
|
* @param {number} [fromIndex=0] The index to search from.
|
|
* @returns {number} Returns the index of the matched value or `-1`.
|
|
*/
|
|
function baseIndexOf(array, value, fromIndex) {
|
|
var index = (fromIndex || 0) - 1,
|
|
length = array ? array.length : 0;
|
|
|
|
while (++index < length) {
|
|
if (array[index] === value) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* An implementation of `_.contains` for cache objects that mimics the return
|
|
* signature of `_.indexOf` by returning `0` if the value is found, else `-1`.
|
|
*
|
|
* @private
|
|
* @param {Object} cache The cache object to inspect.
|
|
* @param {*} value The value to search for.
|
|
* @returns {number} Returns `0` if `value` is found, else `-1`.
|
|
*/
|
|
function cacheIndexOf(cache, value) {
|
|
var type = typeof value;
|
|
cache = cache.cache;
|
|
|
|
if (type == 'boolean' || value == null) {
|
|
return cache[value] ? 0 : -1;
|
|
}
|
|
if (type != 'number' && type != 'string') {
|
|
type = 'object';
|
|
}
|
|
var key = type == 'number' ? value : keyPrefix + value;
|
|
cache = (cache = cache[type]) && cache[key];
|
|
|
|
return type == 'object'
|
|
? (cache && baseIndexOf(cache, value) > -1 ? 0 : -1)
|
|
: (cache ? 0 : -1);
|
|
}
|
|
|
|
/**
|
|
* Adds a given value to the corresponding cache object.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to add to the cache.
|
|
*/
|
|
function cachePush(value) {
|
|
var cache = this.cache,
|
|
type = typeof value;
|
|
|
|
if (type == 'boolean' || value == null) {
|
|
cache[value] = true;
|
|
} else {
|
|
if (type != 'number' && type != 'string') {
|
|
type = 'object';
|
|
}
|
|
var key = type == 'number' ? value : keyPrefix + value,
|
|
typeCache = cache[type] || (cache[type] = {});
|
|
|
|
if (type == 'object') {
|
|
(typeCache[key] || (typeCache[key] = [])).push(value);
|
|
} else {
|
|
typeCache[key] = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Used by `_.max` and `_.min` as the default callback when a given
|
|
* collection is a string value.
|
|
*
|
|
* @private
|
|
* @param {string} value The character to inspect.
|
|
* @returns {number} Returns the code unit of given character.
|
|
*/
|
|
function charAtCallback(value) {
|
|
return value.charCodeAt(0);
|
|
}
|
|
|
|
/**
|
|
* Used by `sortBy` to compare transformed `collection` elements, stable sorting
|
|
* them in ascending order.
|
|
*
|
|
* @private
|
|
* @param {Object} a The object to compare to `b`.
|
|
* @param {Object} b The object to compare to `a`.
|
|
* @returns {number} Returns the sort order indicator of `1` or `-1`.
|
|
*/
|
|
function compareAscending(a, b) {
|
|
var ac = a.criteria,
|
|
bc = b.criteria,
|
|
index = -1,
|
|
length = ac.length;
|
|
|
|
while (++index < length) {
|
|
var value = ac[index],
|
|
other = bc[index];
|
|
|
|
if (value !== other) {
|
|
if (value > other || typeof value == 'undefined') {
|
|
return 1;
|
|
}
|
|
if (value < other || typeof other == 'undefined') {
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
// Fixes an `Array#sort` bug in the JS engine embedded in Adobe applications
|
|
// that causes it, under certain circumstances, to return the same value for
|
|
// `a` and `b`. See https://github.com/jashkenas/underscore/pull/1247
|
|
//
|
|
// This also ensures a stable sort in V8 and other engines.
|
|
// See http://code.google.com/p/v8/issues/detail?id=90
|
|
return a.index - b.index;
|
|
}
|
|
|
|
/**
|
|
* Creates a cache object to optimize linear searches of large arrays.
|
|
*
|
|
* @private
|
|
* @param {Array} [array=[]] The array to search.
|
|
* @returns {null|Object} Returns the cache object or `null` if caching should not be used.
|
|
*/
|
|
function createCache(array) {
|
|
var index = -1,
|
|
length = array.length,
|
|
first = array[0],
|
|
mid = array[(length / 2) | 0],
|
|
last = array[length - 1];
|
|
|
|
if (first && typeof first == 'object' &&
|
|
mid && typeof mid == 'object' && last && typeof last == 'object') {
|
|
return false;
|
|
}
|
|
var cache = getObject();
|
|
cache['false'] = cache['null'] = cache['true'] = cache['undefined'] = false;
|
|
|
|
var result = getObject();
|
|
result.array = array;
|
|
result.cache = cache;
|
|
result.push = cachePush;
|
|
|
|
while (++index < length) {
|
|
result.push(array[index]);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Used by `template` to escape characters for inclusion in compiled
|
|
* string literals.
|
|
*
|
|
* @private
|
|
* @param {string} match The matched character to escape.
|
|
* @returns {string} Returns the escaped character.
|
|
*/
|
|
function escapeStringChar(match) {
|
|
return '\\' + stringEscapes[match];
|
|
}
|
|
|
|
/**
|
|
* Gets an array from the array pool or creates a new one if the pool is empty.
|
|
*
|
|
* @private
|
|
* @returns {Array} The array from the pool.
|
|
*/
|
|
function getArray() {
|
|
return arrayPool.pop() || [];
|
|
}
|
|
|
|
/**
|
|
* Gets an object from the object pool or creates a new one if the pool is empty.
|
|
*
|
|
* @private
|
|
* @returns {Object} The object from the pool.
|
|
*/
|
|
function getObject() {
|
|
return objectPool.pop() || {
|
|
'array': null,
|
|
'cache': null,
|
|
'criteria': null,
|
|
'false': false,
|
|
'index': 0,
|
|
'null': false,
|
|
'number': null,
|
|
'object': null,
|
|
'push': null,
|
|
'string': null,
|
|
'true': false,
|
|
'undefined': false,
|
|
'value': null
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Releases the given array back to the array pool.
|
|
*
|
|
* @private
|
|
* @param {Array} [array] The array to release.
|
|
*/
|
|
function releaseArray(array) {
|
|
array.length = 0;
|
|
if (arrayPool.length < maxPoolSize) {
|
|
arrayPool.push(array);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Releases the given object back to the object pool.
|
|
*
|
|
* @private
|
|
* @param {Object} [object] The object to release.
|
|
*/
|
|
function releaseObject(object) {
|
|
var cache = object.cache;
|
|
if (cache) {
|
|
releaseObject(cache);
|
|
}
|
|
object.array = object.cache = object.criteria = object.object = object.number = object.string = object.value = null;
|
|
if (objectPool.length < maxPoolSize) {
|
|
objectPool.push(object);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Slices the `collection` from the `start` index up to, but not including,
|
|
* the `end` index.
|
|
*
|
|
* Note: This function is used instead of `Array#slice` to support node lists
|
|
* in IE < 9 and to ensure dense arrays are returned.
|
|
*
|
|
* @private
|
|
* @param {Array|Object|string} collection The collection to slice.
|
|
* @param {number} start The start index.
|
|
* @param {number} end The end index.
|
|
* @returns {Array} Returns the new array.
|
|
*/
|
|
function slice(array, start, end) {
|
|
start || (start = 0);
|
|
if (typeof end == 'undefined') {
|
|
end = array ? array.length : 0;
|
|
}
|
|
var index = -1,
|
|
length = end - start || 0,
|
|
result = Array(length < 0 ? 0 : length);
|
|
|
|
while (++index < length) {
|
|
result[index] = array[start + index];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Create a new `lodash` function using the given context object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {Object} [context=root] The context object.
|
|
* @returns {Function} Returns the `lodash` function.
|
|
*/
|
|
function runInContext(context) {
|
|
// Avoid issues with some ES3 environments that attempt to use values, named
|
|
// after built-in constructors like `Object`, for the creation of literals.
|
|
// ES5 clears this up by stating that literals must use built-in constructors.
|
|
// See http://es5.github.io/#x11.1.5.
|
|
context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
|
|
|
|
/** Native constructor references */
|
|
var Array = context.Array,
|
|
Boolean = context.Boolean,
|
|
Date = context.Date,
|
|
Function = context.Function,
|
|
Math = context.Math,
|
|
Number = context.Number,
|
|
Object = context.Object,
|
|
RegExp = context.RegExp,
|
|
String = context.String,
|
|
TypeError = context.TypeError;
|
|
|
|
/**
|
|
* Used for `Array` method references.
|
|
*
|
|
* Normally `Array.prototype` would suffice, however, using an array literal
|
|
* avoids issues in Narwhal.
|
|
*/
|
|
var arrayRef = [];
|
|
|
|
/** Used for native method references */
|
|
var objectProto = Object.prototype;
|
|
|
|
/** Used to restore the original `_` reference in `noConflict` */
|
|
var oldDash = context._;
|
|
|
|
/** Used to resolve the internal [[Class]] of values */
|
|
var toString = objectProto.toString;
|
|
|
|
/** Used to detect if a method is native */
|
|
var reNative = RegExp('^' +
|
|
String(toString)
|
|
.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
.replace(/toString| for [^\]]+/g, '.*?') + '$'
|
|
);
|
|
|
|
/** Native method shortcuts */
|
|
var ceil = Math.ceil,
|
|
clearTimeout = context.clearTimeout,
|
|
floor = Math.floor,
|
|
fnToString = Function.prototype.toString,
|
|
getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
|
|
hasOwnProperty = objectProto.hasOwnProperty,
|
|
push = arrayRef.push,
|
|
setTimeout = context.setTimeout,
|
|
splice = arrayRef.splice,
|
|
unshift = arrayRef.unshift;
|
|
|
|
/** Used to set meta data on functions */
|
|
var defineProperty = (function() {
|
|
// IE 8 only accepts DOM elements
|
|
try {
|
|
var o = {},
|
|
func = isNative(func = Object.defineProperty) && func,
|
|
result = func(o, o, o) && func;
|
|
} catch(e) { }
|
|
return result;
|
|
}());
|
|
|
|
/* Native method shortcuts for methods with the same name as other `lodash` methods */
|
|
var nativeCreate = isNative(nativeCreate = Object.create) && nativeCreate,
|
|
nativeIsArray = isNative(nativeIsArray = Array.isArray) && nativeIsArray,
|
|
nativeIsFinite = context.isFinite,
|
|
nativeIsNaN = context.isNaN,
|
|
nativeKeys = isNative(nativeKeys = Object.keys) && nativeKeys,
|
|
nativeMax = Math.max,
|
|
nativeMin = Math.min,
|
|
nativeParseInt = context.parseInt,
|
|
nativeRandom = Math.random;
|
|
|
|
/** Used to lookup a built-in constructor by [[Class]] */
|
|
var ctorByClass = {};
|
|
ctorByClass[arrayClass] = Array;
|
|
ctorByClass[boolClass] = Boolean;
|
|
ctorByClass[dateClass] = Date;
|
|
ctorByClass[funcClass] = Function;
|
|
ctorByClass[objectClass] = Object;
|
|
ctorByClass[numberClass] = Number;
|
|
ctorByClass[regexpClass] = RegExp;
|
|
ctorByClass[stringClass] = String;
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a `lodash` object which wraps the given value to enable intuitive
|
|
* method chaining.
|
|
*
|
|
* In addition to Lo-Dash methods, wrappers also have the following `Array` methods:
|
|
* `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`, `splice`,
|
|
* and `unshift`
|
|
*
|
|
* Chaining is supported in custom builds as long as the `value` method is
|
|
* implicitly or explicitly included in the build.
|
|
*
|
|
* The chainable wrapper functions are:
|
|
* `after`, `assign`, `bind`, `bindAll`, `bindKey`, `chain`, `compact`,
|
|
* `compose`, `concat`, `countBy`, `create`, `createCallback`, `curry`,
|
|
* `debounce`, `defaults`, `defer`, `delay`, `difference`, `filter`, `flatten`,
|
|
* `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
|
|
* `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
|
|
* `invoke`, `keys`, `map`, `max`, `memoize`, `merge`, `min`, `object`, `omit`,
|
|
* `once`, `pairs`, `partial`, `partialRight`, `pick`, `pluck`, `pull`, `push`,
|
|
* `range`, `reject`, `remove`, `rest`, `reverse`, `shuffle`, `slice`, `sort`,
|
|
* `sortBy`, `splice`, `tap`, `throttle`, `times`, `toArray`, `transform`,
|
|
* `union`, `uniq`, `unshift`, `unzip`, `values`, `where`, `without`, `wrap`,
|
|
* and `zip`
|
|
*
|
|
* The non-chainable wrapper functions are:
|
|
* `clone`, `cloneDeep`, `contains`, `escape`, `every`, `find`, `findIndex`,
|
|
* `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `has`, `identity`,
|
|
* `indexOf`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
|
|
* `isEmpty`, `isEqual`, `isFinite`, `isFunction`, `isNaN`, `isNull`, `isNumber`,
|
|
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, `join`,
|
|
* `lastIndexOf`, `mixin`, `noConflict`, `parseInt`, `pop`, `random`, `reduce`,
|
|
* `reduceRight`, `result`, `shift`, `size`, `some`, `sortedIndex`, `runInContext`,
|
|
* `template`, `unescape`, `uniqueId`, and `value`
|
|
*
|
|
* The wrapper functions `first` and `last` return wrapped values when `n` is
|
|
* provided, otherwise they return unwrapped values.
|
|
*
|
|
* Explicit chaining can be enabled by using the `_.chain` method.
|
|
*
|
|
* @name _
|
|
* @constructor
|
|
* @category Chaining
|
|
* @param {*} value The value to wrap in a `lodash` instance.
|
|
* @returns {Object} Returns a `lodash` instance.
|
|
* @example
|
|
*
|
|
* var wrapped = _([1, 2, 3]);
|
|
*
|
|
* // returns an unwrapped value
|
|
* wrapped.reduce(function(sum, num) {
|
|
* return sum + num;
|
|
* });
|
|
* // => 6
|
|
*
|
|
* // returns a wrapped value
|
|
* var squares = wrapped.map(function(num) {
|
|
* return num * num;
|
|
* });
|
|
*
|
|
* _.isArray(squares);
|
|
* // => false
|
|
*
|
|
* _.isArray(squares.value());
|
|
* // => true
|
|
*/
|
|
function lodash(value) {
|
|
// don't wrap if already wrapped, even if wrapped by a different `lodash` constructor
|
|
return (value && typeof value == 'object' && !isArray(value) && hasOwnProperty.call(value, '__wrapped__'))
|
|
? value
|
|
: new lodashWrapper(value);
|
|
}
|
|
|
|
/**
|
|
* A fast path for creating `lodash` wrapper objects.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to wrap in a `lodash` instance.
|
|
* @param {boolean} chainAll A flag to enable chaining for all methods
|
|
* @returns {Object} Returns a `lodash` instance.
|
|
*/
|
|
function lodashWrapper(value, chainAll) {
|
|
this.__chain__ = !!chainAll;
|
|
this.__wrapped__ = value;
|
|
}
|
|
// ensure `new lodashWrapper` is an instance of `lodash`
|
|
lodashWrapper.prototype = lodash.prototype;
|
|
|
|
/**
|
|
* An object used to flag environments features.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Object
|
|
*/
|
|
var support = lodash.support = {};
|
|
|
|
/**
|
|
* Detect if functions can be decompiled by `Function#toString`
|
|
* (all but PS3 and older Opera mobile browsers & avoided in Windows 8 apps).
|
|
*
|
|
* @memberOf _.support
|
|
* @type boolean
|
|
*/
|
|
support.funcDecomp = !isNative(context.WinRTError) && reThis.test(runInContext);
|
|
|
|
/**
|
|
* Detect if `Function#name` is supported (all but IE).
|
|
*
|
|
* @memberOf _.support
|
|
* @type boolean
|
|
*/
|
|
support.funcNames = typeof Function.name == 'string';
|
|
|
|
/**
|
|
* By default, the template delimiters used by Lo-Dash are similar to those in
|
|
* embedded Ruby (ERB). Change the following template settings to use alternative
|
|
* delimiters.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Object
|
|
*/
|
|
lodash.templateSettings = {
|
|
|
|
/**
|
|
* Used to detect `data` property values to be HTML-escaped.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type RegExp
|
|
*/
|
|
'escape': /<%-([\s\S]+?)%>/g,
|
|
|
|
/**
|
|
* Used to detect code to be evaluated.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type RegExp
|
|
*/
|
|
'evaluate': /<%([\s\S]+?)%>/g,
|
|
|
|
/**
|
|
* Used to detect `data` property values to inject.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type RegExp
|
|
*/
|
|
'interpolate': reInterpolate,
|
|
|
|
/**
|
|
* Used to reference the data object in the template text.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type string
|
|
*/
|
|
'variable': '',
|
|
|
|
/**
|
|
* Used to import variables into the compiled template.
|
|
*
|
|
* @memberOf _.templateSettings
|
|
* @type Object
|
|
*/
|
|
'imports': {
|
|
|
|
/**
|
|
* A reference to the `lodash` function.
|
|
*
|
|
* @memberOf _.templateSettings.imports
|
|
* @type Function
|
|
*/
|
|
'_': lodash
|
|
}
|
|
};
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* The base implementation of `_.bind` that creates the bound function and
|
|
* sets its meta data.
|
|
*
|
|
* @private
|
|
* @param {Array} bindData The bind data array.
|
|
* @returns {Function} Returns the new bound function.
|
|
*/
|
|
function baseBind(bindData) {
|
|
var func = bindData[0],
|
|
partialArgs = bindData[2],
|
|
thisArg = bindData[4];
|
|
|
|
function bound() {
|
|
// `Function#bind` spec
|
|
// http://es5.github.io/#x15.3.4.5
|
|
if (partialArgs) {
|
|
// avoid `arguments` object deoptimizations by using `slice` instead
|
|
// of `Array.prototype.slice.call` and not assigning `arguments` to a
|
|
// variable as a ternary expression
|
|
var args = slice(partialArgs);
|
|
push.apply(args, arguments);
|
|
}
|
|
// mimic the constructor's `return` behavior
|
|
// http://es5.github.io/#x13.2.2
|
|
if (this instanceof bound) {
|
|
// ensure `new bound` is an instance of `func`
|
|
var thisBinding = baseCreate(func.prototype),
|
|
result = func.apply(thisBinding, args || arguments);
|
|
return isObject(result) ? result : thisBinding;
|
|
}
|
|
return func.apply(thisArg, args || arguments);
|
|
}
|
|
setBindData(bound, bindData);
|
|
return bound;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.clone` without argument juggling or support
|
|
* for `thisArg` binding.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to clone.
|
|
* @param {boolean} [isDeep=false] Specify a deep clone.
|
|
* @param {Function} [callback] The function to customize cloning values.
|
|
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
|
* @param {Array} [stackB=[]] Associates clones with source counterparts.
|
|
* @returns {*} Returns the cloned value.
|
|
*/
|
|
function baseClone(value, isDeep, callback, stackA, stackB) {
|
|
if (callback) {
|
|
var result = callback(value);
|
|
if (typeof result != 'undefined') {
|
|
return result;
|
|
}
|
|
}
|
|
// inspect [[Class]]
|
|
var isObj = isObject(value);
|
|
if (isObj) {
|
|
var className = toString.call(value);
|
|
if (!cloneableClasses[className]) {
|
|
return value;
|
|
}
|
|
var ctor = ctorByClass[className];
|
|
switch (className) {
|
|
case boolClass:
|
|
case dateClass:
|
|
return new ctor(+value);
|
|
|
|
case numberClass:
|
|
case stringClass:
|
|
return new ctor(value);
|
|
|
|
case regexpClass:
|
|
result = ctor(value.source, reFlags.exec(value));
|
|
result.lastIndex = value.lastIndex;
|
|
return result;
|
|
}
|
|
} else {
|
|
return value;
|
|
}
|
|
var isArr = isArray(value);
|
|
if (isDeep) {
|
|
// check for circular references and return corresponding clone
|
|
var initedStack = !stackA;
|
|
stackA || (stackA = getArray());
|
|
stackB || (stackB = getArray());
|
|
|
|
var length = stackA.length;
|
|
while (length--) {
|
|
if (stackA[length] == value) {
|
|
return stackB[length];
|
|
}
|
|
}
|
|
result = isArr ? ctor(value.length) : {};
|
|
}
|
|
else {
|
|
result = isArr ? slice(value) : assign({}, value);
|
|
}
|
|
// add array properties assigned by `RegExp#exec`
|
|
if (isArr) {
|
|
if (hasOwnProperty.call(value, 'index')) {
|
|
result.index = value.index;
|
|
}
|
|
if (hasOwnProperty.call(value, 'input')) {
|
|
result.input = value.input;
|
|
}
|
|
}
|
|
// exit for shallow clone
|
|
if (!isDeep) {
|
|
return result;
|
|
}
|
|
// add the source value to the stack of traversed objects
|
|
// and associate it with its clone
|
|
stackA.push(value);
|
|
stackB.push(result);
|
|
|
|
// recursively populate clone (susceptible to call stack limits)
|
|
(isArr ? forEach : forOwn)(value, function(objValue, key) {
|
|
result[key] = baseClone(objValue, isDeep, callback, stackA, stackB);
|
|
});
|
|
|
|
if (initedStack) {
|
|
releaseArray(stackA);
|
|
releaseArray(stackB);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.create` without support for assigning
|
|
* properties to the created object.
|
|
*
|
|
* @private
|
|
* @param {Object} prototype The object to inherit from.
|
|
* @returns {Object} Returns the new object.
|
|
*/
|
|
function baseCreate(prototype, properties) {
|
|
return isObject(prototype) ? nativeCreate(prototype) : {};
|
|
}
|
|
// fallback for browsers without `Object.create`
|
|
if (!nativeCreate) {
|
|
baseCreate = (function() {
|
|
function Object() {}
|
|
return function(prototype) {
|
|
if (isObject(prototype)) {
|
|
Object.prototype = prototype;
|
|
var result = new Object;
|
|
Object.prototype = null;
|
|
}
|
|
return result || context.Object();
|
|
};
|
|
}());
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.createCallback` without support for creating
|
|
* "_.pluck" or "_.where" style callbacks.
|
|
*
|
|
* @private
|
|
* @param {*} [func=identity] The value to convert to a callback.
|
|
* @param {*} [thisArg] The `this` binding of the created callback.
|
|
* @param {number} [argCount] The number of arguments the callback accepts.
|
|
* @returns {Function} Returns a callback function.
|
|
*/
|
|
function baseCreateCallback(func, thisArg, argCount) {
|
|
if (typeof func != 'function') {
|
|
return identity;
|
|
}
|
|
// exit early for no `thisArg` or already bound by `Function#bind`
|
|
if (typeof thisArg == 'undefined' || !('prototype' in func)) {
|
|
return func;
|
|
}
|
|
var bindData = func.__bindData__;
|
|
if (typeof bindData == 'undefined') {
|
|
if (support.funcNames) {
|
|
bindData = !func.name;
|
|
}
|
|
bindData = bindData || !support.funcDecomp;
|
|
if (!bindData) {
|
|
var source = fnToString.call(func);
|
|
if (!support.funcNames) {
|
|
bindData = !reFuncName.test(source);
|
|
}
|
|
if (!bindData) {
|
|
// checks if `func` references the `this` keyword and stores the result
|
|
bindData = reThis.test(source);
|
|
setBindData(func, bindData);
|
|
}
|
|
}
|
|
}
|
|
// exit early if there are no `this` references or `func` is bound
|
|
if (bindData === false || (bindData !== true && bindData[1] & 1)) {
|
|
return func;
|
|
}
|
|
switch (argCount) {
|
|
case 1: return function(value) {
|
|
return func.call(thisArg, value);
|
|
};
|
|
case 2: return function(a, b) {
|
|
return func.call(thisArg, a, b);
|
|
};
|
|
case 3: return function(value, index, collection) {
|
|
return func.call(thisArg, value, index, collection);
|
|
};
|
|
case 4: return function(accumulator, value, index, collection) {
|
|
return func.call(thisArg, accumulator, value, index, collection);
|
|
};
|
|
}
|
|
return bind(func, thisArg);
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `createWrapper` that creates the wrapper and
|
|
* sets its meta data.
|
|
*
|
|
* @private
|
|
* @param {Array} bindData The bind data array.
|
|
* @returns {Function} Returns the new function.
|
|
*/
|
|
function baseCreateWrapper(bindData) {
|
|
var func = bindData[0],
|
|
bitmask = bindData[1],
|
|
partialArgs = bindData[2],
|
|
partialRightArgs = bindData[3],
|
|
thisArg = bindData[4],
|
|
arity = bindData[5];
|
|
|
|
var isBind = bitmask & 1,
|
|
isBindKey = bitmask & 2,
|
|
isCurry = bitmask & 4,
|
|
isCurryBound = bitmask & 8,
|
|
key = func;
|
|
|
|
function bound() {
|
|
var thisBinding = isBind ? thisArg : this;
|
|
if (partialArgs) {
|
|
var args = slice(partialArgs);
|
|
push.apply(args, arguments);
|
|
}
|
|
if (partialRightArgs || isCurry) {
|
|
args || (args = slice(arguments));
|
|
if (partialRightArgs) {
|
|
push.apply(args, partialRightArgs);
|
|
}
|
|
if (isCurry && args.length < arity) {
|
|
bitmask |= 16 & ~32;
|
|
return baseCreateWrapper([func, (isCurryBound ? bitmask : bitmask & ~3), args, null, thisArg, arity]);
|
|
}
|
|
}
|
|
args || (args = arguments);
|
|
if (isBindKey) {
|
|
func = thisBinding[key];
|
|
}
|
|
if (this instanceof bound) {
|
|
thisBinding = baseCreate(func.prototype);
|
|
var result = func.apply(thisBinding, args);
|
|
return isObject(result) ? result : thisBinding;
|
|
}
|
|
return func.apply(thisBinding, args);
|
|
}
|
|
setBindData(bound, bindData);
|
|
return bound;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.difference` that accepts a single array
|
|
* of values to exclude.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to process.
|
|
* @param {Array} [values] The array of values to exclude.
|
|
* @returns {Array} Returns a new array of filtered values.
|
|
*/
|
|
function baseDifference(array, values) {
|
|
var index = -1,
|
|
indexOf = getIndexOf(),
|
|
length = array ? array.length : 0,
|
|
isLarge = length >= largeArraySize && indexOf === baseIndexOf,
|
|
result = [];
|
|
|
|
if (isLarge) {
|
|
var cache = createCache(values);
|
|
if (cache) {
|
|
indexOf = cacheIndexOf;
|
|
values = cache;
|
|
} else {
|
|
isLarge = false;
|
|
}
|
|
}
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (indexOf(values, value) < 0) {
|
|
result.push(value);
|
|
}
|
|
}
|
|
if (isLarge) {
|
|
releaseObject(values);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.flatten` without support for callback
|
|
* shorthands or `thisArg` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to flatten.
|
|
* @param {boolean} [isShallow=false] A flag to restrict flattening to a single level.
|
|
* @param {boolean} [isStrict=false] A flag to restrict flattening to arrays and `arguments` objects.
|
|
* @param {number} [fromIndex=0] The index to start from.
|
|
* @returns {Array} Returns a new flattened array.
|
|
*/
|
|
function baseFlatten(array, isShallow, isStrict, fromIndex) {
|
|
var index = (fromIndex || 0) - 1,
|
|
length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
|
|
if (value && typeof value == 'object' && typeof value.length == 'number'
|
|
&& (isArray(value) || isArguments(value))) {
|
|
// recursively flatten arrays (susceptible to call stack limits)
|
|
if (!isShallow) {
|
|
value = baseFlatten(value, isShallow, isStrict);
|
|
}
|
|
var valIndex = -1,
|
|
valLength = value.length,
|
|
resIndex = result.length;
|
|
|
|
result.length += valLength;
|
|
while (++valIndex < valLength) {
|
|
result[resIndex++] = value[valIndex];
|
|
}
|
|
} else if (!isStrict) {
|
|
result.push(value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.isEqual`, without support for `thisArg` binding,
|
|
* that allows partial "_.where" style comparisons.
|
|
*
|
|
* @private
|
|
* @param {*} a The value to compare.
|
|
* @param {*} b The other value to compare.
|
|
* @param {Function} [callback] The function to customize comparing values.
|
|
* @param {Function} [isWhere=false] A flag to indicate performing partial comparisons.
|
|
* @param {Array} [stackA=[]] Tracks traversed `a` objects.
|
|
* @param {Array} [stackB=[]] Tracks traversed `b` objects.
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
*/
|
|
function baseIsEqual(a, b, callback, isWhere, stackA, stackB) {
|
|
// used to indicate that when comparing objects, `a` has at least the properties of `b`
|
|
if (callback) {
|
|
var result = callback(a, b);
|
|
if (typeof result != 'undefined') {
|
|
return !!result;
|
|
}
|
|
}
|
|
// exit early for identical values
|
|
if (a === b) {
|
|
// treat `+0` vs. `-0` as not equal
|
|
return a !== 0 || (1 / a == 1 / b);
|
|
}
|
|
var type = typeof a,
|
|
otherType = typeof b;
|
|
|
|
// exit early for unlike primitive values
|
|
if (a === a &&
|
|
!(a && objectTypes[type]) &&
|
|
!(b && objectTypes[otherType])) {
|
|
return false;
|
|
}
|
|
// exit early for `null` and `undefined` avoiding ES3's Function#call behavior
|
|
// http://es5.github.io/#x15.3.4.4
|
|
if (a == null || b == null) {
|
|
return a === b;
|
|
}
|
|
// compare [[Class]] names
|
|
var className = toString.call(a),
|
|
otherClass = toString.call(b);
|
|
|
|
if (className == argsClass) {
|
|
className = objectClass;
|
|
}
|
|
if (otherClass == argsClass) {
|
|
otherClass = objectClass;
|
|
}
|
|
if (className != otherClass) {
|
|
return false;
|
|
}
|
|
switch (className) {
|
|
case boolClass:
|
|
case dateClass:
|
|
// coerce dates and booleans to numbers, dates to milliseconds and booleans
|
|
// to `1` or `0` treating invalid dates coerced to `NaN` as not equal
|
|
return +a == +b;
|
|
|
|
case numberClass:
|
|
// treat `NaN` vs. `NaN` as equal
|
|
return (a != +a)
|
|
? b != +b
|
|
// but treat `+0` vs. `-0` as not equal
|
|
: (a == 0 ? (1 / a == 1 / b) : a == +b);
|
|
|
|
case regexpClass:
|
|
case stringClass:
|
|
// coerce regexes to strings (http://es5.github.io/#x15.10.6.4)
|
|
// treat string primitives and their corresponding object instances as equal
|
|
return a == String(b);
|
|
}
|
|
var isArr = className == arrayClass;
|
|
if (!isArr) {
|
|
// unwrap any `lodash` wrapped values
|
|
var aWrapped = hasOwnProperty.call(a, '__wrapped__'),
|
|
bWrapped = hasOwnProperty.call(b, '__wrapped__');
|
|
|
|
if (aWrapped || bWrapped) {
|
|
return baseIsEqual(aWrapped ? a.__wrapped__ : a, bWrapped ? b.__wrapped__ : b, callback, isWhere, stackA, stackB);
|
|
}
|
|
// exit for functions and DOM nodes
|
|
if (className != objectClass) {
|
|
return false;
|
|
}
|
|
// in older versions of Opera, `arguments` objects have `Array` constructors
|
|
var ctorA = a.constructor,
|
|
ctorB = b.constructor;
|
|
|
|
// non `Object` object instances with different constructors are not equal
|
|
if (ctorA != ctorB &&
|
|
!(isFunction(ctorA) && ctorA instanceof ctorA && isFunction(ctorB) && ctorB instanceof ctorB) &&
|
|
('constructor' in a && 'constructor' in b)
|
|
) {
|
|
return false;
|
|
}
|
|
}
|
|
// assume cyclic structures are equal
|
|
// the algorithm for detecting cyclic structures is adapted from ES 5.1
|
|
// section 15.12.3, abstract operation `JO` (http://es5.github.io/#x15.12.3)
|
|
var initedStack = !stackA;
|
|
stackA || (stackA = getArray());
|
|
stackB || (stackB = getArray());
|
|
|
|
var length = stackA.length;
|
|
while (length--) {
|
|
if (stackA[length] == a) {
|
|
return stackB[length] == b;
|
|
}
|
|
}
|
|
var size = 0;
|
|
result = true;
|
|
|
|
// add `a` and `b` to the stack of traversed objects
|
|
stackA.push(a);
|
|
stackB.push(b);
|
|
|
|
// recursively compare objects and arrays (susceptible to call stack limits)
|
|
if (isArr) {
|
|
// compare lengths to determine if a deep comparison is necessary
|
|
length = a.length;
|
|
size = b.length;
|
|
result = size == length;
|
|
|
|
if (result || isWhere) {
|
|
// deep compare the contents, ignoring non-numeric properties
|
|
while (size--) {
|
|
var index = length,
|
|
value = b[size];
|
|
|
|
if (isWhere) {
|
|
while (index--) {
|
|
if ((result = baseIsEqual(a[index], value, callback, isWhere, stackA, stackB))) {
|
|
break;
|
|
}
|
|
}
|
|
} else if (!(result = baseIsEqual(a[size], value, callback, isWhere, stackA, stackB))) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// deep compare objects using `forIn`, instead of `forOwn`, to avoid `Object.keys`
|
|
// which, in this case, is more costly
|
|
forIn(b, function(value, key, b) {
|
|
if (hasOwnProperty.call(b, key)) {
|
|
// count the number of properties.
|
|
size++;
|
|
// deep compare each property value.
|
|
return (result = hasOwnProperty.call(a, key) && baseIsEqual(a[key], value, callback, isWhere, stackA, stackB));
|
|
}
|
|
});
|
|
|
|
if (result && !isWhere) {
|
|
// ensure both objects have the same number of properties
|
|
forIn(a, function(value, key, a) {
|
|
if (hasOwnProperty.call(a, key)) {
|
|
// `size` will be `-1` if `a` has more properties than `b`
|
|
return (result = --size > -1);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
stackA.pop();
|
|
stackB.pop();
|
|
|
|
if (initedStack) {
|
|
releaseArray(stackA);
|
|
releaseArray(stackB);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.merge` without argument juggling or support
|
|
* for `thisArg` binding.
|
|
*
|
|
* @private
|
|
* @param {Object} object The destination object.
|
|
* @param {Object} source The source object.
|
|
* @param {Function} [callback] The function to customize merging properties.
|
|
* @param {Array} [stackA=[]] Tracks traversed source objects.
|
|
* @param {Array} [stackB=[]] Associates values with source counterparts.
|
|
*/
|
|
function baseMerge(object, source, callback, stackA, stackB) {
|
|
(isArray(source) ? forEach : forOwn)(source, function(source, key) {
|
|
var found,
|
|
isArr,
|
|
result = source,
|
|
value = object[key];
|
|
|
|
if (source && ((isArr = isArray(source)) || isPlainObject(source))) {
|
|
// avoid merging previously merged cyclic sources
|
|
var stackLength = stackA.length;
|
|
while (stackLength--) {
|
|
if ((found = stackA[stackLength] == source)) {
|
|
value = stackB[stackLength];
|
|
break;
|
|
}
|
|
}
|
|
if (!found) {
|
|
var isShallow;
|
|
if (callback) {
|
|
result = callback(value, source);
|
|
if ((isShallow = typeof result != 'undefined')) {
|
|
value = result;
|
|
}
|
|
}
|
|
if (!isShallow) {
|
|
value = isArr
|
|
? (isArray(value) ? value : [])
|
|
: (isPlainObject(value) ? value : {});
|
|
}
|
|
// add `source` and associated `value` to the stack of traversed objects
|
|
stackA.push(source);
|
|
stackB.push(value);
|
|
|
|
// recursively merge objects and arrays (susceptible to call stack limits)
|
|
if (!isShallow) {
|
|
baseMerge(value, source, callback, stackA, stackB);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
if (callback) {
|
|
result = callback(value, source);
|
|
if (typeof result == 'undefined') {
|
|
result = source;
|
|
}
|
|
}
|
|
if (typeof result != 'undefined') {
|
|
value = result;
|
|
}
|
|
}
|
|
object[key] = value;
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.random` without argument juggling or support
|
|
* for returning floating-point numbers.
|
|
*
|
|
* @private
|
|
* @param {number} min The minimum possible value.
|
|
* @param {number} max The maximum possible value.
|
|
* @returns {number} Returns a random number.
|
|
*/
|
|
function baseRandom(min, max) {
|
|
return min + floor(nativeRandom() * (max - min + 1));
|
|
}
|
|
|
|
/**
|
|
* The base implementation of `_.uniq` without support for callback shorthands
|
|
* or `thisArg` binding.
|
|
*
|
|
* @private
|
|
* @param {Array} array The array to process.
|
|
* @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted.
|
|
* @param {Function} [callback] The function called per iteration.
|
|
* @returns {Array} Returns a duplicate-value-free array.
|
|
*/
|
|
function baseUniq(array, isSorted, callback) {
|
|
var index = -1,
|
|
indexOf = getIndexOf(),
|
|
length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
var isLarge = !isSorted && length >= largeArraySize && indexOf === baseIndexOf,
|
|
seen = (callback || isLarge) ? getArray() : result;
|
|
|
|
if (isLarge) {
|
|
var cache = createCache(seen);
|
|
indexOf = cacheIndexOf;
|
|
seen = cache;
|
|
}
|
|
while (++index < length) {
|
|
var value = array[index],
|
|
computed = callback ? callback(value, index, array) : value;
|
|
|
|
if (isSorted
|
|
? !index || seen[seen.length - 1] !== computed
|
|
: indexOf(seen, computed) < 0
|
|
) {
|
|
if (callback || isLarge) {
|
|
seen.push(computed);
|
|
}
|
|
result.push(value);
|
|
}
|
|
}
|
|
if (isLarge) {
|
|
releaseArray(seen.array);
|
|
releaseObject(seen);
|
|
} else if (callback) {
|
|
releaseArray(seen);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that aggregates a collection, creating an object composed
|
|
* of keys generated from the results of running each element of the collection
|
|
* through a callback. The given `setter` function sets the keys and values
|
|
* of the composed object.
|
|
*
|
|
* @private
|
|
* @param {Function} setter The setter function.
|
|
* @returns {Function} Returns the new aggregator function.
|
|
*/
|
|
function createAggregator(setter) {
|
|
return function(collection, callback, thisArg) {
|
|
var result = {};
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
if (typeof length == 'number') {
|
|
while (++index < length) {
|
|
var value = collection[index];
|
|
setter(result, value, callback(value, index, collection), collection);
|
|
}
|
|
} else {
|
|
forOwn(collection, function(value, key, collection) {
|
|
setter(result, value, callback(value, key, collection), collection);
|
|
});
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that, when called, either curries or invokes `func`
|
|
* with an optional `this` binding and partially applied arguments.
|
|
*
|
|
* @private
|
|
* @param {Function|string} func The function or method name to reference.
|
|
* @param {number} bitmask The bitmask of method flags to compose.
|
|
* The bitmask may be composed of the following flags:
|
|
* 1 - `_.bind`
|
|
* 2 - `_.bindKey`
|
|
* 4 - `_.curry`
|
|
* 8 - `_.curry` (bound)
|
|
* 16 - `_.partial`
|
|
* 32 - `_.partialRight`
|
|
* @param {Array} [partialArgs] An array of arguments to prepend to those
|
|
* provided to the new function.
|
|
* @param {Array} [partialRightArgs] An array of arguments to append to those
|
|
* provided to the new function.
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @param {number} [arity] The arity of `func`.
|
|
* @returns {Function} Returns the new function.
|
|
*/
|
|
function createWrapper(func, bitmask, partialArgs, partialRightArgs, thisArg, arity) {
|
|
var isBind = bitmask & 1,
|
|
isBindKey = bitmask & 2,
|
|
isCurry = bitmask & 4,
|
|
isCurryBound = bitmask & 8,
|
|
isPartial = bitmask & 16,
|
|
isPartialRight = bitmask & 32;
|
|
|
|
if (!isBindKey && !isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
if (isPartial && !partialArgs.length) {
|
|
bitmask &= ~16;
|
|
isPartial = partialArgs = false;
|
|
}
|
|
if (isPartialRight && !partialRightArgs.length) {
|
|
bitmask &= ~32;
|
|
isPartialRight = partialRightArgs = false;
|
|
}
|
|
var bindData = func && func.__bindData__;
|
|
if (bindData && bindData !== true) {
|
|
// clone `bindData`
|
|
bindData = slice(bindData);
|
|
if (bindData[2]) {
|
|
bindData[2] = slice(bindData[2]);
|
|
}
|
|
if (bindData[3]) {
|
|
bindData[3] = slice(bindData[3]);
|
|
}
|
|
// set `thisBinding` is not previously bound
|
|
if (isBind && !(bindData[1] & 1)) {
|
|
bindData[4] = thisArg;
|
|
}
|
|
// set if previously bound but not currently (subsequent curried functions)
|
|
if (!isBind && bindData[1] & 1) {
|
|
bitmask |= 8;
|
|
}
|
|
// set curried arity if not yet set
|
|
if (isCurry && !(bindData[1] & 4)) {
|
|
bindData[5] = arity;
|
|
}
|
|
// append partial left arguments
|
|
if (isPartial) {
|
|
push.apply(bindData[2] || (bindData[2] = []), partialArgs);
|
|
}
|
|
// append partial right arguments
|
|
if (isPartialRight) {
|
|
unshift.apply(bindData[3] || (bindData[3] = []), partialRightArgs);
|
|
}
|
|
// merge flags
|
|
bindData[1] |= bitmask;
|
|
return createWrapper.apply(null, bindData);
|
|
}
|
|
// fast path for `_.bind`
|
|
var creater = (bitmask == 1 || bitmask === 17) ? baseBind : baseCreateWrapper;
|
|
return creater([func, bitmask, partialArgs, partialRightArgs, thisArg, arity]);
|
|
}
|
|
|
|
/**
|
|
* Used by `escape` to convert characters to HTML entities.
|
|
*
|
|
* @private
|
|
* @param {string} match The matched character to escape.
|
|
* @returns {string} Returns the escaped character.
|
|
*/
|
|
function escapeHtmlChar(match) {
|
|
return htmlEscapes[match];
|
|
}
|
|
|
|
/**
|
|
* Gets the appropriate "indexOf" function. If the `_.indexOf` method is
|
|
* customized, this method returns the custom method, otherwise it returns
|
|
* the `baseIndexOf` function.
|
|
*
|
|
* @private
|
|
* @returns {Function} Returns the "indexOf" function.
|
|
*/
|
|
function getIndexOf() {
|
|
var result = (result = lodash.indexOf) === indexOf ? baseIndexOf : result;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a native function.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a native function, else `false`.
|
|
*/
|
|
function isNative(value) {
|
|
return typeof value == 'function' && reNative.test(value);
|
|
}
|
|
|
|
/**
|
|
* Sets `this` binding data on a given function.
|
|
*
|
|
* @private
|
|
* @param {Function} func The function to set data on.
|
|
* @param {Array} value The data array to set.
|
|
*/
|
|
var setBindData = !defineProperty ? noop : function(func, value) {
|
|
descriptor.value = value;
|
|
defineProperty(func, '__bindData__', descriptor);
|
|
descriptor.value = null;
|
|
};
|
|
|
|
/**
|
|
* A fallback implementation of `isPlainObject` which checks if a given value
|
|
* is an object created by the `Object` constructor, assuming objects created
|
|
* by the `Object` constructor have no inherited enumerable properties and that
|
|
* there are no `Object.prototype` extensions.
|
|
*
|
|
* @private
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
*/
|
|
function shimIsPlainObject(value) {
|
|
var ctor,
|
|
result;
|
|
|
|
// avoid non Object objects, `arguments` objects, and DOM elements
|
|
if (!(value && toString.call(value) == objectClass) ||
|
|
(ctor = value.constructor, isFunction(ctor) && !(ctor instanceof ctor))) {
|
|
return false;
|
|
}
|
|
// In most environments an object's own properties are iterated before
|
|
// its inherited properties. If the last iterated property is an object's
|
|
// own property then there are no inherited enumerable properties.
|
|
forIn(value, function(value, key) {
|
|
result = key;
|
|
});
|
|
return typeof result == 'undefined' || hasOwnProperty.call(value, result);
|
|
}
|
|
|
|
/**
|
|
* Used by `unescape` to convert HTML entities to characters.
|
|
*
|
|
* @private
|
|
* @param {string} match The matched character to unescape.
|
|
* @returns {string} Returns the unescaped character.
|
|
*/
|
|
function unescapeHtmlChar(match) {
|
|
return htmlUnescapes[match];
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Checks if `value` is an `arguments` object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is an `arguments` object, else `false`.
|
|
* @example
|
|
*
|
|
* (function() { return _.isArguments(arguments); })(1, 2, 3);
|
|
* // => true
|
|
*
|
|
* _.isArguments([1, 2, 3]);
|
|
* // => false
|
|
*/
|
|
function isArguments(value) {
|
|
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
|
toString.call(value) == argsClass || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is an array.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is an array, else `false`.
|
|
* @example
|
|
*
|
|
* (function() { return _.isArray(arguments); })();
|
|
* // => false
|
|
*
|
|
* _.isArray([1, 2, 3]);
|
|
* // => true
|
|
*/
|
|
var isArray = nativeIsArray || function(value) {
|
|
return value && typeof value == 'object' && typeof value.length == 'number' &&
|
|
toString.call(value) == arrayClass || false;
|
|
};
|
|
|
|
/**
|
|
* A fallback implementation of `Object.keys` which produces an array of the
|
|
* given object's own enumerable property names.
|
|
*
|
|
* @private
|
|
* @type Function
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns an array of property names.
|
|
*/
|
|
var shimKeys = function(object) {
|
|
var index, iterable = object, result = [];
|
|
if (!iterable) return result;
|
|
if (!(objectTypes[typeof object])) return result;
|
|
for (index in iterable) {
|
|
if (hasOwnProperty.call(iterable, index)) {
|
|
result.push(index);
|
|
}
|
|
}
|
|
return result
|
|
};
|
|
|
|
/**
|
|
* Creates an array composed of the own enumerable property names of an object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns an array of property names.
|
|
* @example
|
|
*
|
|
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
|
|
* // => ['one', 'two', 'three'] (property order is not guaranteed across environments)
|
|
*/
|
|
var keys = !nativeKeys ? shimKeys : function(object) {
|
|
if (!isObject(object)) {
|
|
return [];
|
|
}
|
|
return nativeKeys(object);
|
|
};
|
|
|
|
/**
|
|
* Used to convert characters to HTML entities:
|
|
*
|
|
* Though the `>` character is escaped for symmetry, characters like `>` and `/`
|
|
* don't require escaping in HTML and have no special meaning unless they're part
|
|
* of a tag or an unquoted attribute value.
|
|
* http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
|
|
*/
|
|
var htmlEscapes = {
|
|
'&': '&',
|
|
'<': '<',
|
|
'>': '>',
|
|
'"': '"',
|
|
"'": '''
|
|
};
|
|
|
|
/** Used to convert HTML entities to characters */
|
|
var htmlUnescapes = invert(htmlEscapes);
|
|
|
|
/** Used to match HTML entities and HTML characters */
|
|
var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'),
|
|
reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g');
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Assigns own enumerable properties of source object(s) to the destination
|
|
* object. Subsequent sources will overwrite property assignments of previous
|
|
* sources. If a callback is provided it will be executed to produce the
|
|
* assigned values. The callback is bound to `thisArg` and invoked with two
|
|
* arguments; (objectValue, sourceValue).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @alias extend
|
|
* @category Objects
|
|
* @param {Object} object The destination object.
|
|
* @param {...Object} [source] The source objects.
|
|
* @param {Function} [callback] The function to customize assigning values.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns the destination object.
|
|
* @example
|
|
*
|
|
* _.assign({ 'name': 'fred' }, { 'employer': 'slate' });
|
|
* // => { 'name': 'fred', 'employer': 'slate' }
|
|
*
|
|
* var defaults = _.partialRight(_.assign, function(a, b) {
|
|
* return typeof a == 'undefined' ? b : a;
|
|
* });
|
|
*
|
|
* var object = { 'name': 'barney' };
|
|
* defaults(object, { 'name': 'fred', 'employer': 'slate' });
|
|
* // => { 'name': 'barney', 'employer': 'slate' }
|
|
*/
|
|
var assign = function(object, source, guard) {
|
|
var index, iterable = object, result = iterable;
|
|
if (!iterable) return result;
|
|
var args = arguments,
|
|
argsIndex = 0,
|
|
argsLength = typeof guard == 'number' ? 2 : args.length;
|
|
if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {
|
|
var callback = baseCreateCallback(args[--argsLength - 1], args[argsLength--], 2);
|
|
} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {
|
|
callback = args[--argsLength];
|
|
}
|
|
while (++argsIndex < argsLength) {
|
|
iterable = args[argsIndex];
|
|
if (iterable && objectTypes[typeof iterable]) {
|
|
var ownIndex = -1,
|
|
ownProps = objectTypes[typeof iterable] && keys(iterable),
|
|
length = ownProps ? ownProps.length : 0;
|
|
|
|
while (++ownIndex < length) {
|
|
index = ownProps[ownIndex];
|
|
result[index] = callback ? callback(result[index], iterable[index]) : iterable[index];
|
|
}
|
|
}
|
|
}
|
|
return result
|
|
};
|
|
|
|
/**
|
|
* Creates a clone of `value`. If `isDeep` is `true` nested objects will also
|
|
* be cloned, otherwise they will be assigned by reference. If a callback
|
|
* is provided it will be executed to produce the cloned values. If the
|
|
* callback returns `undefined` cloning will be handled by the method instead.
|
|
* The callback is bound to `thisArg` and invoked with one argument; (value).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to clone.
|
|
* @param {boolean} [isDeep=false] Specify a deep clone.
|
|
* @param {Function} [callback] The function to customize cloning values.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the cloned value.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* var shallow = _.clone(characters);
|
|
* shallow[0] === characters[0];
|
|
* // => true
|
|
*
|
|
* var deep = _.clone(characters, true);
|
|
* deep[0] === characters[0];
|
|
* // => false
|
|
*
|
|
* _.mixin({
|
|
* 'clone': _.partialRight(_.clone, function(value) {
|
|
* return _.isElement(value) ? value.cloneNode(false) : undefined;
|
|
* })
|
|
* });
|
|
*
|
|
* var clone = _.clone(document.body);
|
|
* clone.childNodes.length;
|
|
* // => 0
|
|
*/
|
|
function clone(value, isDeep, callback, thisArg) {
|
|
// allows working with "Collections" methods without using their `index`
|
|
// and `collection` arguments for `isDeep` and `callback`
|
|
if (typeof isDeep != 'boolean' && isDeep != null) {
|
|
thisArg = callback;
|
|
callback = isDeep;
|
|
isDeep = false;
|
|
}
|
|
return baseClone(value, isDeep, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1));
|
|
}
|
|
|
|
/**
|
|
* Creates a deep clone of `value`. If a callback is provided it will be
|
|
* executed to produce the cloned values. If the callback returns `undefined`
|
|
* cloning will be handled by the method instead. The callback is bound to
|
|
* `thisArg` and invoked with one argument; (value).
|
|
*
|
|
* Note: This method is loosely based on the structured clone algorithm. Functions
|
|
* and DOM nodes are **not** cloned. The enumerable properties of `arguments` objects and
|
|
* objects created by constructors other than `Object` are cloned to plain `Object` objects.
|
|
* See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to deep clone.
|
|
* @param {Function} [callback] The function to customize cloning values.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the deep cloned value.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* var deep = _.cloneDeep(characters);
|
|
* deep[0] === characters[0];
|
|
* // => false
|
|
*
|
|
* var view = {
|
|
* 'label': 'docs',
|
|
* 'node': element
|
|
* };
|
|
*
|
|
* var clone = _.cloneDeep(view, function(value) {
|
|
* return _.isElement(value) ? value.cloneNode(true) : undefined;
|
|
* });
|
|
*
|
|
* clone.node == view.node;
|
|
* // => false
|
|
*/
|
|
function cloneDeep(value, callback, thisArg) {
|
|
return baseClone(value, true, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 1));
|
|
}
|
|
|
|
/**
|
|
* Creates an object that inherits from the given `prototype` object. If a
|
|
* `properties` object is provided its own enumerable properties are assigned
|
|
* to the created object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} prototype The object to inherit from.
|
|
* @param {Object} [properties] The properties to assign to the object.
|
|
* @returns {Object} Returns the new object.
|
|
* @example
|
|
*
|
|
* function Shape() {
|
|
* this.x = 0;
|
|
* this.y = 0;
|
|
* }
|
|
*
|
|
* function Circle() {
|
|
* Shape.call(this);
|
|
* }
|
|
*
|
|
* Circle.prototype = _.create(Shape.prototype, { 'constructor': Circle });
|
|
*
|
|
* var circle = new Circle;
|
|
* circle instanceof Circle;
|
|
* // => true
|
|
*
|
|
* circle instanceof Shape;
|
|
* // => true
|
|
*/
|
|
function create(prototype, properties) {
|
|
var result = baseCreate(prototype);
|
|
return properties ? assign(result, properties) : result;
|
|
}
|
|
|
|
/**
|
|
* Assigns own enumerable properties of source object(s) to the destination
|
|
* object for all destination properties that resolve to `undefined`. Once a
|
|
* property is set, additional defaults of the same property will be ignored.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @category Objects
|
|
* @param {Object} object The destination object.
|
|
* @param {...Object} [source] The source objects.
|
|
* @param- {Object} [guard] Allows working with `_.reduce` without using its
|
|
* `key` and `object` arguments as sources.
|
|
* @returns {Object} Returns the destination object.
|
|
* @example
|
|
*
|
|
* var object = { 'name': 'barney' };
|
|
* _.defaults(object, { 'name': 'fred', 'employer': 'slate' });
|
|
* // => { 'name': 'barney', 'employer': 'slate' }
|
|
*/
|
|
var defaults = function(object, source, guard) {
|
|
var index, iterable = object, result = iterable;
|
|
if (!iterable) return result;
|
|
var args = arguments,
|
|
argsIndex = 0,
|
|
argsLength = typeof guard == 'number' ? 2 : args.length;
|
|
while (++argsIndex < argsLength) {
|
|
iterable = args[argsIndex];
|
|
if (iterable && objectTypes[typeof iterable]) {
|
|
var ownIndex = -1,
|
|
ownProps = objectTypes[typeof iterable] && keys(iterable),
|
|
length = ownProps ? ownProps.length : 0;
|
|
|
|
while (++ownIndex < length) {
|
|
index = ownProps[ownIndex];
|
|
if (typeof result[index] == 'undefined') result[index] = iterable[index];
|
|
}
|
|
}
|
|
}
|
|
return result
|
|
};
|
|
|
|
/**
|
|
* This method is like `_.findIndex` except that it returns the key of the
|
|
* first element that passes the callback check, instead of the element itself.
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to search.
|
|
* @param {Function|Object|string} [callback=identity] The function called per
|
|
* iteration. If a property name or object is provided it will be used to
|
|
* create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {string|undefined} Returns the key of the found element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var characters = {
|
|
* 'barney': { 'age': 36, 'blocked': false },
|
|
* 'fred': { 'age': 40, 'blocked': true },
|
|
* 'pebbles': { 'age': 1, 'blocked': false }
|
|
* };
|
|
*
|
|
* _.findKey(characters, function(chr) {
|
|
* return chr.age < 40;
|
|
* });
|
|
* // => 'barney' (property order is not guaranteed across environments)
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.findKey(characters, { 'age': 1 });
|
|
* // => 'pebbles'
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.findKey(characters, 'blocked');
|
|
* // => 'fred'
|
|
*/
|
|
function findKey(object, callback, thisArg) {
|
|
var result;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
forOwn(object, function(value, key, object) {
|
|
if (callback(value, key, object)) {
|
|
result = key;
|
|
return false;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.findKey` except that it iterates over elements
|
|
* of a `collection` in the opposite order.
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to search.
|
|
* @param {Function|Object|string} [callback=identity] The function called per
|
|
* iteration. If a property name or object is provided it will be used to
|
|
* create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {string|undefined} Returns the key of the found element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var characters = {
|
|
* 'barney': { 'age': 36, 'blocked': true },
|
|
* 'fred': { 'age': 40, 'blocked': false },
|
|
* 'pebbles': { 'age': 1, 'blocked': true }
|
|
* };
|
|
*
|
|
* _.findLastKey(characters, function(chr) {
|
|
* return chr.age < 40;
|
|
* });
|
|
* // => returns `pebbles`, assuming `_.findKey` returns `barney`
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.findLastKey(characters, { 'age': 40 });
|
|
* // => 'fred'
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.findLastKey(characters, 'blocked');
|
|
* // => 'pebbles'
|
|
*/
|
|
function findLastKey(object, callback, thisArg) {
|
|
var result;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
forOwnRight(object, function(value, key, object) {
|
|
if (callback(value, key, object)) {
|
|
result = key;
|
|
return false;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Iterates over own and inherited enumerable properties of an object,
|
|
* executing the callback for each property. The callback is bound to `thisArg`
|
|
* and invoked with three arguments; (value, key, object). Callbacks may exit
|
|
* iteration early by explicitly returning `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @category Objects
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function Shape() {
|
|
* this.x = 0;
|
|
* this.y = 0;
|
|
* }
|
|
*
|
|
* Shape.prototype.move = function(x, y) {
|
|
* this.x += x;
|
|
* this.y += y;
|
|
* };
|
|
*
|
|
* _.forIn(new Shape, function(value, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'x', 'y', and 'move' (property order is not guaranteed across environments)
|
|
*/
|
|
var forIn = function(collection, callback, thisArg) {
|
|
var index, iterable = collection, result = iterable;
|
|
if (!iterable) return result;
|
|
if (!objectTypes[typeof iterable]) return result;
|
|
callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
|
|
for (index in iterable) {
|
|
if (callback(iterable[index], index, collection) === false) return result;
|
|
}
|
|
return result
|
|
};
|
|
|
|
/**
|
|
* This method is like `_.forIn` except that it iterates over elements
|
|
* of a `collection` in the opposite order.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* function Shape() {
|
|
* this.x = 0;
|
|
* this.y = 0;
|
|
* }
|
|
*
|
|
* Shape.prototype.move = function(x, y) {
|
|
* this.x += x;
|
|
* this.y += y;
|
|
* };
|
|
*
|
|
* _.forInRight(new Shape, function(value, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'move', 'y', and 'x' assuming `_.forIn ` logs 'x', 'y', and 'move'
|
|
*/
|
|
function forInRight(object, callback, thisArg) {
|
|
var pairs = [];
|
|
|
|
forIn(object, function(value, key) {
|
|
pairs.push(key, value);
|
|
});
|
|
|
|
var length = pairs.length;
|
|
callback = baseCreateCallback(callback, thisArg, 3);
|
|
while (length--) {
|
|
if (callback(pairs[length--], pairs[length], object) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* Iterates over own enumerable properties of an object, executing the callback
|
|
* for each property. The callback is bound to `thisArg` and invoked with three
|
|
* arguments; (value, key, object). Callbacks may exit iteration early by
|
|
* explicitly returning `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @category Objects
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs '0', '1', and 'length' (property order is not guaranteed across environments)
|
|
*/
|
|
var forOwn = function(collection, callback, thisArg) {
|
|
var index, iterable = collection, result = iterable;
|
|
if (!iterable) return result;
|
|
if (!objectTypes[typeof iterable]) return result;
|
|
callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
|
|
var ownIndex = -1,
|
|
ownProps = objectTypes[typeof iterable] && keys(iterable),
|
|
length = ownProps ? ownProps.length : 0;
|
|
|
|
while (++ownIndex < length) {
|
|
index = ownProps[ownIndex];
|
|
if (callback(iterable[index], index, collection) === false) return result;
|
|
}
|
|
return result
|
|
};
|
|
|
|
/**
|
|
* This method is like `_.forOwn` except that it iterates over elements
|
|
* of a `collection` in the opposite order.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) {
|
|
* console.log(key);
|
|
* });
|
|
* // => logs 'length', '1', and '0' assuming `_.forOwn` logs '0', '1', and 'length'
|
|
*/
|
|
function forOwnRight(object, callback, thisArg) {
|
|
var props = keys(object),
|
|
length = props.length;
|
|
|
|
callback = baseCreateCallback(callback, thisArg, 3);
|
|
while (length--) {
|
|
var key = props[length];
|
|
if (callback(object[key], key, object) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* Creates a sorted array of property names of all enumerable properties,
|
|
* own and inherited, of `object` that have function values.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias methods
|
|
* @category Objects
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns an array of property names that have function values.
|
|
* @example
|
|
*
|
|
* _.functions(_);
|
|
* // => ['all', 'any', 'bind', 'bindAll', 'clone', 'compact', 'compose', ...]
|
|
*/
|
|
function functions(object) {
|
|
var result = [];
|
|
forIn(object, function(value, key) {
|
|
if (isFunction(value)) {
|
|
result.push(key);
|
|
}
|
|
});
|
|
return result.sort();
|
|
}
|
|
|
|
/**
|
|
* Checks if the specified property name exists as a direct property of `object`,
|
|
* instead of an inherited property.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to inspect.
|
|
* @param {string} key The name of the property to check.
|
|
* @returns {boolean} Returns `true` if key is a direct property, else `false`.
|
|
* @example
|
|
*
|
|
* _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b');
|
|
* // => true
|
|
*/
|
|
function has(object, key) {
|
|
return object ? hasOwnProperty.call(object, key) : false;
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of the inverted keys and values of the given object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to invert.
|
|
* @returns {Object} Returns the created inverted object.
|
|
* @example
|
|
*
|
|
* _.invert({ 'first': 'fred', 'second': 'barney' });
|
|
* // => { 'fred': 'first', 'barney': 'second' }
|
|
*/
|
|
function invert(object) {
|
|
var index = -1,
|
|
props = keys(object),
|
|
length = props.length,
|
|
result = {};
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
result[object[key]] = key;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a boolean value.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a boolean value, else `false`.
|
|
* @example
|
|
*
|
|
* _.isBoolean(null);
|
|
* // => false
|
|
*/
|
|
function isBoolean(value) {
|
|
return value === true || value === false ||
|
|
value && typeof value == 'object' && toString.call(value) == boolClass || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a date.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a date, else `false`.
|
|
* @example
|
|
*
|
|
* _.isDate(new Date);
|
|
* // => true
|
|
*/
|
|
function isDate(value) {
|
|
return value && typeof value == 'object' && toString.call(value) == dateClass || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a DOM element.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a DOM element, else `false`.
|
|
* @example
|
|
*
|
|
* _.isElement(document.body);
|
|
* // => true
|
|
*/
|
|
function isElement(value) {
|
|
return value && value.nodeType === 1 || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is empty. Arrays, strings, or `arguments` objects with a
|
|
* length of `0` and objects with no own enumerable properties are considered
|
|
* "empty".
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Array|Object|string} value The value to inspect.
|
|
* @returns {boolean} Returns `true` if the `value` is empty, else `false`.
|
|
* @example
|
|
*
|
|
* _.isEmpty([1, 2, 3]);
|
|
* // => false
|
|
*
|
|
* _.isEmpty({});
|
|
* // => true
|
|
*
|
|
* _.isEmpty('');
|
|
* // => true
|
|
*/
|
|
function isEmpty(value) {
|
|
var result = true;
|
|
if (!value) {
|
|
return result;
|
|
}
|
|
var className = toString.call(value),
|
|
length = value.length;
|
|
|
|
if ((className == arrayClass || className == stringClass || className == argsClass ) ||
|
|
(className == objectClass && typeof length == 'number' && isFunction(value.splice))) {
|
|
return !length;
|
|
}
|
|
forOwn(value, function() {
|
|
return (result = false);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Performs a deep comparison between two values to determine if they are
|
|
* equivalent to each other. If a callback is provided it will be executed
|
|
* to compare values. If the callback returns `undefined` comparisons will
|
|
* be handled by the method instead. The callback is bound to `thisArg` and
|
|
* invoked with two arguments; (a, b).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} a The value to compare.
|
|
* @param {*} b The other value to compare.
|
|
* @param {Function} [callback] The function to customize comparing values.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
* @example
|
|
*
|
|
* var object = { 'name': 'fred' };
|
|
* var copy = { 'name': 'fred' };
|
|
*
|
|
* object == copy;
|
|
* // => false
|
|
*
|
|
* _.isEqual(object, copy);
|
|
* // => true
|
|
*
|
|
* var words = ['hello', 'goodbye'];
|
|
* var otherWords = ['hi', 'goodbye'];
|
|
*
|
|
* _.isEqual(words, otherWords, function(a, b) {
|
|
* var reGreet = /^(?:hello|hi)$/i,
|
|
* aGreet = _.isString(a) && reGreet.test(a),
|
|
* bGreet = _.isString(b) && reGreet.test(b);
|
|
*
|
|
* return (aGreet || bGreet) ? (aGreet == bGreet) : undefined;
|
|
* });
|
|
* // => true
|
|
*/
|
|
function isEqual(a, b, callback, thisArg) {
|
|
return baseIsEqual(a, b, typeof callback == 'function' && baseCreateCallback(callback, thisArg, 2));
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is, or can be coerced to, a finite number.
|
|
*
|
|
* Note: This is not the same as native `isFinite` which will return true for
|
|
* booleans and empty strings. See http://es5.github.io/#x15.1.2.5.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is finite, else `false`.
|
|
* @example
|
|
*
|
|
* _.isFinite(-101);
|
|
* // => true
|
|
*
|
|
* _.isFinite('10');
|
|
* // => true
|
|
*
|
|
* _.isFinite(true);
|
|
* // => false
|
|
*
|
|
* _.isFinite('');
|
|
* // => false
|
|
*
|
|
* _.isFinite(Infinity);
|
|
* // => false
|
|
*/
|
|
function isFinite(value) {
|
|
return nativeIsFinite(value) && !nativeIsNaN(parseFloat(value));
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a function, else `false`.
|
|
* @example
|
|
*
|
|
* _.isFunction(_);
|
|
* // => true
|
|
*/
|
|
function isFunction(value) {
|
|
return typeof value == 'function';
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is the language type of Object.
|
|
* (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is an object, else `false`.
|
|
* @example
|
|
*
|
|
* _.isObject({});
|
|
* // => true
|
|
*
|
|
* _.isObject([1, 2, 3]);
|
|
* // => true
|
|
*
|
|
* _.isObject(1);
|
|
* // => false
|
|
*/
|
|
function isObject(value) {
|
|
// check if the value is the ECMAScript language type of Object
|
|
// http://es5.github.io/#x8
|
|
// and avoid a V8 bug
|
|
// http://code.google.com/p/v8/issues/detail?id=2291
|
|
return !!(value && objectTypes[typeof value]);
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is `NaN`.
|
|
*
|
|
* Note: This is not the same as native `isNaN` which will return `true` for
|
|
* `undefined` and other non-numeric values. See http://es5.github.io/#x15.1.2.4.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is `NaN`, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNaN(NaN);
|
|
* // => true
|
|
*
|
|
* _.isNaN(new Number(NaN));
|
|
* // => true
|
|
*
|
|
* isNaN(undefined);
|
|
* // => true
|
|
*
|
|
* _.isNaN(undefined);
|
|
* // => false
|
|
*/
|
|
function isNaN(value) {
|
|
// `NaN` as a primitive is the only value that is not equal to itself
|
|
// (perform the [[Class]] check first to avoid errors with some host objects in IE)
|
|
return isNumber(value) && value != +value;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is `null`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is `null`, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNull(null);
|
|
* // => true
|
|
*
|
|
* _.isNull(undefined);
|
|
* // => false
|
|
*/
|
|
function isNull(value) {
|
|
return value === null;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a number.
|
|
*
|
|
* Note: `NaN` is considered a number. See http://es5.github.io/#x8.5.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a number, else `false`.
|
|
* @example
|
|
*
|
|
* _.isNumber(8.4 * 5);
|
|
* // => true
|
|
*/
|
|
function isNumber(value) {
|
|
return typeof value == 'number' ||
|
|
value && typeof value == 'object' && toString.call(value) == numberClass || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is an object created by the `Object` constructor.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
|
|
* @example
|
|
*
|
|
* function Shape() {
|
|
* this.x = 0;
|
|
* this.y = 0;
|
|
* }
|
|
*
|
|
* _.isPlainObject(new Shape);
|
|
* // => false
|
|
*
|
|
* _.isPlainObject([1, 2, 3]);
|
|
* // => false
|
|
*
|
|
* _.isPlainObject({ 'x': 0, 'y': 0 });
|
|
* // => true
|
|
*/
|
|
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) {
|
|
if (!(value && toString.call(value) == objectClass)) {
|
|
return false;
|
|
}
|
|
var valueOf = value.valueOf,
|
|
objProto = isNative(valueOf) && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto);
|
|
|
|
return objProto
|
|
? (value == objProto || getPrototypeOf(value) == objProto)
|
|
: shimIsPlainObject(value);
|
|
};
|
|
|
|
/**
|
|
* Checks if `value` is a regular expression.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a regular expression, else `false`.
|
|
* @example
|
|
*
|
|
* _.isRegExp(/fred/);
|
|
* // => true
|
|
*/
|
|
function isRegExp(value) {
|
|
return value && typeof value == 'object' && toString.call(value) == regexpClass || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is a string.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is a string, else `false`.
|
|
* @example
|
|
*
|
|
* _.isString('fred');
|
|
* // => true
|
|
*/
|
|
function isString(value) {
|
|
return typeof value == 'string' ||
|
|
value && typeof value == 'object' && toString.call(value) == stringClass || false;
|
|
}
|
|
|
|
/**
|
|
* Checks if `value` is `undefined`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {*} value The value to check.
|
|
* @returns {boolean} Returns `true` if the `value` is `undefined`, else `false`.
|
|
* @example
|
|
*
|
|
* _.isUndefined(void 0);
|
|
* // => true
|
|
*/
|
|
function isUndefined(value) {
|
|
return typeof value == 'undefined';
|
|
}
|
|
|
|
/**
|
|
* Creates an object with the same keys as `object` and values generated by
|
|
* running each own enumerable property of `object` through the callback.
|
|
* The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, key, object).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new object with values of the results of each `callback` execution.
|
|
* @example
|
|
*
|
|
* _.mapValues({ 'a': 1, 'b': 2, 'c': 3} , function(num) { return num * 3; });
|
|
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
|
*
|
|
* var characters = {
|
|
* 'fred': { 'name': 'fred', 'age': 40 },
|
|
* 'pebbles': { 'name': 'pebbles', 'age': 1 }
|
|
* };
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.mapValues(characters, 'age');
|
|
* // => { 'fred': 40, 'pebbles': 1 }
|
|
*/
|
|
function mapValues(object, callback, thisArg) {
|
|
var result = {};
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
|
|
forOwn(object, function(value, key, object) {
|
|
result[key] = callback(value, key, object);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Recursively merges own enumerable properties of the source object(s), that
|
|
* don't resolve to `undefined` into the destination object. Subsequent sources
|
|
* will overwrite property assignments of previous sources. If a callback is
|
|
* provided it will be executed to produce the merged values of the destination
|
|
* and source properties. If the callback returns `undefined` merging will
|
|
* be handled by the method instead. The callback is bound to `thisArg` and
|
|
* invoked with two arguments; (objectValue, sourceValue).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The destination object.
|
|
* @param {...Object} [source] The source objects.
|
|
* @param {Function} [callback] The function to customize merging properties.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns the destination object.
|
|
* @example
|
|
*
|
|
* var names = {
|
|
* 'characters': [
|
|
* { 'name': 'barney' },
|
|
* { 'name': 'fred' }
|
|
* ]
|
|
* };
|
|
*
|
|
* var ages = {
|
|
* 'characters': [
|
|
* { 'age': 36 },
|
|
* { 'age': 40 }
|
|
* ]
|
|
* };
|
|
*
|
|
* _.merge(names, ages);
|
|
* // => { 'characters': [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }] }
|
|
*
|
|
* var food = {
|
|
* 'fruits': ['apple'],
|
|
* 'vegetables': ['beet']
|
|
* };
|
|
*
|
|
* var otherFood = {
|
|
* 'fruits': ['banana'],
|
|
* 'vegetables': ['carrot']
|
|
* };
|
|
*
|
|
* _.merge(food, otherFood, function(a, b) {
|
|
* return _.isArray(a) ? a.concat(b) : undefined;
|
|
* });
|
|
* // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot] }
|
|
*/
|
|
function merge(object) {
|
|
var args = arguments,
|
|
length = 2;
|
|
|
|
if (!isObject(object)) {
|
|
return object;
|
|
}
|
|
// allows working with `_.reduce` and `_.reduceRight` without using
|
|
// their `index` and `collection` arguments
|
|
if (typeof args[2] != 'number') {
|
|
length = args.length;
|
|
}
|
|
if (length > 3 && typeof args[length - 2] == 'function') {
|
|
var callback = baseCreateCallback(args[--length - 1], args[length--], 2);
|
|
} else if (length > 2 && typeof args[length - 1] == 'function') {
|
|
callback = args[--length];
|
|
}
|
|
var sources = slice(arguments, 1, length),
|
|
index = -1,
|
|
stackA = getArray(),
|
|
stackB = getArray();
|
|
|
|
while (++index < length) {
|
|
baseMerge(object, sources[index], callback, stackA, stackB);
|
|
}
|
|
releaseArray(stackA);
|
|
releaseArray(stackB);
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* Creates a shallow clone of `object` excluding the specified properties.
|
|
* Property names may be specified as individual arguments or as arrays of
|
|
* property names. If a callback is provided it will be executed for each
|
|
* property of `object` omitting the properties the callback returns truey
|
|
* for. The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, key, object).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The source object.
|
|
* @param {Function|...string|string[]} [callback] The properties to omit or the
|
|
* function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns an object without the omitted properties.
|
|
* @example
|
|
*
|
|
* _.omit({ 'name': 'fred', 'age': 40 }, 'age');
|
|
* // => { 'name': 'fred' }
|
|
*
|
|
* _.omit({ 'name': 'fred', 'age': 40 }, function(value) {
|
|
* return typeof value == 'number';
|
|
* });
|
|
* // => { 'name': 'fred' }
|
|
*/
|
|
function omit(object, callback, thisArg) {
|
|
var result = {};
|
|
if (typeof callback != 'function') {
|
|
var props = [];
|
|
forIn(object, function(value, key) {
|
|
props.push(key);
|
|
});
|
|
props = baseDifference(props, baseFlatten(arguments, true, false, 1));
|
|
|
|
var index = -1,
|
|
length = props.length;
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
result[key] = object[key];
|
|
}
|
|
} else {
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
forIn(object, function(value, key, object) {
|
|
if (!callback(value, key, object)) {
|
|
result[key] = value;
|
|
}
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a two dimensional array of an object's key-value pairs,
|
|
* i.e. `[[key1, value1], [key2, value2]]`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns new array of key-value pairs.
|
|
* @example
|
|
*
|
|
* _.pairs({ 'barney': 36, 'fred': 40 });
|
|
* // => [['barney', 36], ['fred', 40]] (property order is not guaranteed across environments)
|
|
*/
|
|
function pairs(object) {
|
|
var index = -1,
|
|
props = keys(object),
|
|
length = props.length,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
result[index] = [key, object[key]];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates a shallow clone of `object` composed of the specified properties.
|
|
* Property names may be specified as individual arguments or as arrays of
|
|
* property names. If a callback is provided it will be executed for each
|
|
* property of `object` picking the properties the callback returns truey
|
|
* for. The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, key, object).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The source object.
|
|
* @param {Function|...string|string[]} [callback] The function called per
|
|
* iteration or property names to pick, specified as individual property
|
|
* names or arrays of property names.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns an object composed of the picked properties.
|
|
* @example
|
|
*
|
|
* _.pick({ 'name': 'fred', '_userid': 'fred1' }, 'name');
|
|
* // => { 'name': 'fred' }
|
|
*
|
|
* _.pick({ 'name': 'fred', '_userid': 'fred1' }, function(value, key) {
|
|
* return key.charAt(0) != '_';
|
|
* });
|
|
* // => { 'name': 'fred' }
|
|
*/
|
|
function pick(object, callback, thisArg) {
|
|
var result = {};
|
|
if (typeof callback != 'function') {
|
|
var index = -1,
|
|
props = baseFlatten(arguments, true, false, 1),
|
|
length = isObject(object) ? props.length : 0;
|
|
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
if (key in object) {
|
|
result[key] = object[key];
|
|
}
|
|
}
|
|
} else {
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
forIn(object, function(value, key, object) {
|
|
if (callback(value, key, object)) {
|
|
result[key] = value;
|
|
}
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* An alternative to `_.reduce` this method transforms `object` to a new
|
|
* `accumulator` object which is the result of running each of its own
|
|
* enumerable properties through a callback, with each callback execution
|
|
* potentially mutating the `accumulator` object. The callback is bound to
|
|
* `thisArg` and invoked with four arguments; (accumulator, value, key, object).
|
|
* Callbacks may exit iteration early by explicitly returning `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Array|Object} object The object to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [accumulator] The custom accumulator value.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the accumulated value.
|
|
* @example
|
|
*
|
|
* var squares = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(result, num) {
|
|
* num *= num;
|
|
* if (num % 2) {
|
|
* return result.push(num) < 3;
|
|
* }
|
|
* });
|
|
* // => [1, 9, 25]
|
|
*
|
|
* var mapped = _.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
|
* result[key] = num * 3;
|
|
* });
|
|
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
|
*/
|
|
function transform(object, callback, accumulator, thisArg) {
|
|
var isArr = isArray(object);
|
|
if (accumulator == null) {
|
|
if (isArr) {
|
|
accumulator = [];
|
|
} else {
|
|
var ctor = object && object.constructor,
|
|
proto = ctor && ctor.prototype;
|
|
|
|
accumulator = baseCreate(proto);
|
|
}
|
|
}
|
|
if (callback) {
|
|
callback = lodash.createCallback(callback, thisArg, 4);
|
|
(isArr ? forEach : forOwn)(object, function(value, index, object) {
|
|
return callback(accumulator, value, index, object);
|
|
});
|
|
}
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* Creates an array composed of the own enumerable property values of `object`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Objects
|
|
* @param {Object} object The object to inspect.
|
|
* @returns {Array} Returns an array of property values.
|
|
* @example
|
|
*
|
|
* _.values({ 'one': 1, 'two': 2, 'three': 3 });
|
|
* // => [1, 2, 3] (property order is not guaranteed across environments)
|
|
*/
|
|
function values(object) {
|
|
var index = -1,
|
|
props = keys(object),
|
|
length = props.length,
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
result[index] = object[props[index]];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates an array of elements from the specified indexes, or keys, of the
|
|
* `collection`. Indexes may be specified as individual arguments or as arrays
|
|
* of indexes.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {...(number|number[]|string|string[])} [index] The indexes of `collection`
|
|
* to retrieve, specified as individual indexes or arrays of indexes.
|
|
* @returns {Array} Returns a new array of elements corresponding to the
|
|
* provided indexes.
|
|
* @example
|
|
*
|
|
* _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]);
|
|
* // => ['a', 'c', 'e']
|
|
*
|
|
* _.at(['fred', 'barney', 'pebbles'], 0, 2);
|
|
* // => ['fred', 'pebbles']
|
|
*/
|
|
function at(collection) {
|
|
var args = arguments,
|
|
index = -1,
|
|
props = baseFlatten(args, true, false, 1),
|
|
length = (args[2] && args[2][args[1]] === collection) ? 1 : props.length,
|
|
result = Array(length);
|
|
|
|
while(++index < length) {
|
|
result[index] = collection[props[index]];
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Checks if a given value is present in a collection using strict equality
|
|
* for comparisons, i.e. `===`. If `fromIndex` is negative, it is used as the
|
|
* offset from the end of the collection.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias include
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {*} target The value to check for.
|
|
* @param {number} [fromIndex=0] The index to search from.
|
|
* @returns {boolean} Returns `true` if the `target` element is found, else `false`.
|
|
* @example
|
|
*
|
|
* _.contains([1, 2, 3], 1);
|
|
* // => true
|
|
*
|
|
* _.contains([1, 2, 3], 1, 2);
|
|
* // => false
|
|
*
|
|
* _.contains({ 'name': 'fred', 'age': 40 }, 'fred');
|
|
* // => true
|
|
*
|
|
* _.contains('pebbles', 'eb');
|
|
* // => true
|
|
*/
|
|
function contains(collection, target, fromIndex) {
|
|
var index = -1,
|
|
indexOf = getIndexOf(),
|
|
length = collection ? collection.length : 0,
|
|
result = false;
|
|
|
|
fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex) || 0;
|
|
if (isArray(collection)) {
|
|
result = indexOf(collection, target, fromIndex) > -1;
|
|
} else if (typeof length == 'number') {
|
|
result = (isString(collection) ? collection.indexOf(target, fromIndex) : indexOf(collection, target, fromIndex)) > -1;
|
|
} else {
|
|
forOwn(collection, function(value) {
|
|
if (++index >= fromIndex) {
|
|
return !(result = value === target);
|
|
}
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of keys generated from the results of running
|
|
* each element of `collection` through the callback. The corresponding value
|
|
* of each key is the number of times the key was returned by the callback.
|
|
* The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns the composed aggregate object.
|
|
* @example
|
|
*
|
|
* _.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); });
|
|
* // => { '4': 1, '6': 2 }
|
|
*
|
|
* _.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
|
* // => { '4': 1, '6': 2 }
|
|
*
|
|
* _.countBy(['one', 'two', 'three'], 'length');
|
|
* // => { '3': 2, '5': 1 }
|
|
*/
|
|
var countBy = createAggregator(function(result, value, key) {
|
|
(hasOwnProperty.call(result, key) ? result[key]++ : result[key] = 1);
|
|
});
|
|
|
|
/**
|
|
* Checks if the given callback returns truey value for **all** elements of
|
|
* a collection. The callback is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias all
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {boolean} Returns `true` if all elements passed the callback check,
|
|
* else `false`.
|
|
* @example
|
|
*
|
|
* _.every([true, 1, null, 'yes']);
|
|
* // => false
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.every(characters, 'age');
|
|
* // => true
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.every(characters, { 'age': 36 });
|
|
* // => false
|
|
*/
|
|
function every(collection, callback, thisArg) {
|
|
var result = true;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
if (typeof length == 'number') {
|
|
while (++index < length) {
|
|
if (!(result = !!callback(collection[index], index, collection))) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
forOwn(collection, function(value, index, collection) {
|
|
return (result = !!callback(value, index, collection));
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Iterates over elements of a collection, returning an array of all elements
|
|
* the callback returns truey for. The callback is bound to `thisArg` and
|
|
* invoked with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias select
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new array of elements that passed the callback check.
|
|
* @example
|
|
*
|
|
* var evens = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
|
* // => [2, 4, 6]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
|
* { 'name': 'fred', 'age': 40, 'blocked': true }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.filter(characters, 'blocked');
|
|
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.filter(characters, { 'age': 36 });
|
|
* // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
|
|
*/
|
|
function filter(collection, callback, thisArg) {
|
|
var result = [];
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
if (typeof length == 'number') {
|
|
while (++index < length) {
|
|
var value = collection[index];
|
|
if (callback(value, index, collection)) {
|
|
result.push(value);
|
|
}
|
|
}
|
|
} else {
|
|
forOwn(collection, function(value, index, collection) {
|
|
if (callback(value, index, collection)) {
|
|
result.push(value);
|
|
}
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Iterates over elements of a collection, returning the first element that
|
|
* the callback returns truey for. The callback is bound to `thisArg` and
|
|
* invoked with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias detect, findWhere
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the found element, else `undefined`.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
|
* { 'name': 'fred', 'age': 40, 'blocked': true },
|
|
* { 'name': 'pebbles', 'age': 1, 'blocked': false }
|
|
* ];
|
|
*
|
|
* _.find(characters, function(chr) {
|
|
* return chr.age < 40;
|
|
* });
|
|
* // => { 'name': 'barney', 'age': 36, 'blocked': false }
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.find(characters, { 'age': 1 });
|
|
* // => { 'name': 'pebbles', 'age': 1, 'blocked': false }
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.find(characters, 'blocked');
|
|
* // => { 'name': 'fred', 'age': 40, 'blocked': true }
|
|
*/
|
|
function find(collection, callback, thisArg) {
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
if (typeof length == 'number') {
|
|
while (++index < length) {
|
|
var value = collection[index];
|
|
if (callback(value, index, collection)) {
|
|
return value;
|
|
}
|
|
}
|
|
} else {
|
|
var result;
|
|
forOwn(collection, function(value, index, collection) {
|
|
if (callback(value, index, collection)) {
|
|
result = value;
|
|
return false;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.find` except that it iterates over elements
|
|
* of a `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the found element, else `undefined`.
|
|
* @example
|
|
*
|
|
* _.findLast([1, 2, 3, 4], function(num) {
|
|
* return num % 2 == 1;
|
|
* });
|
|
* // => 3
|
|
*/
|
|
function findLast(collection, callback, thisArg) {
|
|
var result;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
forEachRight(collection, function(value, index, collection) {
|
|
if (callback(value, index, collection)) {
|
|
result = value;
|
|
return false;
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Iterates over elements of a collection, executing the callback for each
|
|
* element. The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection). Callbacks may exit iteration early by
|
|
* explicitly returning `false`.
|
|
*
|
|
* Note: As with other "Collections" methods, objects with a `length` property
|
|
* are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
|
|
* may be used for object iteration.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias each
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array|Object|string} Returns `collection`.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3]).forEach(function(num) { console.log(num); }).join(',');
|
|
* // => logs each number and returns '1,2,3'
|
|
*
|
|
* _.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); });
|
|
* // => logs each number and returns the object (property order is not guaranteed across environments)
|
|
*/
|
|
function forEach(collection, callback, thisArg) {
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
|
|
if (typeof length == 'number') {
|
|
while (++index < length) {
|
|
if (callback(collection[index], index, collection) === false) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
forOwn(collection, callback);
|
|
}
|
|
return collection;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.forEach` except that it iterates over elements
|
|
* of a `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias eachRight
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array|Object|string} Returns `collection`.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3]).forEachRight(function(num) { console.log(num); }).join(',');
|
|
* // => logs each number from right to left and returns '3,2,1'
|
|
*/
|
|
function forEachRight(collection, callback, thisArg) {
|
|
var length = collection ? collection.length : 0;
|
|
callback = callback && typeof thisArg == 'undefined' ? callback : baseCreateCallback(callback, thisArg, 3);
|
|
if (typeof length == 'number') {
|
|
while (length--) {
|
|
if (callback(collection[length], length, collection) === false) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
var props = keys(collection);
|
|
length = props.length;
|
|
forOwn(collection, function(value, key, collection) {
|
|
key = props ? props[--length] : --length;
|
|
return callback(collection[key], key, collection);
|
|
});
|
|
}
|
|
return collection;
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed of keys generated from the results of running
|
|
* each element of a collection through the callback. The corresponding value
|
|
* of each key is an array of the elements responsible for generating the key.
|
|
* The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns the composed aggregate object.
|
|
* @example
|
|
*
|
|
* _.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); });
|
|
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
|
*
|
|
* _.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math);
|
|
* // => { '4': [4.2], '6': [6.1, 6.4] }
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.groupBy(['one', 'two', 'three'], 'length');
|
|
* // => { '3': ['one', 'two'], '5': ['three'] }
|
|
*/
|
|
var groupBy = createAggregator(function(result, value, key) {
|
|
(hasOwnProperty.call(result, key) ? result[key] : result[key] = []).push(value);
|
|
});
|
|
|
|
/**
|
|
* Creates an object composed of keys generated from the results of running
|
|
* each element of the collection through the given callback. The corresponding
|
|
* value of each key is the last element responsible for generating the key.
|
|
* The callback is bound to `thisArg` and invoked with three arguments;
|
|
* (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Object} Returns the composed aggregate object.
|
|
* @example
|
|
*
|
|
* var keys = [
|
|
* { 'dir': 'left', 'code': 97 },
|
|
* { 'dir': 'right', 'code': 100 }
|
|
* ];
|
|
*
|
|
* _.indexBy(keys, 'dir');
|
|
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
|
|
*
|
|
* _.indexBy(keys, function(key) { return String.fromCharCode(key.code); });
|
|
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
|
|
*
|
|
* _.indexBy(characters, function(key) { this.fromCharCode(key.code); }, String);
|
|
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
|
|
*/
|
|
var indexBy = createAggregator(function(result, value, key) {
|
|
result[key] = value;
|
|
});
|
|
|
|
/**
|
|
* Invokes the method named by `methodName` on each element in the `collection`
|
|
* returning an array of the results of each invoked method. Additional arguments
|
|
* will be provided to each invoked method. If `methodName` is a function it
|
|
* will be invoked for, and `this` bound to, each element in the `collection`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|string} methodName The name of the method to invoke or
|
|
* the function invoked per iteration.
|
|
* @param {...*} [arg] Arguments to invoke the method with.
|
|
* @returns {Array} Returns a new array of the results of each invoked method.
|
|
* @example
|
|
*
|
|
* _.invoke([[5, 1, 7], [3, 2, 1]], 'sort');
|
|
* // => [[1, 5, 7], [1, 2, 3]]
|
|
*
|
|
* _.invoke([123, 456], String.prototype.split, '');
|
|
* // => [['1', '2', '3'], ['4', '5', '6']]
|
|
*/
|
|
function invoke(collection, methodName) {
|
|
var args = slice(arguments, 2),
|
|
index = -1,
|
|
isFunc = typeof methodName == 'function',
|
|
length = collection ? collection.length : 0,
|
|
result = Array(typeof length == 'number' ? length : 0);
|
|
|
|
forEach(collection, function(value) {
|
|
result[++index] = (isFunc ? methodName : value[methodName]).apply(value, args);
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of values by running each element in the collection
|
|
* through the callback. The callback is bound to `thisArg` and invoked with
|
|
* three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias collect
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new array of the results of each `callback` execution.
|
|
* @example
|
|
*
|
|
* _.map([1, 2, 3], function(num) { return num * 3; });
|
|
* // => [3, 6, 9]
|
|
*
|
|
* _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; });
|
|
* // => [3, 6, 9] (property order is not guaranteed across environments)
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.map(characters, 'name');
|
|
* // => ['barney', 'fred']
|
|
*/
|
|
function map(collection, callback, thisArg) {
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
if (typeof length == 'number') {
|
|
var result = Array(length);
|
|
while (++index < length) {
|
|
result[index] = callback(collection[index], index, collection);
|
|
}
|
|
} else {
|
|
result = [];
|
|
forOwn(collection, function(value, key, collection) {
|
|
result[++index] = callback(value, key, collection);
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieves the maximum value of a collection. If the collection is empty or
|
|
* falsey `-Infinity` is returned. If a callback is provided it will be executed
|
|
* for each value in the collection to generate the criterion by which the value
|
|
* is ranked. The callback is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the maximum value.
|
|
* @example
|
|
*
|
|
* _.max([4, 2, 8, 6]);
|
|
* // => 8
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.max(characters, function(chr) { return chr.age; });
|
|
* // => { 'name': 'fred', 'age': 40 };
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.max(characters, 'age');
|
|
* // => { 'name': 'fred', 'age': 40 };
|
|
*/
|
|
function max(collection, callback, thisArg) {
|
|
var computed = -Infinity,
|
|
result = computed;
|
|
|
|
// allows working with functions like `_.map` without using
|
|
// their `index` argument as a callback
|
|
if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
|
|
callback = null;
|
|
}
|
|
if (callback == null && isArray(collection)) {
|
|
var index = -1,
|
|
length = collection.length;
|
|
|
|
while (++index < length) {
|
|
var value = collection[index];
|
|
if (value > result) {
|
|
result = value;
|
|
}
|
|
}
|
|
} else {
|
|
callback = (callback == null && isString(collection))
|
|
? charAtCallback
|
|
: lodash.createCallback(callback, thisArg, 3);
|
|
|
|
forEach(collection, function(value, index, collection) {
|
|
var current = callback(value, index, collection);
|
|
if (current > computed) {
|
|
computed = current;
|
|
result = value;
|
|
}
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieves the minimum value of a collection. If the collection is empty or
|
|
* falsey `Infinity` is returned. If a callback is provided it will be executed
|
|
* for each value in the collection to generate the criterion by which the value
|
|
* is ranked. The callback is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the minimum value.
|
|
* @example
|
|
*
|
|
* _.min([4, 2, 8, 6]);
|
|
* // => 2
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.min(characters, function(chr) { return chr.age; });
|
|
* // => { 'name': 'barney', 'age': 36 };
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.min(characters, 'age');
|
|
* // => { 'name': 'barney', 'age': 36 };
|
|
*/
|
|
function min(collection, callback, thisArg) {
|
|
var computed = Infinity,
|
|
result = computed;
|
|
|
|
// allows working with functions like `_.map` without using
|
|
// their `index` argument as a callback
|
|
if (typeof callback != 'function' && thisArg && thisArg[callback] === collection) {
|
|
callback = null;
|
|
}
|
|
if (callback == null && isArray(collection)) {
|
|
var index = -1,
|
|
length = collection.length;
|
|
|
|
while (++index < length) {
|
|
var value = collection[index];
|
|
if (value < result) {
|
|
result = value;
|
|
}
|
|
}
|
|
} else {
|
|
callback = (callback == null && isString(collection))
|
|
? charAtCallback
|
|
: lodash.createCallback(callback, thisArg, 3);
|
|
|
|
forEach(collection, function(value, index, collection) {
|
|
var current = callback(value, index, collection);
|
|
if (current < computed) {
|
|
computed = current;
|
|
result = value;
|
|
}
|
|
});
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Retrieves the value of a specified property from all elements in the collection.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {string} property The name of the property to pluck.
|
|
* @returns {Array} Returns a new array of property values.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* _.pluck(characters, 'name');
|
|
* // => ['barney', 'fred']
|
|
*/
|
|
var pluck = map;
|
|
|
|
/**
|
|
* Reduces a collection to a value which is the accumulated result of running
|
|
* each element in the collection through the callback, where each successive
|
|
* callback execution consumes the return value of the previous execution. If
|
|
* `accumulator` is not provided the first element of the collection will be
|
|
* used as the initial `accumulator` value. The callback is bound to `thisArg`
|
|
* and invoked with four arguments; (accumulator, value, index|key, collection).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias foldl, inject
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [accumulator] Initial value of the accumulator.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the accumulated value.
|
|
* @example
|
|
*
|
|
* var sum = _.reduce([1, 2, 3], function(sum, num) {
|
|
* return sum + num;
|
|
* });
|
|
* // => 6
|
|
*
|
|
* var mapped = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(result, num, key) {
|
|
* result[key] = num * 3;
|
|
* return result;
|
|
* }, {});
|
|
* // => { 'a': 3, 'b': 6, 'c': 9 }
|
|
*/
|
|
function reduce(collection, callback, accumulator, thisArg) {
|
|
if (!collection) return accumulator;
|
|
var noaccum = arguments.length < 3;
|
|
callback = lodash.createCallback(callback, thisArg, 4);
|
|
|
|
var index = -1,
|
|
length = collection.length;
|
|
|
|
if (typeof length == 'number') {
|
|
if (noaccum) {
|
|
accumulator = collection[++index];
|
|
}
|
|
while (++index < length) {
|
|
accumulator = callback(accumulator, collection[index], index, collection);
|
|
}
|
|
} else {
|
|
forOwn(collection, function(value, index, collection) {
|
|
accumulator = noaccum
|
|
? (noaccum = false, value)
|
|
: callback(accumulator, value, index, collection)
|
|
});
|
|
}
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.reduce` except that it iterates over elements
|
|
* of a `collection` from right to left.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias foldr
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function} [callback=identity] The function called per iteration.
|
|
* @param {*} [accumulator] Initial value of the accumulator.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the accumulated value.
|
|
* @example
|
|
*
|
|
* var list = [[0, 1], [2, 3], [4, 5]];
|
|
* var flat = _.reduceRight(list, function(a, b) { return a.concat(b); }, []);
|
|
* // => [4, 5, 2, 3, 0, 1]
|
|
*/
|
|
function reduceRight(collection, callback, accumulator, thisArg) {
|
|
var noaccum = arguments.length < 3;
|
|
callback = lodash.createCallback(callback, thisArg, 4);
|
|
forEachRight(collection, function(value, index, collection) {
|
|
accumulator = noaccum
|
|
? (noaccum = false, value)
|
|
: callback(accumulator, value, index, collection);
|
|
});
|
|
return accumulator;
|
|
}
|
|
|
|
/**
|
|
* The opposite of `_.filter` this method returns the elements of a
|
|
* collection that the callback does **not** return truey for.
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new array of elements that failed the callback check.
|
|
* @example
|
|
*
|
|
* var odds = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; });
|
|
* // => [1, 3, 5]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
|
* { 'name': 'fred', 'age': 40, 'blocked': true }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.reject(characters, 'blocked');
|
|
* // => [{ 'name': 'barney', 'age': 36, 'blocked': false }]
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.reject(characters, { 'age': 36 });
|
|
* // => [{ 'name': 'fred', 'age': 40, 'blocked': true }]
|
|
*/
|
|
function reject(collection, callback, thisArg) {
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
return filter(collection, function(value, index, collection) {
|
|
return !callback(value, index, collection);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Retrieves a random element or `n` random elements from a collection.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to sample.
|
|
* @param {number} [n] The number of elements to sample.
|
|
* @param- {Object} [guard] Allows working with functions like `_.map`
|
|
* without using their `index` arguments as `n`.
|
|
* @returns {Array} Returns the random sample(s) of `collection`.
|
|
* @example
|
|
*
|
|
* _.sample([1, 2, 3, 4]);
|
|
* // => 2
|
|
*
|
|
* _.sample([1, 2, 3, 4], 2);
|
|
* // => [3, 1]
|
|
*/
|
|
function sample(collection, n, guard) {
|
|
if (collection && typeof collection.length != 'number') {
|
|
collection = values(collection);
|
|
}
|
|
if (n == null || guard) {
|
|
return collection ? collection[baseRandom(0, collection.length - 1)] : undefined;
|
|
}
|
|
var result = shuffle(collection);
|
|
result.length = nativeMin(nativeMax(0, n), result.length);
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of shuffled values, using a version of the Fisher-Yates
|
|
* shuffle. See http://en.wikipedia.org/wiki/Fisher-Yates_shuffle.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to shuffle.
|
|
* @returns {Array} Returns a new shuffled collection.
|
|
* @example
|
|
*
|
|
* _.shuffle([1, 2, 3, 4, 5, 6]);
|
|
* // => [4, 1, 6, 3, 5, 2]
|
|
*/
|
|
function shuffle(collection) {
|
|
var index = -1,
|
|
length = collection ? collection.length : 0,
|
|
result = Array(typeof length == 'number' ? length : 0);
|
|
|
|
forEach(collection, function(value) {
|
|
var rand = baseRandom(0, ++index);
|
|
result[index] = result[rand];
|
|
result[rand] = value;
|
|
});
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets the size of the `collection` by returning `collection.length` for arrays
|
|
* and array-like objects or the number of own enumerable properties for objects.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to inspect.
|
|
* @returns {number} Returns `collection.length` or number of own enumerable properties.
|
|
* @example
|
|
*
|
|
* _.size([1, 2]);
|
|
* // => 2
|
|
*
|
|
* _.size({ 'one': 1, 'two': 2, 'three': 3 });
|
|
* // => 3
|
|
*
|
|
* _.size('pebbles');
|
|
* // => 7
|
|
*/
|
|
function size(collection) {
|
|
var length = collection ? collection.length : 0;
|
|
return typeof length == 'number' ? length : keys(collection).length;
|
|
}
|
|
|
|
/**
|
|
* Checks if the callback returns a truey value for **any** element of a
|
|
* collection. The function returns as soon as it finds a passing value and
|
|
* does not iterate over the entire collection. The callback is bound to
|
|
* `thisArg` and invoked with three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias any
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {boolean} Returns `true` if any element passed the callback check,
|
|
* else `false`.
|
|
* @example
|
|
*
|
|
* _.some([null, 0, 'yes', false], Boolean);
|
|
* // => true
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
|
* { 'name': 'fred', 'age': 40, 'blocked': true }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.some(characters, 'blocked');
|
|
* // => true
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.some(characters, { 'age': 1 });
|
|
* // => false
|
|
*/
|
|
function some(collection, callback, thisArg) {
|
|
var result;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
|
|
var index = -1,
|
|
length = collection ? collection.length : 0;
|
|
|
|
if (typeof length == 'number') {
|
|
while (++index < length) {
|
|
if ((result = callback(collection[index], index, collection))) {
|
|
break;
|
|
}
|
|
}
|
|
} else {
|
|
forOwn(collection, function(value, index, collection) {
|
|
return !(result = callback(value, index, collection));
|
|
});
|
|
}
|
|
return !!result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of elements, sorted in ascending order by the results of
|
|
* running each element in a collection through the callback. This method
|
|
* performs a stable sort, that is, it will preserve the original sort order
|
|
* of equal elements. The callback is bound to `thisArg` and invoked with
|
|
* three arguments; (value, index|key, collection).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an array of property names is provided for `callback` the collection
|
|
* will be sorted by each property value.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Array|Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new array of sorted elements.
|
|
* @example
|
|
*
|
|
* _.sortBy([1, 2, 3], function(num) { return Math.sin(num); });
|
|
* // => [3, 1, 2]
|
|
*
|
|
* _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math);
|
|
* // => [3, 1, 2]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 },
|
|
* { 'name': 'barney', 'age': 26 },
|
|
* { 'name': 'fred', 'age': 30 }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.map(_.sortBy(characters, 'age'), _.values);
|
|
* // => [['barney', 26], ['fred', 30], ['barney', 36], ['fred', 40]]
|
|
*
|
|
* // sorting by multiple properties
|
|
* _.map(_.sortBy(characters, ['name', 'age']), _.values);
|
|
* // = > [['barney', 26], ['barney', 36], ['fred', 30], ['fred', 40]]
|
|
*/
|
|
function sortBy(collection, callback, thisArg) {
|
|
var index = -1,
|
|
isArr = isArray(callback),
|
|
length = collection ? collection.length : 0,
|
|
result = Array(typeof length == 'number' ? length : 0);
|
|
|
|
if (!isArr) {
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
}
|
|
forEach(collection, function(value, key, collection) {
|
|
var object = result[++index] = getObject();
|
|
if (isArr) {
|
|
object.criteria = map(callback, function(key) { return value[key]; });
|
|
} else {
|
|
(object.criteria = getArray())[0] = callback(value, key, collection);
|
|
}
|
|
object.index = index;
|
|
object.value = value;
|
|
});
|
|
|
|
length = result.length;
|
|
result.sort(compareAscending);
|
|
while (length--) {
|
|
var object = result[length];
|
|
result[length] = object.value;
|
|
if (!isArr) {
|
|
releaseArray(object.criteria);
|
|
}
|
|
releaseObject(object);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Converts the `collection` to an array.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to convert.
|
|
* @returns {Array} Returns the new converted array.
|
|
* @example
|
|
*
|
|
* (function() { return _.toArray(arguments).slice(1); })(1, 2, 3, 4);
|
|
* // => [2, 3, 4]
|
|
*/
|
|
function toArray(collection) {
|
|
if (collection && typeof collection.length == 'number') {
|
|
return slice(collection);
|
|
}
|
|
return values(collection);
|
|
}
|
|
|
|
/**
|
|
* Performs a deep comparison of each element in a `collection` to the given
|
|
* `properties` object, returning an array of all elements that have equivalent
|
|
* property values.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type Function
|
|
* @category Collections
|
|
* @param {Array|Object|string} collection The collection to iterate over.
|
|
* @param {Object} props The object of property values to filter by.
|
|
* @returns {Array} Returns a new array of elements that have the given properties.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'pets': ['hoppy'] },
|
|
* { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
|
|
* ];
|
|
*
|
|
* _.where(characters, { 'age': 36 });
|
|
* // => [{ 'name': 'barney', 'age': 36, 'pets': ['hoppy'] }]
|
|
*
|
|
* _.where(characters, { 'pets': ['dino'] });
|
|
* // => [{ 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }]
|
|
*/
|
|
var where = filter;
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates an array with all falsey values removed. The values `false`, `null`,
|
|
* `0`, `""`, `undefined`, and `NaN` are all falsey.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to compact.
|
|
* @returns {Array} Returns a new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.compact([0, 1, false, 2, '', 3]);
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function compact(array) {
|
|
var index = -1,
|
|
length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (value) {
|
|
result.push(value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an array excluding all values of the provided arrays using strict
|
|
* equality for comparisons, i.e. `===`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to process.
|
|
* @param {...Array} [values] The arrays of values to exclude.
|
|
* @returns {Array} Returns a new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.difference([1, 2, 3, 4, 5], [5, 2, 10]);
|
|
* // => [1, 3, 4]
|
|
*/
|
|
function difference(array) {
|
|
return baseDifference(array, baseFlatten(arguments, true, true, 1));
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.find` except that it returns the index of the first
|
|
* element that passes the callback check, instead of the element itself.
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to search.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {number} Returns the index of the found element, else `-1`.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'blocked': false },
|
|
* { 'name': 'fred', 'age': 40, 'blocked': true },
|
|
* { 'name': 'pebbles', 'age': 1, 'blocked': false }
|
|
* ];
|
|
*
|
|
* _.findIndex(characters, function(chr) {
|
|
* return chr.age < 20;
|
|
* });
|
|
* // => 2
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.findIndex(characters, { 'age': 36 });
|
|
* // => 0
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.findIndex(characters, 'blocked');
|
|
* // => 1
|
|
*/
|
|
function findIndex(array, callback, thisArg) {
|
|
var index = -1,
|
|
length = array ? array.length : 0;
|
|
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (++index < length) {
|
|
if (callback(array[index], index, array)) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.findIndex` except that it iterates over elements
|
|
* of a `collection` from right to left.
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to search.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {number} Returns the index of the found element, else `-1`.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36, 'blocked': true },
|
|
* { 'name': 'fred', 'age': 40, 'blocked': false },
|
|
* { 'name': 'pebbles', 'age': 1, 'blocked': true }
|
|
* ];
|
|
*
|
|
* _.findLastIndex(characters, function(chr) {
|
|
* return chr.age > 30;
|
|
* });
|
|
* // => 1
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.findLastIndex(characters, { 'age': 36 });
|
|
* // => 0
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.findLastIndex(characters, 'blocked');
|
|
* // => 2
|
|
*/
|
|
function findLastIndex(array, callback, thisArg) {
|
|
var length = array ? array.length : 0;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (length--) {
|
|
if (callback(array[length], length, array)) {
|
|
return length;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* Gets the first element or first `n` elements of an array. If a callback
|
|
* is provided elements at the beginning of the array are returned as long
|
|
* as the callback returns truey. The callback is bound to `thisArg` and
|
|
* invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias head, take
|
|
* @category Arrays
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|number|string} [callback] The function called
|
|
* per element or the number of elements to return. If a property name or
|
|
* object is provided it will be used to create a "_.pluck" or "_.where"
|
|
* style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the first element(s) of `array`.
|
|
* @example
|
|
*
|
|
* _.first([1, 2, 3]);
|
|
* // => 1
|
|
*
|
|
* _.first([1, 2, 3], 2);
|
|
* // => [1, 2]
|
|
*
|
|
* _.first([1, 2, 3], function(num) {
|
|
* return num < 3;
|
|
* });
|
|
* // => [1, 2]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'blocked': true, 'employer': 'slate' },
|
|
* { 'name': 'fred', 'blocked': false, 'employer': 'slate' },
|
|
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.first(characters, 'blocked');
|
|
* // => [{ 'name': 'barney', 'blocked': true, 'employer': 'slate' }]
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.pluck(_.first(characters, { 'employer': 'slate' }), 'name');
|
|
* // => ['barney', 'fred']
|
|
*/
|
|
function first(array, callback, thisArg) {
|
|
var n = 0,
|
|
length = array ? array.length : 0;
|
|
|
|
if (typeof callback != 'number' && callback != null) {
|
|
var index = -1;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (++index < length && callback(array[index], index, array)) {
|
|
n++;
|
|
}
|
|
} else {
|
|
n = callback;
|
|
if (n == null || thisArg) {
|
|
return array ? array[0] : undefined;
|
|
}
|
|
}
|
|
return slice(array, 0, nativeMin(nativeMax(0, n), length));
|
|
}
|
|
|
|
/**
|
|
* Flattens a nested array (the nesting can be to any depth). If `isShallow`
|
|
* is truey, the array will only be flattened a single level. If a callback
|
|
* is provided each element of the array is passed through the callback before
|
|
* flattening. The callback is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to flatten.
|
|
* @param {boolean} [isShallow=false] A flag to restrict flattening to a single level.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new flattened array.
|
|
* @example
|
|
*
|
|
* _.flatten([1, [2], [3, [[4]]]]);
|
|
* // => [1, 2, 3, 4];
|
|
*
|
|
* _.flatten([1, [2], [3, [[4]]]], true);
|
|
* // => [1, 2, 3, [[4]]];
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 30, 'pets': ['hoppy'] },
|
|
* { 'name': 'fred', 'age': 40, 'pets': ['baby puss', 'dino'] }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.flatten(characters, 'pets');
|
|
* // => ['hoppy', 'baby puss', 'dino']
|
|
*/
|
|
function flatten(array, isShallow, callback, thisArg) {
|
|
// juggle arguments
|
|
if (typeof isShallow != 'boolean' && isShallow != null) {
|
|
thisArg = callback;
|
|
callback = (typeof isShallow != 'function' && thisArg && thisArg[isShallow] === array) ? null : isShallow;
|
|
isShallow = false;
|
|
}
|
|
if (callback != null) {
|
|
array = map(array, callback, thisArg);
|
|
}
|
|
return baseFlatten(array, isShallow);
|
|
}
|
|
|
|
/**
|
|
* Gets the index at which the first occurrence of `value` is found using
|
|
* strict equality for comparisons, i.e. `===`. If the array is already sorted
|
|
* providing `true` for `fromIndex` will run a faster binary search.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to search.
|
|
* @param {*} value The value to search for.
|
|
* @param {boolean|number} [fromIndex=0] The index to search from or `true`
|
|
* to perform a binary search on a sorted array.
|
|
* @returns {number} Returns the index of the matched value or `-1`.
|
|
* @example
|
|
*
|
|
* _.indexOf([1, 2, 3, 1, 2, 3], 2);
|
|
* // => 1
|
|
*
|
|
* _.indexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
|
* // => 4
|
|
*
|
|
* _.indexOf([1, 1, 2, 2, 3, 3], 2, true);
|
|
* // => 2
|
|
*/
|
|
function indexOf(array, value, fromIndex) {
|
|
if (typeof fromIndex == 'number') {
|
|
var length = array ? array.length : 0;
|
|
fromIndex = (fromIndex < 0 ? nativeMax(0, length + fromIndex) : fromIndex || 0);
|
|
} else if (fromIndex) {
|
|
var index = sortedIndex(array, value);
|
|
return array[index] === value ? index : -1;
|
|
}
|
|
return baseIndexOf(array, value, fromIndex);
|
|
}
|
|
|
|
/**
|
|
* Gets all but the last element or last `n` elements of an array. If a
|
|
* callback is provided elements at the end of the array are excluded from
|
|
* the result as long as the callback returns truey. The callback is bound
|
|
* to `thisArg` and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|number|string} [callback=1] The function called
|
|
* per element or the number of elements to exclude. If a property name or
|
|
* object is provided it will be used to create a "_.pluck" or "_.where"
|
|
* style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a slice of `array`.
|
|
* @example
|
|
*
|
|
* _.initial([1, 2, 3]);
|
|
* // => [1, 2]
|
|
*
|
|
* _.initial([1, 2, 3], 2);
|
|
* // => [1]
|
|
*
|
|
* _.initial([1, 2, 3], function(num) {
|
|
* return num > 1;
|
|
* });
|
|
* // => [1]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'blocked': false, 'employer': 'slate' },
|
|
* { 'name': 'fred', 'blocked': true, 'employer': 'slate' },
|
|
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.initial(characters, 'blocked');
|
|
* // => [{ 'name': 'barney', 'blocked': false, 'employer': 'slate' }]
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.pluck(_.initial(characters, { 'employer': 'na' }), 'name');
|
|
* // => ['barney', 'fred']
|
|
*/
|
|
function initial(array, callback, thisArg) {
|
|
var n = 0,
|
|
length = array ? array.length : 0;
|
|
|
|
if (typeof callback != 'number' && callback != null) {
|
|
var index = length;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (index-- && callback(array[index], index, array)) {
|
|
n++;
|
|
}
|
|
} else {
|
|
n = (callback == null || thisArg) ? 1 : callback || n;
|
|
}
|
|
return slice(array, 0, nativeMin(nativeMax(0, length - n), length));
|
|
}
|
|
|
|
/**
|
|
* Creates an array of unique values present in all provided arrays using
|
|
* strict equality for comparisons, i.e. `===`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {...Array} [array] The arrays to inspect.
|
|
* @returns {Array} Returns an array of shared values.
|
|
* @example
|
|
*
|
|
* _.intersection([1, 2, 3], [5, 2, 1, 4], [2, 1]);
|
|
* // => [1, 2]
|
|
*/
|
|
function intersection() {
|
|
var args = [],
|
|
argsIndex = -1,
|
|
argsLength = arguments.length,
|
|
caches = getArray(),
|
|
indexOf = getIndexOf(),
|
|
trustIndexOf = indexOf === baseIndexOf,
|
|
seen = getArray();
|
|
|
|
while (++argsIndex < argsLength) {
|
|
var value = arguments[argsIndex];
|
|
if (isArray(value) || isArguments(value)) {
|
|
args.push(value);
|
|
caches.push(trustIndexOf && value.length >= largeArraySize &&
|
|
createCache(argsIndex ? args[argsIndex] : seen));
|
|
}
|
|
}
|
|
var array = args[0],
|
|
index = -1,
|
|
length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
outer:
|
|
while (++index < length) {
|
|
var cache = caches[0];
|
|
value = array[index];
|
|
|
|
if ((cache ? cacheIndexOf(cache, value) : indexOf(seen, value)) < 0) {
|
|
argsIndex = argsLength;
|
|
(cache || seen).push(value);
|
|
while (--argsIndex) {
|
|
cache = caches[argsIndex];
|
|
if ((cache ? cacheIndexOf(cache, value) : indexOf(args[argsIndex], value)) < 0) {
|
|
continue outer;
|
|
}
|
|
}
|
|
result.push(value);
|
|
}
|
|
}
|
|
while (argsLength--) {
|
|
cache = caches[argsLength];
|
|
if (cache) {
|
|
releaseObject(cache);
|
|
}
|
|
}
|
|
releaseArray(caches);
|
|
releaseArray(seen);
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Gets the last element or last `n` elements of an array. If a callback is
|
|
* provided elements at the end of the array are returned as long as the
|
|
* callback returns truey. The callback is bound to `thisArg` and invoked
|
|
* with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|number|string} [callback] The function called
|
|
* per element or the number of elements to return. If a property name or
|
|
* object is provided it will be used to create a "_.pluck" or "_.where"
|
|
* style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {*} Returns the last element(s) of `array`.
|
|
* @example
|
|
*
|
|
* _.last([1, 2, 3]);
|
|
* // => 3
|
|
*
|
|
* _.last([1, 2, 3], 2);
|
|
* // => [2, 3]
|
|
*
|
|
* _.last([1, 2, 3], function(num) {
|
|
* return num > 1;
|
|
* });
|
|
* // => [2, 3]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'blocked': false, 'employer': 'slate' },
|
|
* { 'name': 'fred', 'blocked': true, 'employer': 'slate' },
|
|
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.pluck(_.last(characters, 'blocked'), 'name');
|
|
* // => ['fred', 'pebbles']
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.last(characters, { 'employer': 'na' });
|
|
* // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
|
|
*/
|
|
function last(array, callback, thisArg) {
|
|
var n = 0,
|
|
length = array ? array.length : 0;
|
|
|
|
if (typeof callback != 'number' && callback != null) {
|
|
var index = length;
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (index-- && callback(array[index], index, array)) {
|
|
n++;
|
|
}
|
|
} else {
|
|
n = callback;
|
|
if (n == null || thisArg) {
|
|
return array ? array[length - 1] : undefined;
|
|
}
|
|
}
|
|
return slice(array, nativeMax(0, length - n));
|
|
}
|
|
|
|
/**
|
|
* Gets the index at which the last occurrence of `value` is found using strict
|
|
* equality for comparisons, i.e. `===`. If `fromIndex` is negative, it is used
|
|
* as the offset from the end of the collection.
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to search.
|
|
* @param {*} value The value to search for.
|
|
* @param {number} [fromIndex=array.length-1] The index to search from.
|
|
* @returns {number} Returns the index of the matched value or `-1`.
|
|
* @example
|
|
*
|
|
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2);
|
|
* // => 4
|
|
*
|
|
* _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3);
|
|
* // => 1
|
|
*/
|
|
function lastIndexOf(array, value, fromIndex) {
|
|
var index = array ? array.length : 0;
|
|
if (typeof fromIndex == 'number') {
|
|
index = (fromIndex < 0 ? nativeMax(0, index + fromIndex) : nativeMin(fromIndex, index - 1)) + 1;
|
|
}
|
|
while (index--) {
|
|
if (array[index] === value) {
|
|
return index;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
/**
|
|
* Removes all provided values from the given array using strict equality for
|
|
* comparisons, i.e. `===`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to modify.
|
|
* @param {...*} [value] The values to remove.
|
|
* @returns {Array} Returns `array`.
|
|
* @example
|
|
*
|
|
* var array = [1, 2, 3, 1, 2, 3];
|
|
* _.pull(array, 2, 3);
|
|
* console.log(array);
|
|
* // => [1, 1]
|
|
*/
|
|
function pull(array) {
|
|
var args = arguments,
|
|
argsIndex = 0,
|
|
argsLength = args.length,
|
|
length = array ? array.length : 0;
|
|
|
|
while (++argsIndex < argsLength) {
|
|
var index = -1,
|
|
value = args[argsIndex];
|
|
while (++index < length) {
|
|
if (array[index] === value) {
|
|
splice.call(array, index--, 1);
|
|
length--;
|
|
}
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of numbers (positive and/or negative) progressing from
|
|
* `start` up to but not including `end`. If `start` is less than `stop` a
|
|
* zero-length range is created unless a negative `step` is specified.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {number} [start=0] The start of the range.
|
|
* @param {number} end The end of the range.
|
|
* @param {number} [step=1] The value to increment or decrement by.
|
|
* @returns {Array} Returns a new range array.
|
|
* @example
|
|
*
|
|
* _.range(4);
|
|
* // => [0, 1, 2, 3]
|
|
*
|
|
* _.range(1, 5);
|
|
* // => [1, 2, 3, 4]
|
|
*
|
|
* _.range(0, 20, 5);
|
|
* // => [0, 5, 10, 15]
|
|
*
|
|
* _.range(0, -4, -1);
|
|
* // => [0, -1, -2, -3]
|
|
*
|
|
* _.range(1, 4, 0);
|
|
* // => [1, 1, 1]
|
|
*
|
|
* _.range(0);
|
|
* // => []
|
|
*/
|
|
function range(start, end, step) {
|
|
start = +start || 0;
|
|
step = typeof step == 'number' ? step : (+step || 1);
|
|
|
|
if (end == null) {
|
|
end = start;
|
|
start = 0;
|
|
}
|
|
// use `Array(length)` so engines like Chakra and V8 avoid slower modes
|
|
// http://youtu.be/XAqIpGU8ZZk#t=17m25s
|
|
var index = -1,
|
|
length = nativeMax(0, ceil((end - start) / (step || 1))),
|
|
result = Array(length);
|
|
|
|
while (++index < length) {
|
|
result[index] = start;
|
|
start += step;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Removes all elements from an array that the callback returns truey for
|
|
* and returns an array of removed elements. The callback is bound to `thisArg`
|
|
* and invoked with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to modify.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a new array of removed elements.
|
|
* @example
|
|
*
|
|
* var array = [1, 2, 3, 4, 5, 6];
|
|
* var evens = _.remove(array, function(num) { return num % 2 == 0; });
|
|
*
|
|
* console.log(array);
|
|
* // => [1, 3, 5]
|
|
*
|
|
* console.log(evens);
|
|
* // => [2, 4, 6]
|
|
*/
|
|
function remove(array, callback, thisArg) {
|
|
var index = -1,
|
|
length = array ? array.length : 0,
|
|
result = [];
|
|
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (++index < length) {
|
|
var value = array[index];
|
|
if (callback(value, index, array)) {
|
|
result.push(value);
|
|
splice.call(array, index--, 1);
|
|
length--;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The opposite of `_.initial` this method gets all but the first element or
|
|
* first `n` elements of an array. If a callback function is provided elements
|
|
* at the beginning of the array are excluded from the result as long as the
|
|
* callback returns truey. The callback is bound to `thisArg` and invoked
|
|
* with three arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias drop, tail
|
|
* @category Arrays
|
|
* @param {Array} array The array to query.
|
|
* @param {Function|Object|number|string} [callback=1] The function called
|
|
* per element or the number of elements to exclude. If a property name or
|
|
* object is provided it will be used to create a "_.pluck" or "_.where"
|
|
* style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a slice of `array`.
|
|
* @example
|
|
*
|
|
* _.rest([1, 2, 3]);
|
|
* // => [2, 3]
|
|
*
|
|
* _.rest([1, 2, 3], 2);
|
|
* // => [3]
|
|
*
|
|
* _.rest([1, 2, 3], function(num) {
|
|
* return num < 3;
|
|
* });
|
|
* // => [3]
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'blocked': true, 'employer': 'slate' },
|
|
* { 'name': 'fred', 'blocked': false, 'employer': 'slate' },
|
|
* { 'name': 'pebbles', 'blocked': true, 'employer': 'na' }
|
|
* ];
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.pluck(_.rest(characters, 'blocked'), 'name');
|
|
* // => ['fred', 'pebbles']
|
|
*
|
|
* // using "_.where" callback shorthand
|
|
* _.rest(characters, { 'employer': 'slate' });
|
|
* // => [{ 'name': 'pebbles', 'blocked': true, 'employer': 'na' }]
|
|
*/
|
|
function rest(array, callback, thisArg) {
|
|
if (typeof callback != 'number' && callback != null) {
|
|
var n = 0,
|
|
index = -1,
|
|
length = array ? array.length : 0;
|
|
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
while (++index < length && callback(array[index], index, array)) {
|
|
n++;
|
|
}
|
|
} else {
|
|
n = (callback == null || thisArg) ? 1 : nativeMax(0, callback);
|
|
}
|
|
return slice(array, n);
|
|
}
|
|
|
|
/**
|
|
* Uses a binary search to determine the smallest index at which a value
|
|
* should be inserted into a given sorted array in order to maintain the sort
|
|
* order of the array. If a callback is provided it will be executed for
|
|
* `value` and each element of `array` to compute their sort ranking. The
|
|
* callback is bound to `thisArg` and invoked with one argument; (value).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to inspect.
|
|
* @param {*} value The value to evaluate.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {number} Returns the index at which `value` should be inserted
|
|
* into `array`.
|
|
* @example
|
|
*
|
|
* _.sortedIndex([20, 30, 50], 40);
|
|
* // => 2
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x');
|
|
* // => 2
|
|
*
|
|
* var dict = {
|
|
* 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 }
|
|
* };
|
|
*
|
|
* _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
|
|
* return dict.wordToNumber[word];
|
|
* });
|
|
* // => 2
|
|
*
|
|
* _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) {
|
|
* return this.wordToNumber[word];
|
|
* }, dict);
|
|
* // => 2
|
|
*/
|
|
function sortedIndex(array, value, callback, thisArg) {
|
|
var low = 0,
|
|
high = array ? array.length : low;
|
|
|
|
// explicitly reference `identity` for better inlining in Firefox
|
|
callback = callback ? lodash.createCallback(callback, thisArg, 1) : identity;
|
|
value = callback(value);
|
|
|
|
while (low < high) {
|
|
var mid = (low + high) >>> 1;
|
|
(callback(array[mid]) < value)
|
|
? low = mid + 1
|
|
: high = mid;
|
|
}
|
|
return low;
|
|
}
|
|
|
|
/**
|
|
* Creates an array of unique values, in order, of the provided arrays using
|
|
* strict equality for comparisons, i.e. `===`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {...Array} [array] The arrays to inspect.
|
|
* @returns {Array} Returns an array of combined values.
|
|
* @example
|
|
*
|
|
* _.union([1, 2, 3], [5, 2, 1, 4], [2, 1]);
|
|
* // => [1, 2, 3, 5, 4]
|
|
*/
|
|
function union() {
|
|
return baseUniq(baseFlatten(arguments, true, true));
|
|
}
|
|
|
|
/**
|
|
* Creates a duplicate-value-free version of an array using strict equality
|
|
* for comparisons, i.e. `===`. If the array is sorted, providing
|
|
* `true` for `isSorted` will use a faster algorithm. If a callback is provided
|
|
* each element of `array` is passed through the callback before uniqueness
|
|
* is computed. The callback is bound to `thisArg` and invoked with three
|
|
* arguments; (value, index, array).
|
|
*
|
|
* If a property name is provided for `callback` the created "_.pluck" style
|
|
* callback will return the property value of the given element.
|
|
*
|
|
* If an object is provided for `callback` the created "_.where" style callback
|
|
* will return `true` for elements that have the properties of the given object,
|
|
* else `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias unique
|
|
* @category Arrays
|
|
* @param {Array} array The array to process.
|
|
* @param {boolean} [isSorted=false] A flag to indicate that `array` is sorted.
|
|
* @param {Function|Object|string} [callback=identity] The function called
|
|
* per iteration. If a property name or object is provided it will be used
|
|
* to create a "_.pluck" or "_.where" style callback, respectively.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns a duplicate-value-free array.
|
|
* @example
|
|
*
|
|
* _.uniq([1, 2, 1, 3, 1]);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* _.uniq([1, 1, 2, 2, 3], true);
|
|
* // => [1, 2, 3]
|
|
*
|
|
* _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { return letter.toLowerCase(); });
|
|
* // => ['A', 'b', 'C']
|
|
*
|
|
* _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math);
|
|
* // => [1, 2.5, 3]
|
|
*
|
|
* // using "_.pluck" callback shorthand
|
|
* _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
|
|
* // => [{ 'x': 1 }, { 'x': 2 }]
|
|
*/
|
|
function uniq(array, isSorted, callback, thisArg) {
|
|
// juggle arguments
|
|
if (typeof isSorted != 'boolean' && isSorted != null) {
|
|
thisArg = callback;
|
|
callback = (typeof isSorted != 'function' && thisArg && thisArg[isSorted] === array) ? null : isSorted;
|
|
isSorted = false;
|
|
}
|
|
if (callback != null) {
|
|
callback = lodash.createCallback(callback, thisArg, 3);
|
|
}
|
|
return baseUniq(array, isSorted, callback);
|
|
}
|
|
|
|
/**
|
|
* Creates an array excluding all provided values using strict equality for
|
|
* comparisons, i.e. `===`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {Array} array The array to filter.
|
|
* @param {...*} [value] The values to exclude.
|
|
* @returns {Array} Returns a new array of filtered values.
|
|
* @example
|
|
*
|
|
* _.without([1, 2, 1, 0, 3, 1, 4], 0, 1);
|
|
* // => [2, 3, 4]
|
|
*/
|
|
function without(array) {
|
|
return baseDifference(array, slice(arguments, 1));
|
|
}
|
|
|
|
/**
|
|
* Creates an array that is the symmetric difference of the provided arrays.
|
|
* See http://en.wikipedia.org/wiki/Symmetric_difference.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Arrays
|
|
* @param {...Array} [array] The arrays to inspect.
|
|
* @returns {Array} Returns an array of values.
|
|
* @example
|
|
*
|
|
* _.xor([1, 2, 3], [5, 2, 1, 4]);
|
|
* // => [3, 5, 4]
|
|
*
|
|
* _.xor([1, 2, 5], [2, 3, 5], [3, 4, 5]);
|
|
* // => [1, 4, 5]
|
|
*/
|
|
function xor() {
|
|
var index = -1,
|
|
length = arguments.length;
|
|
|
|
while (++index < length) {
|
|
var array = arguments[index];
|
|
if (isArray(array) || isArguments(array)) {
|
|
var result = result
|
|
? baseUniq(baseDifference(result, array).concat(baseDifference(array, result)))
|
|
: array;
|
|
}
|
|
}
|
|
return result || [];
|
|
}
|
|
|
|
/**
|
|
* Creates an array of grouped elements, the first of which contains the first
|
|
* elements of the given arrays, the second of which contains the second
|
|
* elements of the given arrays, and so on.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias unzip
|
|
* @category Arrays
|
|
* @param {...Array} [array] Arrays to process.
|
|
* @returns {Array} Returns a new array of grouped elements.
|
|
* @example
|
|
*
|
|
* _.zip(['fred', 'barney'], [30, 40], [true, false]);
|
|
* // => [['fred', 30, true], ['barney', 40, false]]
|
|
*/
|
|
function zip() {
|
|
var array = arguments.length > 1 ? arguments : arguments[0],
|
|
index = -1,
|
|
length = array ? max(pluck(array, 'length')) : 0,
|
|
result = Array(length < 0 ? 0 : length);
|
|
|
|
while (++index < length) {
|
|
result[index] = pluck(array, index);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Creates an object composed from arrays of `keys` and `values`. Provide
|
|
* either a single two dimensional array, i.e. `[[key1, value1], [key2, value2]]`
|
|
* or two arrays, one of `keys` and one of corresponding `values`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @alias object
|
|
* @category Arrays
|
|
* @param {Array} keys The array of keys.
|
|
* @param {Array} [values=[]] The array of values.
|
|
* @returns {Object} Returns an object composed of the given keys and
|
|
* corresponding values.
|
|
* @example
|
|
*
|
|
* _.zipObject(['fred', 'barney'], [30, 40]);
|
|
* // => { 'fred': 30, 'barney': 40 }
|
|
*/
|
|
function zipObject(keys, values) {
|
|
var index = -1,
|
|
length = keys ? keys.length : 0,
|
|
result = {};
|
|
|
|
if (!values && length && !isArray(keys[0])) {
|
|
values = [];
|
|
}
|
|
while (++index < length) {
|
|
var key = keys[index];
|
|
if (values) {
|
|
result[key] = values[index];
|
|
} else if (key) {
|
|
result[key[0]] = key[1];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a function that executes `func`, with the `this` binding and
|
|
* arguments of the created function, only after being called `n` times.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {number} n The number of times the function must be called before
|
|
* `func` is executed.
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* var saves = ['profile', 'settings'];
|
|
*
|
|
* var done = _.after(saves.length, function() {
|
|
* console.log('Done saving!');
|
|
* });
|
|
*
|
|
* _.forEach(saves, function(type) {
|
|
* asyncSave({ 'type': type, 'complete': done });
|
|
* });
|
|
* // => logs 'Done saving!', after all saves have completed
|
|
*/
|
|
function after(n, func) {
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
return function() {
|
|
if (--n < 1) {
|
|
return func.apply(this, arguments);
|
|
}
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that, when called, invokes `func` with the `this`
|
|
* binding of `thisArg` and prepends any additional `bind` arguments to those
|
|
* provided to the bound function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to bind.
|
|
* @param {*} [thisArg] The `this` binding of `func`.
|
|
* @param {...*} [arg] Arguments to be partially applied.
|
|
* @returns {Function} Returns the new bound function.
|
|
* @example
|
|
*
|
|
* var func = function(greeting) {
|
|
* return greeting + ' ' + this.name;
|
|
* };
|
|
*
|
|
* func = _.bind(func, { 'name': 'fred' }, 'hi');
|
|
* func();
|
|
* // => 'hi fred'
|
|
*/
|
|
function bind(func, thisArg) {
|
|
return arguments.length > 2
|
|
? createWrapper(func, 17, slice(arguments, 2), null, thisArg)
|
|
: createWrapper(func, 1, null, null, thisArg);
|
|
}
|
|
|
|
/**
|
|
* Binds methods of an object to the object itself, overwriting the existing
|
|
* method. Method names may be specified as individual arguments or as arrays
|
|
* of method names. If no method names are provided all the function properties
|
|
* of `object` will be bound.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Object} object The object to bind and assign the bound methods to.
|
|
* @param {...string} [methodName] The object method names to
|
|
* bind, specified as individual method names or arrays of method names.
|
|
* @returns {Object} Returns `object`.
|
|
* @example
|
|
*
|
|
* var view = {
|
|
* 'label': 'docs',
|
|
* 'onClick': function() { console.log('clicked ' + this.label); }
|
|
* };
|
|
*
|
|
* _.bindAll(view);
|
|
* jQuery('#docs').on('click', view.onClick);
|
|
* // => logs 'clicked docs', when the button is clicked
|
|
*/
|
|
function bindAll(object) {
|
|
var funcs = arguments.length > 1 ? baseFlatten(arguments, true, false, 1) : functions(object),
|
|
index = -1,
|
|
length = funcs.length;
|
|
|
|
while (++index < length) {
|
|
var key = funcs[index];
|
|
object[key] = createWrapper(object[key], 1, null, null, object);
|
|
}
|
|
return object;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that, when called, invokes the method at `object[key]`
|
|
* and prepends any additional `bindKey` arguments to those provided to the bound
|
|
* function. This method differs from `_.bind` by allowing bound functions to
|
|
* reference methods that will be redefined or don't yet exist.
|
|
* See http://michaux.ca/articles/lazy-function-definition-pattern.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Object} object The object the method belongs to.
|
|
* @param {string} key The key of the method.
|
|
* @param {...*} [arg] Arguments to be partially applied.
|
|
* @returns {Function} Returns the new bound function.
|
|
* @example
|
|
*
|
|
* var object = {
|
|
* 'name': 'fred',
|
|
* 'greet': function(greeting) {
|
|
* return greeting + ' ' + this.name;
|
|
* }
|
|
* };
|
|
*
|
|
* var func = _.bindKey(object, 'greet', 'hi');
|
|
* func();
|
|
* // => 'hi fred'
|
|
*
|
|
* object.greet = function(greeting) {
|
|
* return greeting + 'ya ' + this.name + '!';
|
|
* };
|
|
*
|
|
* func();
|
|
* // => 'hiya fred!'
|
|
*/
|
|
function bindKey(object, key) {
|
|
return arguments.length > 2
|
|
? createWrapper(key, 19, slice(arguments, 2), null, object)
|
|
: createWrapper(key, 3, null, null, object);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that is the composition of the provided functions,
|
|
* where each function consumes the return value of the function that follows.
|
|
* For example, composing the functions `f()`, `g()`, and `h()` produces `f(g(h()))`.
|
|
* Each function is executed with the `this` binding of the composed function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {...Function} [func] Functions to compose.
|
|
* @returns {Function} Returns the new composed function.
|
|
* @example
|
|
*
|
|
* var realNameMap = {
|
|
* 'pebbles': 'penelope'
|
|
* };
|
|
*
|
|
* var format = function(name) {
|
|
* name = realNameMap[name.toLowerCase()] || name;
|
|
* return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
|
* };
|
|
*
|
|
* var greet = function(formatted) {
|
|
* return 'Hiya ' + formatted + '!';
|
|
* };
|
|
*
|
|
* var welcome = _.compose(greet, format);
|
|
* welcome('pebbles');
|
|
* // => 'Hiya Penelope!'
|
|
*/
|
|
function compose() {
|
|
var funcs = arguments,
|
|
length = funcs.length;
|
|
|
|
while (length--) {
|
|
if (!isFunction(funcs[length])) {
|
|
throw new TypeError;
|
|
}
|
|
}
|
|
return function() {
|
|
var args = arguments,
|
|
length = funcs.length;
|
|
|
|
while (length--) {
|
|
args = [funcs[length].apply(this, args)];
|
|
}
|
|
return args[0];
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function which accepts one or more arguments of `func` that when
|
|
* invoked either executes `func` returning its result, if all `func` arguments
|
|
* have been provided, or returns a function that accepts one or more of the
|
|
* remaining `func` arguments, and so on. The arity of `func` can be specified
|
|
* if `func.length` is not sufficient.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to curry.
|
|
* @param {number} [arity=func.length] The arity of `func`.
|
|
* @returns {Function} Returns the new curried function.
|
|
* @example
|
|
*
|
|
* var curried = _.curry(function(a, b, c) {
|
|
* console.log(a + b + c);
|
|
* });
|
|
*
|
|
* curried(1)(2)(3);
|
|
* // => 6
|
|
*
|
|
* curried(1, 2)(3);
|
|
* // => 6
|
|
*
|
|
* curried(1, 2, 3);
|
|
* // => 6
|
|
*/
|
|
function curry(func, arity) {
|
|
arity = typeof arity == 'number' ? arity : (+arity || func.length);
|
|
return createWrapper(func, 4, null, null, null, arity);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that will delay the execution of `func` until after
|
|
* `wait` milliseconds have elapsed since the last time it was invoked.
|
|
* Provide an options object to indicate that `func` should be invoked on
|
|
* the leading and/or trailing edge of the `wait` timeout. Subsequent calls
|
|
* to the debounced function will return the result of the last `func` call.
|
|
*
|
|
* Note: If `leading` and `trailing` options are `true` `func` will be called
|
|
* on the trailing edge of the timeout only if the the debounced function is
|
|
* invoked more than once during the `wait` timeout.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to debounce.
|
|
* @param {number} wait The number of milliseconds to delay.
|
|
* @param {Object} [options] The options object.
|
|
* @param {boolean} [options.leading=false] Specify execution on the leading edge of the timeout.
|
|
* @param {number} [options.maxWait] The maximum time `func` is allowed to be delayed before it's called.
|
|
* @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout.
|
|
* @returns {Function} Returns the new debounced function.
|
|
* @example
|
|
*
|
|
* // avoid costly calculations while the window size is in flux
|
|
* var lazyLayout = _.debounce(calculateLayout, 150);
|
|
* jQuery(window).on('resize', lazyLayout);
|
|
*
|
|
* // execute `sendMail` when the click event is fired, debouncing subsequent calls
|
|
* jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
|
|
* 'leading': true,
|
|
* 'trailing': false
|
|
* });
|
|
*
|
|
* // ensure `batchLog` is executed once after 1 second of debounced calls
|
|
* var source = new EventSource('/stream');
|
|
* source.addEventListener('message', _.debounce(batchLog, 250, {
|
|
* 'maxWait': 1000
|
|
* }, false);
|
|
*/
|
|
function debounce(func, wait, options) {
|
|
var args,
|
|
maxTimeoutId,
|
|
result,
|
|
stamp,
|
|
thisArg,
|
|
timeoutId,
|
|
trailingCall,
|
|
lastCalled = 0,
|
|
maxWait = false,
|
|
trailing = true;
|
|
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
wait = nativeMax(0, wait) || 0;
|
|
if (options === true) {
|
|
var leading = true;
|
|
trailing = false;
|
|
} else if (isObject(options)) {
|
|
leading = options.leading;
|
|
maxWait = 'maxWait' in options && (nativeMax(wait, options.maxWait) || 0);
|
|
trailing = 'trailing' in options ? options.trailing : trailing;
|
|
}
|
|
var delayed = function() {
|
|
var remaining = wait - (now() - stamp);
|
|
if (remaining <= 0) {
|
|
if (maxTimeoutId) {
|
|
clearTimeout(maxTimeoutId);
|
|
}
|
|
var isCalled = trailingCall;
|
|
maxTimeoutId = timeoutId = trailingCall = undefined;
|
|
if (isCalled) {
|
|
lastCalled = now();
|
|
result = func.apply(thisArg, args);
|
|
if (!timeoutId && !maxTimeoutId) {
|
|
args = thisArg = null;
|
|
}
|
|
}
|
|
} else {
|
|
timeoutId = setTimeout(delayed, remaining);
|
|
}
|
|
};
|
|
|
|
var maxDelayed = function() {
|
|
if (timeoutId) {
|
|
clearTimeout(timeoutId);
|
|
}
|
|
maxTimeoutId = timeoutId = trailingCall = undefined;
|
|
if (trailing || (maxWait !== wait)) {
|
|
lastCalled = now();
|
|
result = func.apply(thisArg, args);
|
|
if (!timeoutId && !maxTimeoutId) {
|
|
args = thisArg = null;
|
|
}
|
|
}
|
|
};
|
|
|
|
return function() {
|
|
args = arguments;
|
|
stamp = now();
|
|
thisArg = this;
|
|
trailingCall = trailing && (timeoutId || !leading);
|
|
|
|
if (maxWait === false) {
|
|
var leadingCall = leading && !timeoutId;
|
|
} else {
|
|
if (!maxTimeoutId && !leading) {
|
|
lastCalled = stamp;
|
|
}
|
|
var remaining = maxWait - (stamp - lastCalled),
|
|
isCalled = remaining <= 0;
|
|
|
|
if (isCalled) {
|
|
if (maxTimeoutId) {
|
|
maxTimeoutId = clearTimeout(maxTimeoutId);
|
|
}
|
|
lastCalled = stamp;
|
|
result = func.apply(thisArg, args);
|
|
}
|
|
else if (!maxTimeoutId) {
|
|
maxTimeoutId = setTimeout(maxDelayed, remaining);
|
|
}
|
|
}
|
|
if (isCalled && timeoutId) {
|
|
timeoutId = clearTimeout(timeoutId);
|
|
}
|
|
else if (!timeoutId && wait !== maxWait) {
|
|
timeoutId = setTimeout(delayed, wait);
|
|
}
|
|
if (leadingCall) {
|
|
isCalled = true;
|
|
result = func.apply(thisArg, args);
|
|
}
|
|
if (isCalled && !timeoutId && !maxTimeoutId) {
|
|
args = thisArg = null;
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Defers executing the `func` function until the current call stack has cleared.
|
|
* Additional arguments will be provided to `func` when it is invoked.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to defer.
|
|
* @param {...*} [arg] Arguments to invoke the function with.
|
|
* @returns {number} Returns the timer id.
|
|
* @example
|
|
*
|
|
* _.defer(function(text) { console.log(text); }, 'deferred');
|
|
* // logs 'deferred' after one or more milliseconds
|
|
*/
|
|
function defer(func) {
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
var args = slice(arguments, 1);
|
|
return setTimeout(function() { func.apply(undefined, args); }, 1);
|
|
}
|
|
|
|
/**
|
|
* Executes the `func` function after `wait` milliseconds. Additional arguments
|
|
* will be provided to `func` when it is invoked.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to delay.
|
|
* @param {number} wait The number of milliseconds to delay execution.
|
|
* @param {...*} [arg] Arguments to invoke the function with.
|
|
* @returns {number} Returns the timer id.
|
|
* @example
|
|
*
|
|
* _.delay(function(text) { console.log(text); }, 1000, 'later');
|
|
* // => logs 'later' after one second
|
|
*/
|
|
function delay(func, wait) {
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
var args = slice(arguments, 2);
|
|
return setTimeout(function() { func.apply(undefined, args); }, wait);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that memoizes the result of `func`. If `resolver` is
|
|
* provided it will be used to determine the cache key for storing the result
|
|
* based on the arguments provided to the memoized function. By default, the
|
|
* first argument provided to the memoized function is used as the cache key.
|
|
* The `func` is executed with the `this` binding of the memoized function.
|
|
* The result cache is exposed as the `cache` property on the memoized function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to have its output memoized.
|
|
* @param {Function} [resolver] A function used to resolve the cache key.
|
|
* @returns {Function} Returns the new memoizing function.
|
|
* @example
|
|
*
|
|
* var fibonacci = _.memoize(function(n) {
|
|
* return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2);
|
|
* });
|
|
*
|
|
* fibonacci(9)
|
|
* // => 34
|
|
*
|
|
* var data = {
|
|
* 'fred': { 'name': 'fred', 'age': 40 },
|
|
* 'pebbles': { 'name': 'pebbles', 'age': 1 }
|
|
* };
|
|
*
|
|
* // modifying the result cache
|
|
* var get = _.memoize(function(name) { return data[name]; }, _.identity);
|
|
* get('pebbles');
|
|
* // => { 'name': 'pebbles', 'age': 1 }
|
|
*
|
|
* get.cache.pebbles.name = 'penelope';
|
|
* get('pebbles');
|
|
* // => { 'name': 'penelope', 'age': 1 }
|
|
*/
|
|
function memoize(func, resolver) {
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
var memoized = function() {
|
|
var cache = memoized.cache,
|
|
key = resolver ? resolver.apply(this, arguments) : keyPrefix + arguments[0];
|
|
|
|
return hasOwnProperty.call(cache, key)
|
|
? cache[key]
|
|
: (cache[key] = func.apply(this, arguments));
|
|
}
|
|
memoized.cache = {};
|
|
return memoized;
|
|
}
|
|
|
|
/**
|
|
* Creates a function that is restricted to execute `func` once. Repeat calls to
|
|
* the function will return the value of the first call. The `func` is executed
|
|
* with the `this` binding of the created function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to restrict.
|
|
* @returns {Function} Returns the new restricted function.
|
|
* @example
|
|
*
|
|
* var initialize = _.once(createApplication);
|
|
* initialize();
|
|
* initialize();
|
|
* // `initialize` executes `createApplication` once
|
|
*/
|
|
function once(func) {
|
|
var ran,
|
|
result;
|
|
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
return function() {
|
|
if (ran) {
|
|
return result;
|
|
}
|
|
ran = true;
|
|
result = func.apply(this, arguments);
|
|
|
|
// clear the `func` variable so the function may be garbage collected
|
|
func = null;
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Creates a function that, when called, invokes `func` with any additional
|
|
* `partial` arguments prepended to those provided to the new function. This
|
|
* method is similar to `_.bind` except it does **not** alter the `this` binding.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to partially apply arguments to.
|
|
* @param {...*} [arg] Arguments to be partially applied.
|
|
* @returns {Function} Returns the new partially applied function.
|
|
* @example
|
|
*
|
|
* var greet = function(greeting, name) { return greeting + ' ' + name; };
|
|
* var hi = _.partial(greet, 'hi');
|
|
* hi('fred');
|
|
* // => 'hi fred'
|
|
*/
|
|
function partial(func) {
|
|
return createWrapper(func, 16, slice(arguments, 1));
|
|
}
|
|
|
|
/**
|
|
* This method is like `_.partial` except that `partial` arguments are
|
|
* appended to those provided to the new function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to partially apply arguments to.
|
|
* @param {...*} [arg] Arguments to be partially applied.
|
|
* @returns {Function} Returns the new partially applied function.
|
|
* @example
|
|
*
|
|
* var defaultsDeep = _.partialRight(_.merge, _.defaults);
|
|
*
|
|
* var options = {
|
|
* 'variable': 'data',
|
|
* 'imports': { 'jq': $ }
|
|
* };
|
|
*
|
|
* defaultsDeep(options, _.templateSettings);
|
|
*
|
|
* options.variable
|
|
* // => 'data'
|
|
*
|
|
* options.imports
|
|
* // => { '_': _, 'jq': $ }
|
|
*/
|
|
function partialRight(func) {
|
|
return createWrapper(func, 32, null, slice(arguments, 1));
|
|
}
|
|
|
|
/**
|
|
* Creates a function that, when executed, will only call the `func` function
|
|
* at most once per every `wait` milliseconds. Provide an options object to
|
|
* indicate that `func` should be invoked on the leading and/or trailing edge
|
|
* of the `wait` timeout. Subsequent calls to the throttled function will
|
|
* return the result of the last `func` call.
|
|
*
|
|
* Note: If `leading` and `trailing` options are `true` `func` will be called
|
|
* on the trailing edge of the timeout only if the the throttled function is
|
|
* invoked more than once during the `wait` timeout.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {Function} func The function to throttle.
|
|
* @param {number} wait The number of milliseconds to throttle executions to.
|
|
* @param {Object} [options] The options object.
|
|
* @param {boolean} [options.leading=true] Specify execution on the leading edge of the timeout.
|
|
* @param {boolean} [options.trailing=true] Specify execution on the trailing edge of the timeout.
|
|
* @returns {Function} Returns the new throttled function.
|
|
* @example
|
|
*
|
|
* // avoid excessively updating the position while scrolling
|
|
* var throttled = _.throttle(updatePosition, 100);
|
|
* jQuery(window).on('scroll', throttled);
|
|
*
|
|
* // execute `renewToken` when the click event is fired, but not more than once every 5 minutes
|
|
* jQuery('.interactive').on('click', _.throttle(renewToken, 300000, {
|
|
* 'trailing': false
|
|
* }));
|
|
*/
|
|
function throttle(func, wait, options) {
|
|
var leading = true,
|
|
trailing = true;
|
|
|
|
if (!isFunction(func)) {
|
|
throw new TypeError;
|
|
}
|
|
if (options === false) {
|
|
leading = false;
|
|
} else if (isObject(options)) {
|
|
leading = 'leading' in options ? options.leading : leading;
|
|
trailing = 'trailing' in options ? options.trailing : trailing;
|
|
}
|
|
debounceOptions.leading = leading;
|
|
debounceOptions.maxWait = wait;
|
|
debounceOptions.trailing = trailing;
|
|
|
|
return debounce(func, wait, debounceOptions);
|
|
}
|
|
|
|
/**
|
|
* Creates a function that provides `value` to the wrapper function as its
|
|
* first argument. Additional arguments provided to the function are appended
|
|
* to those provided to the wrapper function. The wrapper is executed with
|
|
* the `this` binding of the created function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Functions
|
|
* @param {*} value The value to wrap.
|
|
* @param {Function} wrapper The wrapper function.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var p = _.wrap(_.escape, function(func, text) {
|
|
* return '<p>' + func(text) + '</p>';
|
|
* });
|
|
*
|
|
* p('Fred, Wilma, & Pebbles');
|
|
* // => '<p>Fred, Wilma, & Pebbles</p>'
|
|
*/
|
|
function wrap(value, wrapper) {
|
|
return createWrapper(wrapper, 16, [value]);
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a function that returns `value`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {*} value The value to return from the new function.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var object = { 'name': 'fred' };
|
|
* var getter = _.constant(object);
|
|
* getter() === object;
|
|
* // => true
|
|
*/
|
|
function constant(value) {
|
|
return function() {
|
|
return value;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Produces a callback bound to an optional `thisArg`. If `func` is a property
|
|
* name the created callback will return the property value for a given element.
|
|
* If `func` is an object the created callback will return `true` for elements
|
|
* that contain the equivalent object properties, otherwise it will return `false`.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {*} [func=identity] The value to convert to a callback.
|
|
* @param {*} [thisArg] The `this` binding of the created callback.
|
|
* @param {number} [argCount] The number of arguments the callback accepts.
|
|
* @returns {Function} Returns a callback function.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* // wrap to create custom callback shorthands
|
|
* _.createCallback = _.wrap(_.createCallback, function(func, callback, thisArg) {
|
|
* var match = /^(.+?)__([gl]t)(.+)$/.exec(callback);
|
|
* return !match ? func(callback, thisArg) : function(object) {
|
|
* return match[2] == 'gt' ? object[match[1]] > match[3] : object[match[1]] < match[3];
|
|
* };
|
|
* });
|
|
*
|
|
* _.filter(characters, 'age__gt38');
|
|
* // => [{ 'name': 'fred', 'age': 40 }]
|
|
*/
|
|
function createCallback(func, thisArg, argCount) {
|
|
var type = typeof func;
|
|
if (func == null || type == 'function') {
|
|
return baseCreateCallback(func, thisArg, argCount);
|
|
}
|
|
// handle "_.pluck" style callback shorthands
|
|
if (type != 'object') {
|
|
return property(func);
|
|
}
|
|
var props = keys(func),
|
|
key = props[0],
|
|
a = func[key];
|
|
|
|
// handle "_.where" style callback shorthands
|
|
if (props.length == 1 && a === a && !isObject(a)) {
|
|
// fast path the common case of providing an object with a single
|
|
// property containing a primitive value
|
|
return function(object) {
|
|
var b = object[key];
|
|
return a === b && (a !== 0 || (1 / a == 1 / b));
|
|
};
|
|
}
|
|
return function(object) {
|
|
var length = props.length,
|
|
result = false;
|
|
|
|
while (length--) {
|
|
if (!(result = baseIsEqual(object[props[length]], func[props[length]], null, true))) {
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Converts the characters `&`, `<`, `>`, `"`, and `'` in `string` to their
|
|
* corresponding HTML entities.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {string} string The string to escape.
|
|
* @returns {string} Returns the escaped string.
|
|
* @example
|
|
*
|
|
* _.escape('Fred, Wilma, & Pebbles');
|
|
* // => 'Fred, Wilma, & Pebbles'
|
|
*/
|
|
function escape(string) {
|
|
return string == null ? '' : String(string).replace(reUnescapedHtml, escapeHtmlChar);
|
|
}
|
|
|
|
/**
|
|
* This method returns the first argument provided to it.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {*} value Any value.
|
|
* @returns {*} Returns `value`.
|
|
* @example
|
|
*
|
|
* var object = { 'name': 'fred' };
|
|
* _.identity(object) === object;
|
|
* // => true
|
|
*/
|
|
function identity(value) {
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* Adds function properties of a source object to the destination object.
|
|
* If `object` is a function methods will be added to its prototype as well.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {Function|Object} [object=lodash] object The destination object.
|
|
* @param {Object} source The object of functions to add.
|
|
* @param {Object} [options] The options object.
|
|
* @param {boolean} [options.chain=true] Specify whether the functions added are chainable.
|
|
* @example
|
|
*
|
|
* function capitalize(string) {
|
|
* return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase();
|
|
* }
|
|
*
|
|
* _.mixin({ 'capitalize': capitalize });
|
|
* _.capitalize('fred');
|
|
* // => 'Fred'
|
|
*
|
|
* _('fred').capitalize().value();
|
|
* // => 'Fred'
|
|
*
|
|
* _.mixin({ 'capitalize': capitalize }, { 'chain': false });
|
|
* _('fred').capitalize();
|
|
* // => 'Fred'
|
|
*/
|
|
function mixin(object, source, options) {
|
|
var chain = true,
|
|
methodNames = source && functions(source);
|
|
|
|
if (!source || (!options && !methodNames.length)) {
|
|
if (options == null) {
|
|
options = source;
|
|
}
|
|
ctor = lodashWrapper;
|
|
source = object;
|
|
object = lodash;
|
|
methodNames = functions(source);
|
|
}
|
|
if (options === false) {
|
|
chain = false;
|
|
} else if (isObject(options) && 'chain' in options) {
|
|
chain = options.chain;
|
|
}
|
|
var ctor = object,
|
|
isFunc = isFunction(ctor);
|
|
|
|
forEach(methodNames, function(methodName) {
|
|
var func = object[methodName] = source[methodName];
|
|
if (isFunc) {
|
|
ctor.prototype[methodName] = function() {
|
|
var chainAll = this.__chain__,
|
|
value = this.__wrapped__,
|
|
args = [value];
|
|
|
|
push.apply(args, arguments);
|
|
var result = func.apply(object, args);
|
|
if (chain || chainAll) {
|
|
if (value === result && isObject(result)) {
|
|
return this;
|
|
}
|
|
result = new ctor(result);
|
|
result.__chain__ = chainAll;
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverts the '_' variable to its previous value and returns a reference to
|
|
* the `lodash` function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @returns {Function} Returns the `lodash` function.
|
|
* @example
|
|
*
|
|
* var lodash = _.noConflict();
|
|
*/
|
|
function noConflict() {
|
|
context._ = oldDash;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* A no-operation function.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @example
|
|
*
|
|
* var object = { 'name': 'fred' };
|
|
* _.noop(object) === undefined;
|
|
* // => true
|
|
*/
|
|
function noop() {
|
|
// no operation performed
|
|
}
|
|
|
|
/**
|
|
* Gets the number of milliseconds that have elapsed since the Unix epoch
|
|
* (1 January 1970 00:00:00 UTC).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @example
|
|
*
|
|
* var stamp = _.now();
|
|
* _.defer(function() { console.log(_.now() - stamp); });
|
|
* // => logs the number of milliseconds it took for the deferred function to be called
|
|
*/
|
|
var now = isNative(now = Date.now) && now || function() {
|
|
return new Date().getTime();
|
|
};
|
|
|
|
/**
|
|
* Converts the given value into an integer of the specified radix.
|
|
* If `radix` is `undefined` or `0` a `radix` of `10` is used unless the
|
|
* `value` is a hexadecimal, in which case a `radix` of `16` is used.
|
|
*
|
|
* Note: This method avoids differences in native ES3 and ES5 `parseInt`
|
|
* implementations. See http://es5.github.io/#E.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {string} value The value to parse.
|
|
* @param {number} [radix] The radix used to interpret the value to parse.
|
|
* @returns {number} Returns the new integer value.
|
|
* @example
|
|
*
|
|
* _.parseInt('08');
|
|
* // => 8
|
|
*/
|
|
var parseInt = nativeParseInt(whitespace + '08') == 8 ? nativeParseInt : function(value, radix) {
|
|
// Firefox < 21 and Opera < 15 follow the ES3 specified implementation of `parseInt`
|
|
return nativeParseInt(isString(value) ? value.replace(reLeadingSpacesAndZeros, '') : value, radix || 0);
|
|
};
|
|
|
|
/**
|
|
* Creates a "_.pluck" style function, which returns the `key` value of a
|
|
* given object.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {string} key The name of the property to retrieve.
|
|
* @returns {Function} Returns the new function.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'fred', 'age': 40 },
|
|
* { 'name': 'barney', 'age': 36 }
|
|
* ];
|
|
*
|
|
* var getName = _.property('name');
|
|
*
|
|
* _.map(characters, getName);
|
|
* // => ['barney', 'fred']
|
|
*
|
|
* _.sortBy(characters, getName);
|
|
* // => [{ 'name': 'barney', 'age': 36 }, { 'name': 'fred', 'age': 40 }]
|
|
*/
|
|
function property(key) {
|
|
return function(object) {
|
|
return object[key];
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Produces a random number between `min` and `max` (inclusive). If only one
|
|
* argument is provided a number between `0` and the given number will be
|
|
* returned. If `floating` is truey or either `min` or `max` are floats a
|
|
* floating-point number will be returned instead of an integer.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {number} [min=0] The minimum possible value.
|
|
* @param {number} [max=1] The maximum possible value.
|
|
* @param {boolean} [floating=false] Specify returning a floating-point number.
|
|
* @returns {number} Returns a random number.
|
|
* @example
|
|
*
|
|
* _.random(0, 5);
|
|
* // => an integer between 0 and 5
|
|
*
|
|
* _.random(5);
|
|
* // => also an integer between 0 and 5
|
|
*
|
|
* _.random(5, true);
|
|
* // => a floating-point number between 0 and 5
|
|
*
|
|
* _.random(1.2, 5.2);
|
|
* // => a floating-point number between 1.2 and 5.2
|
|
*/
|
|
function random(min, max, floating) {
|
|
var noMin = min == null,
|
|
noMax = max == null;
|
|
|
|
if (floating == null) {
|
|
if (typeof min == 'boolean' && noMax) {
|
|
floating = min;
|
|
min = 1;
|
|
}
|
|
else if (!noMax && typeof max == 'boolean') {
|
|
floating = max;
|
|
noMax = true;
|
|
}
|
|
}
|
|
if (noMin && noMax) {
|
|
max = 1;
|
|
}
|
|
min = +min || 0;
|
|
if (noMax) {
|
|
max = min;
|
|
min = 0;
|
|
} else {
|
|
max = +max || 0;
|
|
}
|
|
if (floating || min % 1 || max % 1) {
|
|
var rand = nativeRandom();
|
|
return nativeMin(min + (rand * (max - min + parseFloat('1e-' + ((rand +'').length - 1)))), max);
|
|
}
|
|
return baseRandom(min, max);
|
|
}
|
|
|
|
/**
|
|
* Resolves the value of property `key` on `object`. If `key` is a function
|
|
* it will be invoked with the `this` binding of `object` and its result returned,
|
|
* else the property value is returned. If `object` is falsey then `undefined`
|
|
* is returned.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {Object} object The object to inspect.
|
|
* @param {string} key The name of the property to resolve.
|
|
* @returns {*} Returns the resolved value.
|
|
* @example
|
|
*
|
|
* var object = {
|
|
* 'cheese': 'crumpets',
|
|
* 'stuff': function() {
|
|
* return 'nonsense';
|
|
* }
|
|
* };
|
|
*
|
|
* _.result(object, 'cheese');
|
|
* // => 'crumpets'
|
|
*
|
|
* _.result(object, 'stuff');
|
|
* // => 'nonsense'
|
|
*/
|
|
function result(object, key) {
|
|
if (object) {
|
|
var value = object[key];
|
|
return isFunction(value) ? object[key]() : value;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* A micro-templating method that handles arbitrary delimiters, preserves
|
|
* whitespace, and correctly escapes quotes within interpolated code.
|
|
*
|
|
* Note: In the development build, `_.template` utilizes sourceURLs for easier
|
|
* debugging. See http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
|
*
|
|
* For more information on precompiling templates see:
|
|
* https://lodash.com/custom-builds
|
|
*
|
|
* For more information on Chrome extension sandboxes see:
|
|
* http://developer.chrome.com/stable/extensions/sandboxingEval.html
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {string} text The template text.
|
|
* @param {Object} data The data object used to populate the text.
|
|
* @param {Object} [options] The options object.
|
|
* @param {RegExp} [options.escape] The "escape" delimiter.
|
|
* @param {RegExp} [options.evaluate] The "evaluate" delimiter.
|
|
* @param {Object} [options.imports] An object to import into the template as local variables.
|
|
* @param {RegExp} [options.interpolate] The "interpolate" delimiter.
|
|
* @param {string} [sourceURL] The sourceURL of the template's compiled source.
|
|
* @param {string} [variable] The data object variable name.
|
|
* @returns {Function|string} Returns a compiled function when no `data` object
|
|
* is given, else it returns the interpolated text.
|
|
* @example
|
|
*
|
|
* // using the "interpolate" delimiter to create a compiled template
|
|
* var compiled = _.template('hello <%= name %>');
|
|
* compiled({ 'name': 'fred' });
|
|
* // => 'hello fred'
|
|
*
|
|
* // using the "escape" delimiter to escape HTML in data property values
|
|
* _.template('<b><%- value %></b>', { 'value': '<script>' });
|
|
* // => '<b><script></b>'
|
|
*
|
|
* // using the "evaluate" delimiter to generate HTML
|
|
* var list = '<% _.forEach(people, function(name) { %><li><%- name %></li><% }); %>';
|
|
* _.template(list, { 'people': ['fred', 'barney'] });
|
|
* // => '<li>fred</li><li>barney</li>'
|
|
*
|
|
* // using the ES6 delimiter as an alternative to the default "interpolate" delimiter
|
|
* _.template('hello ${ name }', { 'name': 'pebbles' });
|
|
* // => 'hello pebbles'
|
|
*
|
|
* // using the internal `print` function in "evaluate" delimiters
|
|
* _.template('<% print("hello " + name); %>!', { 'name': 'barney' });
|
|
* // => 'hello barney!'
|
|
*
|
|
* // using a custom template delimiters
|
|
* _.templateSettings = {
|
|
* 'interpolate': /{{([\s\S]+?)}}/g
|
|
* };
|
|
*
|
|
* _.template('hello {{ name }}!', { 'name': 'mustache' });
|
|
* // => 'hello mustache!'
|
|
*
|
|
* // using the `imports` option to import jQuery
|
|
* var list = '<% jq.each(people, function(name) { %><li><%- name %></li><% }); %>';
|
|
* _.template(list, { 'people': ['fred', 'barney'] }, { 'imports': { 'jq': jQuery } });
|
|
* // => '<li>fred</li><li>barney</li>'
|
|
*
|
|
* // using the `sourceURL` option to specify a custom sourceURL for the template
|
|
* var compiled = _.template('hello <%= name %>', null, { 'sourceURL': '/basic/greeting.jst' });
|
|
* compiled(data);
|
|
* // => find the source of "greeting.jst" under the Sources tab or Resources panel of the web inspector
|
|
*
|
|
* // using the `variable` option to ensure a with-statement isn't used in the compiled template
|
|
* var compiled = _.template('hi <%= data.name %>!', null, { 'variable': 'data' });
|
|
* compiled.source;
|
|
* // => function(data) {
|
|
* var __t, __p = '', __e = _.escape;
|
|
* __p += 'hi ' + ((__t = ( data.name )) == null ? '' : __t) + '!';
|
|
* return __p;
|
|
* }
|
|
*
|
|
* // using the `source` property to inline compiled templates for meaningful
|
|
* // line numbers in error messages and a stack trace
|
|
* fs.writeFileSync(path.join(cwd, 'jst.js'), '\
|
|
* var JST = {\
|
|
* "main": ' + _.template(mainText).source + '\
|
|
* };\
|
|
* ');
|
|
*/
|
|
function template(text, data, options) {
|
|
// based on John Resig's `tmpl` implementation
|
|
// http://ejohn.org/blog/javascript-micro-templating/
|
|
// and Laura Doktorova's doT.js
|
|
// https://github.com/olado/doT
|
|
var settings = lodash.templateSettings;
|
|
text = String(text || '');
|
|
|
|
// avoid missing dependencies when `iteratorTemplate` is not defined
|
|
options = defaults({}, options, settings);
|
|
|
|
var imports = defaults({}, options.imports, settings.imports),
|
|
importsKeys = keys(imports),
|
|
importsValues = values(imports);
|
|
|
|
var isEvaluating,
|
|
index = 0,
|
|
interpolate = options.interpolate || reNoMatch,
|
|
source = "__p += '";
|
|
|
|
// compile the regexp to match each delimiter
|
|
var reDelimiters = RegExp(
|
|
(options.escape || reNoMatch).source + '|' +
|
|
interpolate.source + '|' +
|
|
(interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + '|' +
|
|
(options.evaluate || reNoMatch).source + '|$'
|
|
, 'g');
|
|
|
|
text.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
|
|
interpolateValue || (interpolateValue = esTemplateValue);
|
|
|
|
// escape characters that cannot be included in string literals
|
|
source += text.slice(index, offset).replace(reUnescapedString, escapeStringChar);
|
|
|
|
// replace delimiters with snippets
|
|
if (escapeValue) {
|
|
source += "' +\n__e(" + escapeValue + ") +\n'";
|
|
}
|
|
if (evaluateValue) {
|
|
isEvaluating = true;
|
|
source += "';\n" + evaluateValue + ";\n__p += '";
|
|
}
|
|
if (interpolateValue) {
|
|
source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
|
|
}
|
|
index = offset + match.length;
|
|
|
|
// the JS engine embedded in Adobe products requires returning the `match`
|
|
// string in order to produce the correct `offset` value
|
|
return match;
|
|
});
|
|
|
|
source += "';\n";
|
|
|
|
// if `variable` is not specified, wrap a with-statement around the generated
|
|
// code to add the data object to the top of the scope chain
|
|
var variable = options.variable,
|
|
hasVariable = variable;
|
|
|
|
if (!hasVariable) {
|
|
variable = 'obj';
|
|
source = 'with (' + variable + ') {\n' + source + '\n}\n';
|
|
}
|
|
// cleanup code by stripping empty strings
|
|
source = (isEvaluating ? source.replace(reEmptyStringLeading, '') : source)
|
|
.replace(reEmptyStringMiddle, '$1')
|
|
.replace(reEmptyStringTrailing, '$1;');
|
|
|
|
// frame code as the function body
|
|
source = 'function(' + variable + ') {\n' +
|
|
(hasVariable ? '' : variable + ' || (' + variable + ' = {});\n') +
|
|
"var __t, __p = '', __e = _.escape" +
|
|
(isEvaluating
|
|
? ', __j = Array.prototype.join;\n' +
|
|
"function print() { __p += __j.call(arguments, '') }\n"
|
|
: ';\n'
|
|
) +
|
|
source +
|
|
'return __p\n}';
|
|
|
|
// Use a sourceURL for easier debugging.
|
|
// http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/#toc-sourceurl
|
|
var sourceURL = '\n/*\n//# sourceURL=' + (options.sourceURL || '/lodash/template/source[' + (templateCounter++) + ']') + '\n*/';
|
|
|
|
try {
|
|
var result = Function(importsKeys, 'return ' + source + sourceURL).apply(undefined, importsValues);
|
|
} catch(e) {
|
|
e.source = source;
|
|
throw e;
|
|
}
|
|
if (data) {
|
|
return result(data);
|
|
}
|
|
// provide the compiled function's source by its `toString` method, in
|
|
// supported environments, or the `source` property as a convenience for
|
|
// inlining compiled templates during the build process
|
|
result.source = source;
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Executes the callback `n` times, returning an array of the results
|
|
* of each callback execution. The callback is bound to `thisArg` and invoked
|
|
* with one argument; (index).
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {number} n The number of times to execute the callback.
|
|
* @param {Function} callback The function called per iteration.
|
|
* @param {*} [thisArg] The `this` binding of `callback`.
|
|
* @returns {Array} Returns an array of the results of each `callback` execution.
|
|
* @example
|
|
*
|
|
* var diceRolls = _.times(3, _.partial(_.random, 1, 6));
|
|
* // => [3, 6, 4]
|
|
*
|
|
* _.times(3, function(n) { mage.castSpell(n); });
|
|
* // => calls `mage.castSpell(n)` three times, passing `n` of `0`, `1`, and `2` respectively
|
|
*
|
|
* _.times(3, function(n) { this.cast(n); }, mage);
|
|
* // => also calls `mage.castSpell(n)` three times
|
|
*/
|
|
function times(n, callback, thisArg) {
|
|
n = (n = +n) > -1 ? n : 0;
|
|
var index = -1,
|
|
result = Array(n);
|
|
|
|
callback = baseCreateCallback(callback, thisArg, 1);
|
|
while (++index < n) {
|
|
result[index] = callback(index);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* The inverse of `_.escape` this method converts the HTML entities
|
|
* `&`, `<`, `>`, `"`, and `'` in `string` to their
|
|
* corresponding characters.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {string} string The string to unescape.
|
|
* @returns {string} Returns the unescaped string.
|
|
* @example
|
|
*
|
|
* _.unescape('Fred, Barney & Pebbles');
|
|
* // => 'Fred, Barney & Pebbles'
|
|
*/
|
|
function unescape(string) {
|
|
return string == null ? '' : String(string).replace(reEscapedHtml, unescapeHtmlChar);
|
|
}
|
|
|
|
/**
|
|
* Generates a unique ID. If `prefix` is provided the ID will be appended to it.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Utilities
|
|
* @param {string} [prefix] The value to prefix the ID with.
|
|
* @returns {string} Returns the unique ID.
|
|
* @example
|
|
*
|
|
* _.uniqueId('contact_');
|
|
* // => 'contact_104'
|
|
*
|
|
* _.uniqueId();
|
|
* // => '105'
|
|
*/
|
|
function uniqueId(prefix) {
|
|
var id = ++idCounter;
|
|
return String(prefix == null ? '' : prefix) + id;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* Creates a `lodash` object that wraps the given value with explicit
|
|
* method chaining enabled.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Chaining
|
|
* @param {*} value The value to wrap.
|
|
* @returns {Object} Returns the wrapper object.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 },
|
|
* { 'name': 'pebbles', 'age': 1 }
|
|
* ];
|
|
*
|
|
* var youngest = _.chain(characters)
|
|
* .sortBy('age')
|
|
* .map(function(chr) { return chr.name + ' is ' + chr.age; })
|
|
* .first()
|
|
* .value();
|
|
* // => 'pebbles is 1'
|
|
*/
|
|
function chain(value) {
|
|
value = new lodashWrapper(value);
|
|
value.__chain__ = true;
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* Invokes `interceptor` with the `value` as the first argument and then
|
|
* returns `value`. The purpose of this method is to "tap into" a method
|
|
* chain in order to perform operations on intermediate results within
|
|
* the chain.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @category Chaining
|
|
* @param {*} value The value to provide to `interceptor`.
|
|
* @param {Function} interceptor The function to invoke.
|
|
* @returns {*} Returns `value`.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3, 4])
|
|
* .tap(function(array) { array.pop(); })
|
|
* .reverse()
|
|
* .value();
|
|
* // => [3, 2, 1]
|
|
*/
|
|
function tap(value, interceptor) {
|
|
interceptor(value);
|
|
return value;
|
|
}
|
|
|
|
/**
|
|
* Enables explicit method chaining on the wrapper object.
|
|
*
|
|
* @name chain
|
|
* @memberOf _
|
|
* @category Chaining
|
|
* @returns {*} Returns the wrapper object.
|
|
* @example
|
|
*
|
|
* var characters = [
|
|
* { 'name': 'barney', 'age': 36 },
|
|
* { 'name': 'fred', 'age': 40 }
|
|
* ];
|
|
*
|
|
* // without explicit chaining
|
|
* _(characters).first();
|
|
* // => { 'name': 'barney', 'age': 36 }
|
|
*
|
|
* // with explicit chaining
|
|
* _(characters).chain()
|
|
* .first()
|
|
* .pick('age')
|
|
* .value();
|
|
* // => { 'age': 36 }
|
|
*/
|
|
function wrapperChain() {
|
|
this.__chain__ = true;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Produces the `toString` result of the wrapped value.
|
|
*
|
|
* @name toString
|
|
* @memberOf _
|
|
* @category Chaining
|
|
* @returns {string} Returns the string result.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3]).toString();
|
|
* // => '1,2,3'
|
|
*/
|
|
function wrapperToString() {
|
|
return String(this.__wrapped__);
|
|
}
|
|
|
|
/**
|
|
* Extracts the wrapped value.
|
|
*
|
|
* @name valueOf
|
|
* @memberOf _
|
|
* @alias value
|
|
* @category Chaining
|
|
* @returns {*} Returns the wrapped value.
|
|
* @example
|
|
*
|
|
* _([1, 2, 3]).valueOf();
|
|
* // => [1, 2, 3]
|
|
*/
|
|
function wrapperValueOf() {
|
|
return this.__wrapped__;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
// add functions that return wrapped values when chaining
|
|
lodash.after = after;
|
|
lodash.assign = assign;
|
|
lodash.at = at;
|
|
lodash.bind = bind;
|
|
lodash.bindAll = bindAll;
|
|
lodash.bindKey = bindKey;
|
|
lodash.chain = chain;
|
|
lodash.compact = compact;
|
|
lodash.compose = compose;
|
|
lodash.constant = constant;
|
|
lodash.countBy = countBy;
|
|
lodash.create = create;
|
|
lodash.createCallback = createCallback;
|
|
lodash.curry = curry;
|
|
lodash.debounce = debounce;
|
|
lodash.defaults = defaults;
|
|
lodash.defer = defer;
|
|
lodash.delay = delay;
|
|
lodash.difference = difference;
|
|
lodash.filter = filter;
|
|
lodash.flatten = flatten;
|
|
lodash.forEach = forEach;
|
|
lodash.forEachRight = forEachRight;
|
|
lodash.forIn = forIn;
|
|
lodash.forInRight = forInRight;
|
|
lodash.forOwn = forOwn;
|
|
lodash.forOwnRight = forOwnRight;
|
|
lodash.functions = functions;
|
|
lodash.groupBy = groupBy;
|
|
lodash.indexBy = indexBy;
|
|
lodash.initial = initial;
|
|
lodash.intersection = intersection;
|
|
lodash.invert = invert;
|
|
lodash.invoke = invoke;
|
|
lodash.keys = keys;
|
|
lodash.map = map;
|
|
lodash.mapValues = mapValues;
|
|
lodash.max = max;
|
|
lodash.memoize = memoize;
|
|
lodash.merge = merge;
|
|
lodash.min = min;
|
|
lodash.omit = omit;
|
|
lodash.once = once;
|
|
lodash.pairs = pairs;
|
|
lodash.partial = partial;
|
|
lodash.partialRight = partialRight;
|
|
lodash.pick = pick;
|
|
lodash.pluck = pluck;
|
|
lodash.property = property;
|
|
lodash.pull = pull;
|
|
lodash.range = range;
|
|
lodash.reject = reject;
|
|
lodash.remove = remove;
|
|
lodash.rest = rest;
|
|
lodash.shuffle = shuffle;
|
|
lodash.sortBy = sortBy;
|
|
lodash.tap = tap;
|
|
lodash.throttle = throttle;
|
|
lodash.times = times;
|
|
lodash.toArray = toArray;
|
|
lodash.transform = transform;
|
|
lodash.union = union;
|
|
lodash.uniq = uniq;
|
|
lodash.values = values;
|
|
lodash.where = where;
|
|
lodash.without = without;
|
|
lodash.wrap = wrap;
|
|
lodash.xor = xor;
|
|
lodash.zip = zip;
|
|
lodash.zipObject = zipObject;
|
|
|
|
// add aliases
|
|
lodash.collect = map;
|
|
lodash.drop = rest;
|
|
lodash.each = forEach;
|
|
lodash.eachRight = forEachRight;
|
|
lodash.extend = assign;
|
|
lodash.methods = functions;
|
|
lodash.object = zipObject;
|
|
lodash.select = filter;
|
|
lodash.tail = rest;
|
|
lodash.unique = uniq;
|
|
lodash.unzip = zip;
|
|
|
|
// add functions to `lodash.prototype`
|
|
mixin(lodash);
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
// add functions that return unwrapped values when chaining
|
|
lodash.clone = clone;
|
|
lodash.cloneDeep = cloneDeep;
|
|
lodash.contains = contains;
|
|
lodash.escape = escape;
|
|
lodash.every = every;
|
|
lodash.find = find;
|
|
lodash.findIndex = findIndex;
|
|
lodash.findKey = findKey;
|
|
lodash.findLast = findLast;
|
|
lodash.findLastIndex = findLastIndex;
|
|
lodash.findLastKey = findLastKey;
|
|
lodash.has = has;
|
|
lodash.identity = identity;
|
|
lodash.indexOf = indexOf;
|
|
lodash.isArguments = isArguments;
|
|
lodash.isArray = isArray;
|
|
lodash.isBoolean = isBoolean;
|
|
lodash.isDate = isDate;
|
|
lodash.isElement = isElement;
|
|
lodash.isEmpty = isEmpty;
|
|
lodash.isEqual = isEqual;
|
|
lodash.isFinite = isFinite;
|
|
lodash.isFunction = isFunction;
|
|
lodash.isNaN = isNaN;
|
|
lodash.isNull = isNull;
|
|
lodash.isNumber = isNumber;
|
|
lodash.isObject = isObject;
|
|
lodash.isPlainObject = isPlainObject;
|
|
lodash.isRegExp = isRegExp;
|
|
lodash.isString = isString;
|
|
lodash.isUndefined = isUndefined;
|
|
lodash.lastIndexOf = lastIndexOf;
|
|
lodash.mixin = mixin;
|
|
lodash.noConflict = noConflict;
|
|
lodash.noop = noop;
|
|
lodash.now = now;
|
|
lodash.parseInt = parseInt;
|
|
lodash.random = random;
|
|
lodash.reduce = reduce;
|
|
lodash.reduceRight = reduceRight;
|
|
lodash.result = result;
|
|
lodash.runInContext = runInContext;
|
|
lodash.size = size;
|
|
lodash.some = some;
|
|
lodash.sortedIndex = sortedIndex;
|
|
lodash.template = template;
|
|
lodash.unescape = unescape;
|
|
lodash.uniqueId = uniqueId;
|
|
|
|
// add aliases
|
|
lodash.all = every;
|
|
lodash.any = some;
|
|
lodash.detect = find;
|
|
lodash.findWhere = find;
|
|
lodash.foldl = reduce;
|
|
lodash.foldr = reduceRight;
|
|
lodash.include = contains;
|
|
lodash.inject = reduce;
|
|
|
|
mixin(function() {
|
|
var source = {}
|
|
forOwn(lodash, function(func, methodName) {
|
|
if (!lodash.prototype[methodName]) {
|
|
source[methodName] = func;
|
|
}
|
|
});
|
|
return source;
|
|
}(), false);
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
// add functions capable of returning wrapped and unwrapped values when chaining
|
|
lodash.first = first;
|
|
lodash.last = last;
|
|
lodash.sample = sample;
|
|
|
|
// add aliases
|
|
lodash.take = first;
|
|
lodash.head = first;
|
|
|
|
forOwn(lodash, function(func, methodName) {
|
|
var callbackable = methodName !== 'sample';
|
|
if (!lodash.prototype[methodName]) {
|
|
lodash.prototype[methodName]= function(n, guard) {
|
|
var chainAll = this.__chain__,
|
|
result = func(this.__wrapped__, n, guard);
|
|
|
|
return !chainAll && (n == null || (guard && !(callbackable && typeof n == 'function')))
|
|
? result
|
|
: new lodashWrapper(result, chainAll);
|
|
};
|
|
}
|
|
});
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/**
|
|
* The semantic version number.
|
|
*
|
|
* @static
|
|
* @memberOf _
|
|
* @type string
|
|
*/
|
|
lodash.VERSION = '2.4.2';
|
|
|
|
// add "Chaining" functions to the wrapper
|
|
lodash.prototype.chain = wrapperChain;
|
|
lodash.prototype.toString = wrapperToString;
|
|
lodash.prototype.value = wrapperValueOf;
|
|
lodash.prototype.valueOf = wrapperValueOf;
|
|
|
|
// add `Array` functions that return unwrapped values
|
|
forEach(['join', 'pop', 'shift'], function(methodName) {
|
|
var func = arrayRef[methodName];
|
|
lodash.prototype[methodName] = function() {
|
|
var chainAll = this.__chain__,
|
|
result = func.apply(this.__wrapped__, arguments);
|
|
|
|
return chainAll
|
|
? new lodashWrapper(result, chainAll)
|
|
: result;
|
|
};
|
|
});
|
|
|
|
// add `Array` functions that return the existing wrapped value
|
|
forEach(['push', 'reverse', 'sort', 'unshift'], function(methodName) {
|
|
var func = arrayRef[methodName];
|
|
lodash.prototype[methodName] = function() {
|
|
func.apply(this.__wrapped__, arguments);
|
|
return this;
|
|
};
|
|
});
|
|
|
|
// add `Array` functions that return new wrapped values
|
|
forEach(['concat', 'slice', 'splice'], function(methodName) {
|
|
var func = arrayRef[methodName];
|
|
lodash.prototype[methodName] = function() {
|
|
return new lodashWrapper(func.apply(this.__wrapped__, arguments), this.__chain__);
|
|
};
|
|
});
|
|
|
|
return lodash;
|
|
}
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
// expose Lo-Dash
|
|
var _ = runInContext();
|
|
|
|
// some AMD build optimizers like r.js check for condition patterns like the following:
|
|
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
|
|
// Expose Lo-Dash to the global object even when an AMD loader is present in
|
|
// case Lo-Dash is loaded with a RequireJS shim config.
|
|
// See http://requirejs.org/docs/api.html#config-shim
|
|
root._ = _;
|
|
|
|
// define as an anonymous module so, through path mapping, it can be
|
|
// referenced as the "underscore" module
|
|
define(function() {
|
|
return _;
|
|
});
|
|
}
|
|
// check for `exports` after `define` in case a build optimizer adds an `exports` object
|
|
else if (freeExports && freeModule) {
|
|
// in Node.js or RingoJS
|
|
if (moduleExports) {
|
|
(freeModule.exports = _)._ = _;
|
|
}
|
|
// in Narwhal or Rhino -require
|
|
else {
|
|
freeExports._ = _;
|
|
}
|
|
}
|
|
else {
|
|
// in a browser or Rhino
|
|
root._ = _;
|
|
}
|
|
}.call(this));
|
|
|
|
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{}],83:[function(require,module,exports){
|
|
//! moment.js
|
|
//! version : 2.10.3
|
|
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
|
//! license : MIT
|
|
//! momentjs.com
|
|
|
|
(function (global, factory) {
|
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
global.moment = factory()
|
|
}(this, function () { 'use strict';
|
|
|
|
var hookCallback;
|
|
|
|
function utils_hooks__hooks () {
|
|
return hookCallback.apply(null, arguments);
|
|
}
|
|
|
|
// This is done to register the method called with moment()
|
|
// without creating circular dependencies.
|
|
function setHookCallback (callback) {
|
|
hookCallback = callback;
|
|
}
|
|
|
|
function isArray(input) {
|
|
return Object.prototype.toString.call(input) === '[object Array]';
|
|
}
|
|
|
|
function isDate(input) {
|
|
return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
|
|
}
|
|
|
|
function map(arr, fn) {
|
|
var res = [], i;
|
|
for (i = 0; i < arr.length; ++i) {
|
|
res.push(fn(arr[i], i));
|
|
}
|
|
return res;
|
|
}
|
|
|
|
function hasOwnProp(a, b) {
|
|
return Object.prototype.hasOwnProperty.call(a, b);
|
|
}
|
|
|
|
function extend(a, b) {
|
|
for (var i in b) {
|
|
if (hasOwnProp(b, i)) {
|
|
a[i] = b[i];
|
|
}
|
|
}
|
|
|
|
if (hasOwnProp(b, 'toString')) {
|
|
a.toString = b.toString;
|
|
}
|
|
|
|
if (hasOwnProp(b, 'valueOf')) {
|
|
a.valueOf = b.valueOf;
|
|
}
|
|
|
|
return a;
|
|
}
|
|
|
|
function create_utc__createUTC (input, format, locale, strict) {
|
|
return createLocalOrUTC(input, format, locale, strict, true).utc();
|
|
}
|
|
|
|
function defaultParsingFlags() {
|
|
// We need to deep clone this object.
|
|
return {
|
|
empty : false,
|
|
unusedTokens : [],
|
|
unusedInput : [],
|
|
overflow : -2,
|
|
charsLeftOver : 0,
|
|
nullInput : false,
|
|
invalidMonth : null,
|
|
invalidFormat : false,
|
|
userInvalidated : false,
|
|
iso : false
|
|
};
|
|
}
|
|
|
|
function getParsingFlags(m) {
|
|
if (m._pf == null) {
|
|
m._pf = defaultParsingFlags();
|
|
}
|
|
return m._pf;
|
|
}
|
|
|
|
function valid__isValid(m) {
|
|
if (m._isValid == null) {
|
|
var flags = getParsingFlags(m);
|
|
m._isValid = !isNaN(m._d.getTime()) &&
|
|
flags.overflow < 0 &&
|
|
!flags.empty &&
|
|
!flags.invalidMonth &&
|
|
!flags.nullInput &&
|
|
!flags.invalidFormat &&
|
|
!flags.userInvalidated;
|
|
|
|
if (m._strict) {
|
|
m._isValid = m._isValid &&
|
|
flags.charsLeftOver === 0 &&
|
|
flags.unusedTokens.length === 0 &&
|
|
flags.bigHour === undefined;
|
|
}
|
|
}
|
|
return m._isValid;
|
|
}
|
|
|
|
function valid__createInvalid (flags) {
|
|
var m = create_utc__createUTC(NaN);
|
|
if (flags != null) {
|
|
extend(getParsingFlags(m), flags);
|
|
}
|
|
else {
|
|
getParsingFlags(m).userInvalidated = true;
|
|
}
|
|
|
|
return m;
|
|
}
|
|
|
|
var momentProperties = utils_hooks__hooks.momentProperties = [];
|
|
|
|
function copyConfig(to, from) {
|
|
var i, prop, val;
|
|
|
|
if (typeof from._isAMomentObject !== 'undefined') {
|
|
to._isAMomentObject = from._isAMomentObject;
|
|
}
|
|
if (typeof from._i !== 'undefined') {
|
|
to._i = from._i;
|
|
}
|
|
if (typeof from._f !== 'undefined') {
|
|
to._f = from._f;
|
|
}
|
|
if (typeof from._l !== 'undefined') {
|
|
to._l = from._l;
|
|
}
|
|
if (typeof from._strict !== 'undefined') {
|
|
to._strict = from._strict;
|
|
}
|
|
if (typeof from._tzm !== 'undefined') {
|
|
to._tzm = from._tzm;
|
|
}
|
|
if (typeof from._isUTC !== 'undefined') {
|
|
to._isUTC = from._isUTC;
|
|
}
|
|
if (typeof from._offset !== 'undefined') {
|
|
to._offset = from._offset;
|
|
}
|
|
if (typeof from._pf !== 'undefined') {
|
|
to._pf = getParsingFlags(from);
|
|
}
|
|
if (typeof from._locale !== 'undefined') {
|
|
to._locale = from._locale;
|
|
}
|
|
|
|
if (momentProperties.length > 0) {
|
|
for (i in momentProperties) {
|
|
prop = momentProperties[i];
|
|
val = from[prop];
|
|
if (typeof val !== 'undefined') {
|
|
to[prop] = val;
|
|
}
|
|
}
|
|
}
|
|
|
|
return to;
|
|
}
|
|
|
|
var updateInProgress = false;
|
|
|
|
// Moment prototype object
|
|
function Moment(config) {
|
|
copyConfig(this, config);
|
|
this._d = new Date(+config._d);
|
|
// Prevent infinite loop in case updateOffset creates new moment
|
|
// objects.
|
|
if (updateInProgress === false) {
|
|
updateInProgress = true;
|
|
utils_hooks__hooks.updateOffset(this);
|
|
updateInProgress = false;
|
|
}
|
|
}
|
|
|
|
function isMoment (obj) {
|
|
return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
|
|
}
|
|
|
|
function toInt(argumentForCoercion) {
|
|
var coercedNumber = +argumentForCoercion,
|
|
value = 0;
|
|
|
|
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
|
|
if (coercedNumber >= 0) {
|
|
value = Math.floor(coercedNumber);
|
|
} else {
|
|
value = Math.ceil(coercedNumber);
|
|
}
|
|
}
|
|
|
|
return value;
|
|
}
|
|
|
|
function compareArrays(array1, array2, dontConvert) {
|
|
var len = Math.min(array1.length, array2.length),
|
|
lengthDiff = Math.abs(array1.length - array2.length),
|
|
diffs = 0,
|
|
i;
|
|
for (i = 0; i < len; i++) {
|
|
if ((dontConvert && array1[i] !== array2[i]) ||
|
|
(!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
|
|
diffs++;
|
|
}
|
|
}
|
|
return diffs + lengthDiff;
|
|
}
|
|
|
|
function Locale() {
|
|
}
|
|
|
|
var locales = {};
|
|
var globalLocale;
|
|
|
|
function normalizeLocale(key) {
|
|
return key ? key.toLowerCase().replace('_', '-') : key;
|
|
}
|
|
|
|
// pick the locale from the array
|
|
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
|
|
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
|
|
function chooseLocale(names) {
|
|
var i = 0, j, next, locale, split;
|
|
|
|
while (i < names.length) {
|
|
split = normalizeLocale(names[i]).split('-');
|
|
j = split.length;
|
|
next = normalizeLocale(names[i + 1]);
|
|
next = next ? next.split('-') : null;
|
|
while (j > 0) {
|
|
locale = loadLocale(split.slice(0, j).join('-'));
|
|
if (locale) {
|
|
return locale;
|
|
}
|
|
if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
|
|
//the next array item is better than a shallower substring of this one
|
|
break;
|
|
}
|
|
j--;
|
|
}
|
|
i++;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function loadLocale(name) {
|
|
var oldLocale = null;
|
|
// TODO: Find a better way to register and load all the locales in Node
|
|
if (!locales[name] && typeof module !== 'undefined' &&
|
|
module && module.exports) {
|
|
try {
|
|
oldLocale = globalLocale._abbr;
|
|
require('./locale/' + name);
|
|
// because defineLocale currently also sets the global locale, we
|
|
// want to undo that for lazy loaded locales
|
|
locale_locales__getSetGlobalLocale(oldLocale);
|
|
} catch (e) { }
|
|
}
|
|
return locales[name];
|
|
}
|
|
|
|
// This function will load locale and then set the global locale. If
|
|
// no arguments are passed in, it will simply return the current global
|
|
// locale key.
|
|
function locale_locales__getSetGlobalLocale (key, values) {
|
|
var data;
|
|
if (key) {
|
|
if (typeof values === 'undefined') {
|
|
data = locale_locales__getLocale(key);
|
|
}
|
|
else {
|
|
data = defineLocale(key, values);
|
|
}
|
|
|
|
if (data) {
|
|
// moment.duration._locale = moment._locale = data;
|
|
globalLocale = data;
|
|
}
|
|
}
|
|
|
|
return globalLocale._abbr;
|
|
}
|
|
|
|
function defineLocale (name, values) {
|
|
if (values !== null) {
|
|
values.abbr = name;
|
|
if (!locales[name]) {
|
|
locales[name] = new Locale();
|
|
}
|
|
locales[name].set(values);
|
|
|
|
// backwards compat for now: also set the locale
|
|
locale_locales__getSetGlobalLocale(name);
|
|
|
|
return locales[name];
|
|
} else {
|
|
// useful for testing
|
|
delete locales[name];
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// returns locale data
|
|
function locale_locales__getLocale (key) {
|
|
var locale;
|
|
|
|
if (key && key._locale && key._locale._abbr) {
|
|
key = key._locale._abbr;
|
|
}
|
|
|
|
if (!key) {
|
|
return globalLocale;
|
|
}
|
|
|
|
if (!isArray(key)) {
|
|
//short-circuit everything else
|
|
locale = loadLocale(key);
|
|
if (locale) {
|
|
return locale;
|
|
}
|
|
key = [key];
|
|
}
|
|
|
|
return chooseLocale(key);
|
|
}
|
|
|
|
var aliases = {};
|
|
|
|
function addUnitAlias (unit, shorthand) {
|
|
var lowerCase = unit.toLowerCase();
|
|
aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
|
|
}
|
|
|
|
function normalizeUnits(units) {
|
|
return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
|
|
}
|
|
|
|
function normalizeObjectUnits(inputObject) {
|
|
var normalizedInput = {},
|
|
normalizedProp,
|
|
prop;
|
|
|
|
for (prop in inputObject) {
|
|
if (hasOwnProp(inputObject, prop)) {
|
|
normalizedProp = normalizeUnits(prop);
|
|
if (normalizedProp) {
|
|
normalizedInput[normalizedProp] = inputObject[prop];
|
|
}
|
|
}
|
|
}
|
|
|
|
return normalizedInput;
|
|
}
|
|
|
|
function makeGetSet (unit, keepTime) {
|
|
return function (value) {
|
|
if (value != null) {
|
|
get_set__set(this, unit, value);
|
|
utils_hooks__hooks.updateOffset(this, keepTime);
|
|
return this;
|
|
} else {
|
|
return get_set__get(this, unit);
|
|
}
|
|
};
|
|
}
|
|
|
|
function get_set__get (mom, unit) {
|
|
return mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]();
|
|
}
|
|
|
|
function get_set__set (mom, unit, value) {
|
|
return mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
|
|
}
|
|
|
|
// MOMENTS
|
|
|
|
function getSet (units, value) {
|
|
var unit;
|
|
if (typeof units === 'object') {
|
|
for (unit in units) {
|
|
this.set(unit, units[unit]);
|
|
}
|
|
} else {
|
|
units = normalizeUnits(units);
|
|
if (typeof this[units] === 'function') {
|
|
return this[units](value);
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
|
|
function zeroFill(number, targetLength, forceSign) {
|
|
var output = '' + Math.abs(number),
|
|
sign = number >= 0;
|
|
|
|
while (output.length < targetLength) {
|
|
output = '0' + output;
|
|
}
|
|
return (sign ? (forceSign ? '+' : '') : '-') + output;
|
|
}
|
|
|
|
var formattingTokens = /(\[[^\[]*\])|(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Q|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|mm?|ss?|S{1,4}|x|X|zz?|ZZ?|.)/g;
|
|
|
|
var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
|
|
|
|
var formatFunctions = {};
|
|
|
|
var formatTokenFunctions = {};
|
|
|
|
// token: 'M'
|
|
// padded: ['MM', 2]
|
|
// ordinal: 'Mo'
|
|
// callback: function () { this.month() + 1 }
|
|
function addFormatToken (token, padded, ordinal, callback) {
|
|
var func = callback;
|
|
if (typeof callback === 'string') {
|
|
func = function () {
|
|
return this[callback]();
|
|
};
|
|
}
|
|
if (token) {
|
|
formatTokenFunctions[token] = func;
|
|
}
|
|
if (padded) {
|
|
formatTokenFunctions[padded[0]] = function () {
|
|
return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
|
|
};
|
|
}
|
|
if (ordinal) {
|
|
formatTokenFunctions[ordinal] = function () {
|
|
return this.localeData().ordinal(func.apply(this, arguments), token);
|
|
};
|
|
}
|
|
}
|
|
|
|
function removeFormattingTokens(input) {
|
|
if (input.match(/\[[\s\S]/)) {
|
|
return input.replace(/^\[|\]$/g, '');
|
|
}
|
|
return input.replace(/\\/g, '');
|
|
}
|
|
|
|
function makeFormatFunction(format) {
|
|
var array = format.match(formattingTokens), i, length;
|
|
|
|
for (i = 0, length = array.length; i < length; i++) {
|
|
if (formatTokenFunctions[array[i]]) {
|
|
array[i] = formatTokenFunctions[array[i]];
|
|
} else {
|
|
array[i] = removeFormattingTokens(array[i]);
|
|
}
|
|
}
|
|
|
|
return function (mom) {
|
|
var output = '';
|
|
for (i = 0; i < length; i++) {
|
|
output += array[i] instanceof Function ? array[i].call(mom, format) : array[i];
|
|
}
|
|
return output;
|
|
};
|
|
}
|
|
|
|
// format date using native date object
|
|
function formatMoment(m, format) {
|
|
if (!m.isValid()) {
|
|
return m.localeData().invalidDate();
|
|
}
|
|
|
|
format = expandFormat(format, m.localeData());
|
|
|
|
if (!formatFunctions[format]) {
|
|
formatFunctions[format] = makeFormatFunction(format);
|
|
}
|
|
|
|
return formatFunctions[format](m);
|
|
}
|
|
|
|
function expandFormat(format, locale) {
|
|
var i = 5;
|
|
|
|
function replaceLongDateFormatTokens(input) {
|
|
return locale.longDateFormat(input) || input;
|
|
}
|
|
|
|
localFormattingTokens.lastIndex = 0;
|
|
while (i >= 0 && localFormattingTokens.test(format)) {
|
|
format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
|
|
localFormattingTokens.lastIndex = 0;
|
|
i -= 1;
|
|
}
|
|
|
|
return format;
|
|
}
|
|
|
|
var match1 = /\d/; // 0 - 9
|
|
var match2 = /\d\d/; // 00 - 99
|
|
var match3 = /\d{3}/; // 000 - 999
|
|
var match4 = /\d{4}/; // 0000 - 9999
|
|
var match6 = /[+-]?\d{6}/; // -999999 - 999999
|
|
var match1to2 = /\d\d?/; // 0 - 99
|
|
var match1to3 = /\d{1,3}/; // 0 - 999
|
|
var match1to4 = /\d{1,4}/; // 0 - 9999
|
|
var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
|
|
|
|
var matchUnsigned = /\d+/; // 0 - inf
|
|
var matchSigned = /[+-]?\d+/; // -inf - inf
|
|
|
|
var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
|
|
|
|
var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
|
|
|
|
// any word (or two) characters or numbers including two/three word month in arabic.
|
|
var matchWord = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
|
|
|
|
var regexes = {};
|
|
|
|
function addRegexToken (token, regex, strictRegex) {
|
|
regexes[token] = typeof regex === 'function' ? regex : function (isStrict) {
|
|
return (isStrict && strictRegex) ? strictRegex : regex;
|
|
};
|
|
}
|
|
|
|
function getParseRegexForToken (token, config) {
|
|
if (!hasOwnProp(regexes, token)) {
|
|
return new RegExp(unescapeFormat(token));
|
|
}
|
|
|
|
return regexes[token](config._strict, config._locale);
|
|
}
|
|
|
|
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
|
|
function unescapeFormat(s) {
|
|
return s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
|
|
return p1 || p2 || p3 || p4;
|
|
}).replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
|
}
|
|
|
|
var tokens = {};
|
|
|
|
function addParseToken (token, callback) {
|
|
var i, func = callback;
|
|
if (typeof token === 'string') {
|
|
token = [token];
|
|
}
|
|
if (typeof callback === 'number') {
|
|
func = function (input, array) {
|
|
array[callback] = toInt(input);
|
|
};
|
|
}
|
|
for (i = 0; i < token.length; i++) {
|
|
tokens[token[i]] = func;
|
|
}
|
|
}
|
|
|
|
function addWeekParseToken (token, callback) {
|
|
addParseToken(token, function (input, array, config, token) {
|
|
config._w = config._w || {};
|
|
callback(input, config._w, config, token);
|
|
});
|
|
}
|
|
|
|
function addTimeToArrayFromToken(token, input, config) {
|
|
if (input != null && hasOwnProp(tokens, token)) {
|
|
tokens[token](input, config._a, config, token);
|
|
}
|
|
}
|
|
|
|
var YEAR = 0;
|
|
var MONTH = 1;
|
|
var DATE = 2;
|
|
var HOUR = 3;
|
|
var MINUTE = 4;
|
|
var SECOND = 5;
|
|
var MILLISECOND = 6;
|
|
|
|
function daysInMonth(year, month) {
|
|
return new Date(Date.UTC(year, month + 1, 0)).getUTCDate();
|
|
}
|
|
|
|
// FORMATTING
|
|
|
|
addFormatToken('M', ['MM', 2], 'Mo', function () {
|
|
return this.month() + 1;
|
|
});
|
|
|
|
addFormatToken('MMM', 0, 0, function (format) {
|
|
return this.localeData().monthsShort(this, format);
|
|
});
|
|
|
|
addFormatToken('MMMM', 0, 0, function (format) {
|
|
return this.localeData().months(this, format);
|
|
});
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('month', 'M');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('M', match1to2);
|
|
addRegexToken('MM', match1to2, match2);
|
|
addRegexToken('MMM', matchWord);
|
|
addRegexToken('MMMM', matchWord);
|
|
|
|
addParseToken(['M', 'MM'], function (input, array) {
|
|
array[MONTH] = toInt(input) - 1;
|
|
});
|
|
|
|
addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
|
|
var month = config._locale.monthsParse(input, token, config._strict);
|
|
// if we didn't find a month name, mark the date as invalid.
|
|
if (month != null) {
|
|
array[MONTH] = month;
|
|
} else {
|
|
getParsingFlags(config).invalidMonth = input;
|
|
}
|
|
});
|
|
|
|
// LOCALES
|
|
|
|
var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
|
|
function localeMonths (m) {
|
|
return this._months[m.month()];
|
|
}
|
|
|
|
var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
|
|
function localeMonthsShort (m) {
|
|
return this._monthsShort[m.month()];
|
|
}
|
|
|
|
function localeMonthsParse (monthName, format, strict) {
|
|
var i, mom, regex;
|
|
|
|
if (!this._monthsParse) {
|
|
this._monthsParse = [];
|
|
this._longMonthsParse = [];
|
|
this._shortMonthsParse = [];
|
|
}
|
|
|
|
for (i = 0; i < 12; i++) {
|
|
// make the regex if we don't have it already
|
|
mom = create_utc__createUTC([2000, i]);
|
|
if (strict && !this._longMonthsParse[i]) {
|
|
this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
|
|
this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
|
|
}
|
|
if (!strict && !this._monthsParse[i]) {
|
|
regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
|
|
this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
|
}
|
|
// test the regex
|
|
if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
|
|
return i;
|
|
} else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
|
|
return i;
|
|
} else if (!strict && this._monthsParse[i].test(monthName)) {
|
|
return i;
|
|
}
|
|
}
|
|
}
|
|
|
|
// MOMENTS
|
|
|
|
function setMonth (mom, value) {
|
|
var dayOfMonth;
|
|
|
|
// TODO: Move this out of here!
|
|
if (typeof value === 'string') {
|
|
value = mom.localeData().monthsParse(value);
|
|
// TODO: Another silent failure?
|
|
if (typeof value !== 'number') {
|
|
return mom;
|
|
}
|
|
}
|
|
|
|
dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
|
|
mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
|
|
return mom;
|
|
}
|
|
|
|
function getSetMonth (value) {
|
|
if (value != null) {
|
|
setMonth(this, value);
|
|
utils_hooks__hooks.updateOffset(this, true);
|
|
return this;
|
|
} else {
|
|
return get_set__get(this, 'Month');
|
|
}
|
|
}
|
|
|
|
function getDaysInMonth () {
|
|
return daysInMonth(this.year(), this.month());
|
|
}
|
|
|
|
function checkOverflow (m) {
|
|
var overflow;
|
|
var a = m._a;
|
|
|
|
if (a && getParsingFlags(m).overflow === -2) {
|
|
overflow =
|
|
a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
|
|
a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
|
|
a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
|
|
a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
|
|
a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
|
|
a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
|
|
-1;
|
|
|
|
if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
|
|
overflow = DATE;
|
|
}
|
|
|
|
getParsingFlags(m).overflow = overflow;
|
|
}
|
|
|
|
return m;
|
|
}
|
|
|
|
function warn(msg) {
|
|
if (utils_hooks__hooks.suppressDeprecationWarnings === false && typeof console !== 'undefined' && console.warn) {
|
|
console.warn('Deprecation warning: ' + msg);
|
|
}
|
|
}
|
|
|
|
function deprecate(msg, fn) {
|
|
var firstTime = true,
|
|
msgWithStack = msg + '\n' + (new Error()).stack;
|
|
|
|
return extend(function () {
|
|
if (firstTime) {
|
|
warn(msgWithStack);
|
|
firstTime = false;
|
|
}
|
|
return fn.apply(this, arguments);
|
|
}, fn);
|
|
}
|
|
|
|
var deprecations = {};
|
|
|
|
function deprecateSimple(name, msg) {
|
|
if (!deprecations[name]) {
|
|
warn(msg);
|
|
deprecations[name] = true;
|
|
}
|
|
}
|
|
|
|
utils_hooks__hooks.suppressDeprecationWarnings = false;
|
|
|
|
var from_string__isoRegex = /^\s*(?:[+-]\d{6}|\d{4})-(?:(\d\d-\d\d)|(W\d\d$)|(W\d\d-\d)|(\d\d\d))((T| )(\d\d(:\d\d(:\d\d(\.\d+)?)?)?)?([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
|
|
|
|
var isoDates = [
|
|
['YYYYYY-MM-DD', /[+-]\d{6}-\d{2}-\d{2}/],
|
|
['YYYY-MM-DD', /\d{4}-\d{2}-\d{2}/],
|
|
['GGGG-[W]WW-E', /\d{4}-W\d{2}-\d/],
|
|
['GGGG-[W]WW', /\d{4}-W\d{2}/],
|
|
['YYYY-DDD', /\d{4}-\d{3}/]
|
|
];
|
|
|
|
// iso time formats and regexes
|
|
var isoTimes = [
|
|
['HH:mm:ss.SSSS', /(T| )\d\d:\d\d:\d\d\.\d+/],
|
|
['HH:mm:ss', /(T| )\d\d:\d\d:\d\d/],
|
|
['HH:mm', /(T| )\d\d:\d\d/],
|
|
['HH', /(T| )\d\d/]
|
|
];
|
|
|
|
var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
|
|
|
|
// date from iso format
|
|
function configFromISO(config) {
|
|
var i, l,
|
|
string = config._i,
|
|
match = from_string__isoRegex.exec(string);
|
|
|
|
if (match) {
|
|
getParsingFlags(config).iso = true;
|
|
for (i = 0, l = isoDates.length; i < l; i++) {
|
|
if (isoDates[i][1].exec(string)) {
|
|
// match[5] should be 'T' or undefined
|
|
config._f = isoDates[i][0] + (match[6] || ' ');
|
|
break;
|
|
}
|
|
}
|
|
for (i = 0, l = isoTimes.length; i < l; i++) {
|
|
if (isoTimes[i][1].exec(string)) {
|
|
config._f += isoTimes[i][0];
|
|
break;
|
|
}
|
|
}
|
|
if (string.match(matchOffset)) {
|
|
config._f += 'Z';
|
|
}
|
|
configFromStringAndFormat(config);
|
|
} else {
|
|
config._isValid = false;
|
|
}
|
|
}
|
|
|
|
// date from iso format or fallback
|
|
function configFromString(config) {
|
|
var matched = aspNetJsonRegex.exec(config._i);
|
|
|
|
if (matched !== null) {
|
|
config._d = new Date(+matched[1]);
|
|
return;
|
|
}
|
|
|
|
configFromISO(config);
|
|
if (config._isValid === false) {
|
|
delete config._isValid;
|
|
utils_hooks__hooks.createFromInputFallback(config);
|
|
}
|
|
}
|
|
|
|
utils_hooks__hooks.createFromInputFallback = deprecate(
|
|
'moment construction falls back to js Date. This is ' +
|
|
'discouraged and will be removed in upcoming major ' +
|
|
'release. Please refer to ' +
|
|
'https://github.com/moment/moment/issues/1407 for more info.',
|
|
function (config) {
|
|
config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
|
|
}
|
|
);
|
|
|
|
function createDate (y, m, d, h, M, s, ms) {
|
|
//can't just apply() to create a date:
|
|
//http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
|
|
var date = new Date(y, m, d, h, M, s, ms);
|
|
|
|
//the date constructor doesn't accept years < 1970
|
|
if (y < 1970) {
|
|
date.setFullYear(y);
|
|
}
|
|
return date;
|
|
}
|
|
|
|
function createUTCDate (y) {
|
|
var date = new Date(Date.UTC.apply(null, arguments));
|
|
if (y < 1970) {
|
|
date.setUTCFullYear(y);
|
|
}
|
|
return date;
|
|
}
|
|
|
|
addFormatToken(0, ['YY', 2], 0, function () {
|
|
return this.year() % 100;
|
|
});
|
|
|
|
addFormatToken(0, ['YYYY', 4], 0, 'year');
|
|
addFormatToken(0, ['YYYYY', 5], 0, 'year');
|
|
addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('year', 'y');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('Y', matchSigned);
|
|
addRegexToken('YY', match1to2, match2);
|
|
addRegexToken('YYYY', match1to4, match4);
|
|
addRegexToken('YYYYY', match1to6, match6);
|
|
addRegexToken('YYYYYY', match1to6, match6);
|
|
|
|
addParseToken(['YYYY', 'YYYYY', 'YYYYYY'], YEAR);
|
|
addParseToken('YY', function (input, array) {
|
|
array[YEAR] = utils_hooks__hooks.parseTwoDigitYear(input);
|
|
});
|
|
|
|
// HELPERS
|
|
|
|
function daysInYear(year) {
|
|
return isLeapYear(year) ? 366 : 365;
|
|
}
|
|
|
|
function isLeapYear(year) {
|
|
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
}
|
|
|
|
// HOOKS
|
|
|
|
utils_hooks__hooks.parseTwoDigitYear = function (input) {
|
|
return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
|
|
};
|
|
|
|
// MOMENTS
|
|
|
|
var getSetYear = makeGetSet('FullYear', false);
|
|
|
|
function getIsLeapYear () {
|
|
return isLeapYear(this.year());
|
|
}
|
|
|
|
addFormatToken('w', ['ww', 2], 'wo', 'week');
|
|
addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('week', 'w');
|
|
addUnitAlias('isoWeek', 'W');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('w', match1to2);
|
|
addRegexToken('ww', match1to2, match2);
|
|
addRegexToken('W', match1to2);
|
|
addRegexToken('WW', match1to2, match2);
|
|
|
|
addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
|
|
week[token.substr(0, 1)] = toInt(input);
|
|
});
|
|
|
|
// HELPERS
|
|
|
|
// firstDayOfWeek 0 = sun, 6 = sat
|
|
// the day of the week that starts the week
|
|
// (usually sunday or monday)
|
|
// firstDayOfWeekOfYear 0 = sun, 6 = sat
|
|
// the first week is the week that contains the first
|
|
// of this day of the week
|
|
// (eg. ISO weeks use thursday (4))
|
|
function weekOfYear(mom, firstDayOfWeek, firstDayOfWeekOfYear) {
|
|
var end = firstDayOfWeekOfYear - firstDayOfWeek,
|
|
daysToDayOfWeek = firstDayOfWeekOfYear - mom.day(),
|
|
adjustedMoment;
|
|
|
|
|
|
if (daysToDayOfWeek > end) {
|
|
daysToDayOfWeek -= 7;
|
|
}
|
|
|
|
if (daysToDayOfWeek < end - 7) {
|
|
daysToDayOfWeek += 7;
|
|
}
|
|
|
|
adjustedMoment = local__createLocal(mom).add(daysToDayOfWeek, 'd');
|
|
return {
|
|
week: Math.ceil(adjustedMoment.dayOfYear() / 7),
|
|
year: adjustedMoment.year()
|
|
};
|
|
}
|
|
|
|
// LOCALES
|
|
|
|
function localeWeek (mom) {
|
|
return weekOfYear(mom, this._week.dow, this._week.doy).week;
|
|
}
|
|
|
|
var defaultLocaleWeek = {
|
|
dow : 0, // Sunday is the first day of the week.
|
|
doy : 6 // The week that contains Jan 1st is the first week of the year.
|
|
};
|
|
|
|
function localeFirstDayOfWeek () {
|
|
return this._week.dow;
|
|
}
|
|
|
|
function localeFirstDayOfYear () {
|
|
return this._week.doy;
|
|
}
|
|
|
|
// MOMENTS
|
|
|
|
function getSetWeek (input) {
|
|
var week = this.localeData().week(this);
|
|
return input == null ? week : this.add((input - week) * 7, 'd');
|
|
}
|
|
|
|
function getSetISOWeek (input) {
|
|
var week = weekOfYear(this, 1, 4).week;
|
|
return input == null ? week : this.add((input - week) * 7, 'd');
|
|
}
|
|
|
|
addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('dayOfYear', 'DDD');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('DDD', match1to3);
|
|
addRegexToken('DDDD', match3);
|
|
addParseToken(['DDD', 'DDDD'], function (input, array, config) {
|
|
config._dayOfYear = toInt(input);
|
|
});
|
|
|
|
// HELPERS
|
|
|
|
//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
|
|
function dayOfYearFromWeeks(year, week, weekday, firstDayOfWeekOfYear, firstDayOfWeek) {
|
|
var d = createUTCDate(year, 0, 1).getUTCDay();
|
|
var daysToAdd;
|
|
var dayOfYear;
|
|
|
|
d = d === 0 ? 7 : d;
|
|
weekday = weekday != null ? weekday : firstDayOfWeek;
|
|
daysToAdd = firstDayOfWeek - d + (d > firstDayOfWeekOfYear ? 7 : 0) - (d < firstDayOfWeek ? 7 : 0);
|
|
dayOfYear = 7 * (week - 1) + (weekday - firstDayOfWeek) + daysToAdd + 1;
|
|
|
|
return {
|
|
year : dayOfYear > 0 ? year : year - 1,
|
|
dayOfYear : dayOfYear > 0 ? dayOfYear : daysInYear(year - 1) + dayOfYear
|
|
};
|
|
}
|
|
|
|
// MOMENTS
|
|
|
|
function getSetDayOfYear (input) {
|
|
var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
|
|
return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
|
|
}
|
|
|
|
// Pick the first defined of two or three arguments.
|
|
function defaults(a, b, c) {
|
|
if (a != null) {
|
|
return a;
|
|
}
|
|
if (b != null) {
|
|
return b;
|
|
}
|
|
return c;
|
|
}
|
|
|
|
function currentDateArray(config) {
|
|
var now = new Date();
|
|
if (config._useUTC) {
|
|
return [now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate()];
|
|
}
|
|
return [now.getFullYear(), now.getMonth(), now.getDate()];
|
|
}
|
|
|
|
// convert an array to a date.
|
|
// the array should mirror the parameters below
|
|
// note: all values past the year are optional and will default to the lowest possible value.
|
|
// [year, month, day , hour, minute, second, millisecond]
|
|
function configFromArray (config) {
|
|
var i, date, input = [], currentDate, yearToUse;
|
|
|
|
if (config._d) {
|
|
return;
|
|
}
|
|
|
|
currentDate = currentDateArray(config);
|
|
|
|
//compute day of the year from weeks and weekdays
|
|
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
|
|
dayOfYearFromWeekInfo(config);
|
|
}
|
|
|
|
//if the day of the year is set, figure out what it is
|
|
if (config._dayOfYear) {
|
|
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
|
|
|
|
if (config._dayOfYear > daysInYear(yearToUse)) {
|
|
getParsingFlags(config)._overflowDayOfYear = true;
|
|
}
|
|
|
|
date = createUTCDate(yearToUse, 0, config._dayOfYear);
|
|
config._a[MONTH] = date.getUTCMonth();
|
|
config._a[DATE] = date.getUTCDate();
|
|
}
|
|
|
|
// Default to current date.
|
|
// * if no year, month, day of month are given, default to today
|
|
// * if day of month is given, default month and year
|
|
// * if month is given, default only year
|
|
// * if year is given, don't default anything
|
|
for (i = 0; i < 3 && config._a[i] == null; ++i) {
|
|
config._a[i] = input[i] = currentDate[i];
|
|
}
|
|
|
|
// Zero out whatever was not defaulted, including time
|
|
for (; i < 7; i++) {
|
|
config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
|
|
}
|
|
|
|
// Check for 24:00:00.000
|
|
if (config._a[HOUR] === 24 &&
|
|
config._a[MINUTE] === 0 &&
|
|
config._a[SECOND] === 0 &&
|
|
config._a[MILLISECOND] === 0) {
|
|
config._nextDay = true;
|
|
config._a[HOUR] = 0;
|
|
}
|
|
|
|
config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
|
|
// Apply timezone offset from input. The actual utcOffset can be changed
|
|
// with parseZone.
|
|
if (config._tzm != null) {
|
|
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
|
|
}
|
|
|
|
if (config._nextDay) {
|
|
config._a[HOUR] = 24;
|
|
}
|
|
}
|
|
|
|
function dayOfYearFromWeekInfo(config) {
|
|
var w, weekYear, week, weekday, dow, doy, temp;
|
|
|
|
w = config._w;
|
|
if (w.GG != null || w.W != null || w.E != null) {
|
|
dow = 1;
|
|
doy = 4;
|
|
|
|
// TODO: We need to take the current isoWeekYear, but that depends on
|
|
// how we interpret now (local, utc, fixed offset). So create
|
|
// a now version of current config (take local/utc/offset flags, and
|
|
// create now).
|
|
weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(local__createLocal(), 1, 4).year);
|
|
week = defaults(w.W, 1);
|
|
weekday = defaults(w.E, 1);
|
|
} else {
|
|
dow = config._locale._week.dow;
|
|
doy = config._locale._week.doy;
|
|
|
|
weekYear = defaults(w.gg, config._a[YEAR], weekOfYear(local__createLocal(), dow, doy).year);
|
|
week = defaults(w.w, 1);
|
|
|
|
if (w.d != null) {
|
|
// weekday -- low day numbers are considered next week
|
|
weekday = w.d;
|
|
if (weekday < dow) {
|
|
++week;
|
|
}
|
|
} else if (w.e != null) {
|
|
// local weekday -- counting starts from begining of week
|
|
weekday = w.e + dow;
|
|
} else {
|
|
// default to begining of week
|
|
weekday = dow;
|
|
}
|
|
}
|
|
temp = dayOfYearFromWeeks(weekYear, week, weekday, doy, dow);
|
|
|
|
config._a[YEAR] = temp.year;
|
|
config._dayOfYear = temp.dayOfYear;
|
|
}
|
|
|
|
utils_hooks__hooks.ISO_8601 = function () {};
|
|
|
|
// date from string and format string
|
|
function configFromStringAndFormat(config) {
|
|
// TODO: Move this to another part of the creation flow to prevent circular deps
|
|
if (config._f === utils_hooks__hooks.ISO_8601) {
|
|
configFromISO(config);
|
|
return;
|
|
}
|
|
|
|
config._a = [];
|
|
getParsingFlags(config).empty = true;
|
|
|
|
// This array is used to make a Date, either with `new Date` or `Date.UTC`
|
|
var string = '' + config._i,
|
|
i, parsedInput, tokens, token, skipped,
|
|
stringLength = string.length,
|
|
totalParsedInputLength = 0;
|
|
|
|
tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
|
|
|
|
for (i = 0; i < tokens.length; i++) {
|
|
token = tokens[i];
|
|
parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
|
|
if (parsedInput) {
|
|
skipped = string.substr(0, string.indexOf(parsedInput));
|
|
if (skipped.length > 0) {
|
|
getParsingFlags(config).unusedInput.push(skipped);
|
|
}
|
|
string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
|
|
totalParsedInputLength += parsedInput.length;
|
|
}
|
|
// don't parse if it's not a known token
|
|
if (formatTokenFunctions[token]) {
|
|
if (parsedInput) {
|
|
getParsingFlags(config).empty = false;
|
|
}
|
|
else {
|
|
getParsingFlags(config).unusedTokens.push(token);
|
|
}
|
|
addTimeToArrayFromToken(token, parsedInput, config);
|
|
}
|
|
else if (config._strict && !parsedInput) {
|
|
getParsingFlags(config).unusedTokens.push(token);
|
|
}
|
|
}
|
|
|
|
// add remaining unparsed input length to the string
|
|
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
|
|
if (string.length > 0) {
|
|
getParsingFlags(config).unusedInput.push(string);
|
|
}
|
|
|
|
// clear _12h flag if hour is <= 12
|
|
if (getParsingFlags(config).bigHour === true &&
|
|
config._a[HOUR] <= 12 &&
|
|
config._a[HOUR] > 0) {
|
|
getParsingFlags(config).bigHour = undefined;
|
|
}
|
|
// handle meridiem
|
|
config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
|
|
|
|
configFromArray(config);
|
|
checkOverflow(config);
|
|
}
|
|
|
|
|
|
function meridiemFixWrap (locale, hour, meridiem) {
|
|
var isPm;
|
|
|
|
if (meridiem == null) {
|
|
// nothing to do
|
|
return hour;
|
|
}
|
|
if (locale.meridiemHour != null) {
|
|
return locale.meridiemHour(hour, meridiem);
|
|
} else if (locale.isPM != null) {
|
|
// Fallback
|
|
isPm = locale.isPM(meridiem);
|
|
if (isPm && hour < 12) {
|
|
hour += 12;
|
|
}
|
|
if (!isPm && hour === 12) {
|
|
hour = 0;
|
|
}
|
|
return hour;
|
|
} else {
|
|
// this is not supposed to happen
|
|
return hour;
|
|
}
|
|
}
|
|
|
|
function configFromStringAndArray(config) {
|
|
var tempConfig,
|
|
bestMoment,
|
|
|
|
scoreToBeat,
|
|
i,
|
|
currentScore;
|
|
|
|
if (config._f.length === 0) {
|
|
getParsingFlags(config).invalidFormat = true;
|
|
config._d = new Date(NaN);
|
|
return;
|
|
}
|
|
|
|
for (i = 0; i < config._f.length; i++) {
|
|
currentScore = 0;
|
|
tempConfig = copyConfig({}, config);
|
|
if (config._useUTC != null) {
|
|
tempConfig._useUTC = config._useUTC;
|
|
}
|
|
tempConfig._f = config._f[i];
|
|
configFromStringAndFormat(tempConfig);
|
|
|
|
if (!valid__isValid(tempConfig)) {
|
|
continue;
|
|
}
|
|
|
|
// if there is any input that was not parsed add a penalty for that format
|
|
currentScore += getParsingFlags(tempConfig).charsLeftOver;
|
|
|
|
//or tokens
|
|
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
|
|
|
|
getParsingFlags(tempConfig).score = currentScore;
|
|
|
|
if (scoreToBeat == null || currentScore < scoreToBeat) {
|
|
scoreToBeat = currentScore;
|
|
bestMoment = tempConfig;
|
|
}
|
|
}
|
|
|
|
extend(config, bestMoment || tempConfig);
|
|
}
|
|
|
|
function configFromObject(config) {
|
|
if (config._d) {
|
|
return;
|
|
}
|
|
|
|
var i = normalizeObjectUnits(config._i);
|
|
config._a = [i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond];
|
|
|
|
configFromArray(config);
|
|
}
|
|
|
|
function createFromConfig (config) {
|
|
var input = config._i,
|
|
format = config._f,
|
|
res;
|
|
|
|
config._locale = config._locale || locale_locales__getLocale(config._l);
|
|
|
|
if (input === null || (format === undefined && input === '')) {
|
|
return valid__createInvalid({nullInput: true});
|
|
}
|
|
|
|
if (typeof input === 'string') {
|
|
config._i = input = config._locale.preparse(input);
|
|
}
|
|
|
|
if (isMoment(input)) {
|
|
return new Moment(checkOverflow(input));
|
|
} else if (isArray(format)) {
|
|
configFromStringAndArray(config);
|
|
} else if (format) {
|
|
configFromStringAndFormat(config);
|
|
} else if (isDate(input)) {
|
|
config._d = input;
|
|
} else {
|
|
configFromInput(config);
|
|
}
|
|
|
|
res = new Moment(checkOverflow(config));
|
|
if (res._nextDay) {
|
|
// Adding is smart enough around DST
|
|
res.add(1, 'd');
|
|
res._nextDay = undefined;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
function configFromInput(config) {
|
|
var input = config._i;
|
|
if (input === undefined) {
|
|
config._d = new Date();
|
|
} else if (isDate(input)) {
|
|
config._d = new Date(+input);
|
|
} else if (typeof input === 'string') {
|
|
configFromString(config);
|
|
} else if (isArray(input)) {
|
|
config._a = map(input.slice(0), function (obj) {
|
|
return parseInt(obj, 10);
|
|
});
|
|
configFromArray(config);
|
|
} else if (typeof(input) === 'object') {
|
|
configFromObject(config);
|
|
} else if (typeof(input) === 'number') {
|
|
// from milliseconds
|
|
config._d = new Date(input);
|
|
} else {
|
|
utils_hooks__hooks.createFromInputFallback(config);
|
|
}
|
|
}
|
|
|
|
function createLocalOrUTC (input, format, locale, strict, isUTC) {
|
|
var c = {};
|
|
|
|
if (typeof(locale) === 'boolean') {
|
|
strict = locale;
|
|
locale = undefined;
|
|
}
|
|
// object construction must be done this way.
|
|
// https://github.com/moment/moment/issues/1423
|
|
c._isAMomentObject = true;
|
|
c._useUTC = c._isUTC = isUTC;
|
|
c._l = locale;
|
|
c._i = input;
|
|
c._f = format;
|
|
c._strict = strict;
|
|
|
|
return createFromConfig(c);
|
|
}
|
|
|
|
function local__createLocal (input, format, locale, strict) {
|
|
return createLocalOrUTC(input, format, locale, strict, false);
|
|
}
|
|
|
|
var prototypeMin = deprecate(
|
|
'moment().min is deprecated, use moment.min instead. https://github.com/moment/moment/issues/1548',
|
|
function () {
|
|
var other = local__createLocal.apply(null, arguments);
|
|
return other < this ? this : other;
|
|
}
|
|
);
|
|
|
|
var prototypeMax = deprecate(
|
|
'moment().max is deprecated, use moment.max instead. https://github.com/moment/moment/issues/1548',
|
|
function () {
|
|
var other = local__createLocal.apply(null, arguments);
|
|
return other > this ? this : other;
|
|
}
|
|
);
|
|
|
|
// Pick a moment m from moments so that m[fn](other) is true for all
|
|
// other. This relies on the function fn to be transitive.
|
|
//
|
|
// moments should either be an array of moment objects or an array, whose
|
|
// first element is an array of moment objects.
|
|
function pickBy(fn, moments) {
|
|
var res, i;
|
|
if (moments.length === 1 && isArray(moments[0])) {
|
|
moments = moments[0];
|
|
}
|
|
if (!moments.length) {
|
|
return local__createLocal();
|
|
}
|
|
res = moments[0];
|
|
for (i = 1; i < moments.length; ++i) {
|
|
if (moments[i][fn](res)) {
|
|
res = moments[i];
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
// TODO: Use [].sort instead?
|
|
function min () {
|
|
var args = [].slice.call(arguments, 0);
|
|
|
|
return pickBy('isBefore', args);
|
|
}
|
|
|
|
function max () {
|
|
var args = [].slice.call(arguments, 0);
|
|
|
|
return pickBy('isAfter', args);
|
|
}
|
|
|
|
function Duration (duration) {
|
|
var normalizedInput = normalizeObjectUnits(duration),
|
|
years = normalizedInput.year || 0,
|
|
quarters = normalizedInput.quarter || 0,
|
|
months = normalizedInput.month || 0,
|
|
weeks = normalizedInput.week || 0,
|
|
days = normalizedInput.day || 0,
|
|
hours = normalizedInput.hour || 0,
|
|
minutes = normalizedInput.minute || 0,
|
|
seconds = normalizedInput.second || 0,
|
|
milliseconds = normalizedInput.millisecond || 0;
|
|
|
|
// representation for dateAddRemove
|
|
this._milliseconds = +milliseconds +
|
|
seconds * 1e3 + // 1000
|
|
minutes * 6e4 + // 1000 * 60
|
|
hours * 36e5; // 1000 * 60 * 60
|
|
// Because of dateAddRemove treats 24 hours as different from a
|
|
// day when working around DST, we need to store them separately
|
|
this._days = +days +
|
|
weeks * 7;
|
|
// It is impossible translate months into days without knowing
|
|
// which months you are are talking about, so we have to store
|
|
// it separately.
|
|
this._months = +months +
|
|
quarters * 3 +
|
|
years * 12;
|
|
|
|
this._data = {};
|
|
|
|
this._locale = locale_locales__getLocale();
|
|
|
|
this._bubble();
|
|
}
|
|
|
|
function isDuration (obj) {
|
|
return obj instanceof Duration;
|
|
}
|
|
|
|
function offset (token, separator) {
|
|
addFormatToken(token, 0, 0, function () {
|
|
var offset = this.utcOffset();
|
|
var sign = '+';
|
|
if (offset < 0) {
|
|
offset = -offset;
|
|
sign = '-';
|
|
}
|
|
return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
|
|
});
|
|
}
|
|
|
|
offset('Z', ':');
|
|
offset('ZZ', '');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('Z', matchOffset);
|
|
addRegexToken('ZZ', matchOffset);
|
|
addParseToken(['Z', 'ZZ'], function (input, array, config) {
|
|
config._useUTC = true;
|
|
config._tzm = offsetFromString(input);
|
|
});
|
|
|
|
// HELPERS
|
|
|
|
// timezone chunker
|
|
// '+10:00' > ['10', '00']
|
|
// '-1530' > ['-15', '30']
|
|
var chunkOffset = /([\+\-]|\d\d)/gi;
|
|
|
|
function offsetFromString(string) {
|
|
var matches = ((string || '').match(matchOffset) || []);
|
|
var chunk = matches[matches.length - 1] || [];
|
|
var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
|
|
var minutes = +(parts[1] * 60) + toInt(parts[2]);
|
|
|
|
return parts[0] === '+' ? minutes : -minutes;
|
|
}
|
|
|
|
// Return a moment from input, that is local/utc/zone equivalent to model.
|
|
function cloneWithOffset(input, model) {
|
|
var res, diff;
|
|
if (model._isUTC) {
|
|
res = model.clone();
|
|
diff = (isMoment(input) || isDate(input) ? +input : +local__createLocal(input)) - (+res);
|
|
// Use low-level api, because this fn is low-level api.
|
|
res._d.setTime(+res._d + diff);
|
|
utils_hooks__hooks.updateOffset(res, false);
|
|
return res;
|
|
} else {
|
|
return local__createLocal(input).local();
|
|
}
|
|
return model._isUTC ? local__createLocal(input).zone(model._offset || 0) : local__createLocal(input).local();
|
|
}
|
|
|
|
function getDateOffset (m) {
|
|
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
|
|
// https://github.com/moment/moment/pull/1871
|
|
return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
|
|
}
|
|
|
|
// HOOKS
|
|
|
|
// This function will be called whenever a moment is mutated.
|
|
// It is intended to keep the offset in sync with the timezone.
|
|
utils_hooks__hooks.updateOffset = function () {};
|
|
|
|
// MOMENTS
|
|
|
|
// keepLocalTime = true means only change the timezone, without
|
|
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
|
|
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
|
|
// +0200, so we adjust the time as needed, to be valid.
|
|
//
|
|
// Keeping the time actually adds/subtracts (one hour)
|
|
// from the actual represented time. That is why we call updateOffset
|
|
// a second time. In case it wants us to change the offset again
|
|
// _changeInProgress == true case, then we have to adjust, because
|
|
// there is no such time in the given timezone.
|
|
function getSetOffset (input, keepLocalTime) {
|
|
var offset = this._offset || 0,
|
|
localAdjust;
|
|
if (input != null) {
|
|
if (typeof input === 'string') {
|
|
input = offsetFromString(input);
|
|
}
|
|
if (Math.abs(input) < 16) {
|
|
input = input * 60;
|
|
}
|
|
if (!this._isUTC && keepLocalTime) {
|
|
localAdjust = getDateOffset(this);
|
|
}
|
|
this._offset = input;
|
|
this._isUTC = true;
|
|
if (localAdjust != null) {
|
|
this.add(localAdjust, 'm');
|
|
}
|
|
if (offset !== input) {
|
|
if (!keepLocalTime || this._changeInProgress) {
|
|
add_subtract__addSubtract(this, create__createDuration(input - offset, 'm'), 1, false);
|
|
} else if (!this._changeInProgress) {
|
|
this._changeInProgress = true;
|
|
utils_hooks__hooks.updateOffset(this, true);
|
|
this._changeInProgress = null;
|
|
}
|
|
}
|
|
return this;
|
|
} else {
|
|
return this._isUTC ? offset : getDateOffset(this);
|
|
}
|
|
}
|
|
|
|
function getSetZone (input, keepLocalTime) {
|
|
if (input != null) {
|
|
if (typeof input !== 'string') {
|
|
input = -input;
|
|
}
|
|
|
|
this.utcOffset(input, keepLocalTime);
|
|
|
|
return this;
|
|
} else {
|
|
return -this.utcOffset();
|
|
}
|
|
}
|
|
|
|
function setOffsetToUTC (keepLocalTime) {
|
|
return this.utcOffset(0, keepLocalTime);
|
|
}
|
|
|
|
function setOffsetToLocal (keepLocalTime) {
|
|
if (this._isUTC) {
|
|
this.utcOffset(0, keepLocalTime);
|
|
this._isUTC = false;
|
|
|
|
if (keepLocalTime) {
|
|
this.subtract(getDateOffset(this), 'm');
|
|
}
|
|
}
|
|
return this;
|
|
}
|
|
|
|
function setOffsetToParsedOffset () {
|
|
if (this._tzm) {
|
|
this.utcOffset(this._tzm);
|
|
} else if (typeof this._i === 'string') {
|
|
this.utcOffset(offsetFromString(this._i));
|
|
}
|
|
return this;
|
|
}
|
|
|
|
function hasAlignedHourOffset (input) {
|
|
if (!input) {
|
|
input = 0;
|
|
}
|
|
else {
|
|
input = local__createLocal(input).utcOffset();
|
|
}
|
|
|
|
return (this.utcOffset() - input) % 60 === 0;
|
|
}
|
|
|
|
function isDaylightSavingTime () {
|
|
return (
|
|
this.utcOffset() > this.clone().month(0).utcOffset() ||
|
|
this.utcOffset() > this.clone().month(5).utcOffset()
|
|
);
|
|
}
|
|
|
|
function isDaylightSavingTimeShifted () {
|
|
if (this._a) {
|
|
var other = this._isUTC ? create_utc__createUTC(this._a) : local__createLocal(this._a);
|
|
return this.isValid() && compareArrays(this._a, other.toArray()) > 0;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
function isLocal () {
|
|
return !this._isUTC;
|
|
}
|
|
|
|
function isUtcOffset () {
|
|
return this._isUTC;
|
|
}
|
|
|
|
function isUtc () {
|
|
return this._isUTC && this._offset === 0;
|
|
}
|
|
|
|
var aspNetRegex = /(\-)?(?:(\d*)\.)?(\d+)\:(\d+)(?:\:(\d+)\.?(\d{3})?)?/;
|
|
|
|
// from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
|
|
// somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
|
|
var create__isoRegex = /^(-)?P(?:(?:([0-9,.]*)Y)?(?:([0-9,.]*)M)?(?:([0-9,.]*)D)?(?:T(?:([0-9,.]*)H)?(?:([0-9,.]*)M)?(?:([0-9,.]*)S)?)?|([0-9,.]*)W)$/;
|
|
|
|
function create__createDuration (input, key) {
|
|
var duration = input,
|
|
// matching against regexp is expensive, do it on demand
|
|
match = null,
|
|
sign,
|
|
ret,
|
|
diffRes;
|
|
|
|
if (isDuration(input)) {
|
|
duration = {
|
|
ms : input._milliseconds,
|
|
d : input._days,
|
|
M : input._months
|
|
};
|
|
} else if (typeof input === 'number') {
|
|
duration = {};
|
|
if (key) {
|
|
duration[key] = input;
|
|
} else {
|
|
duration.milliseconds = input;
|
|
}
|
|
} else if (!!(match = aspNetRegex.exec(input))) {
|
|
sign = (match[1] === '-') ? -1 : 1;
|
|
duration = {
|
|
y : 0,
|
|
d : toInt(match[DATE]) * sign,
|
|
h : toInt(match[HOUR]) * sign,
|
|
m : toInt(match[MINUTE]) * sign,
|
|
s : toInt(match[SECOND]) * sign,
|
|
ms : toInt(match[MILLISECOND]) * sign
|
|
};
|
|
} else if (!!(match = create__isoRegex.exec(input))) {
|
|
sign = (match[1] === '-') ? -1 : 1;
|
|
duration = {
|
|
y : parseIso(match[2], sign),
|
|
M : parseIso(match[3], sign),
|
|
d : parseIso(match[4], sign),
|
|
h : parseIso(match[5], sign),
|
|
m : parseIso(match[6], sign),
|
|
s : parseIso(match[7], sign),
|
|
w : parseIso(match[8], sign)
|
|
};
|
|
} else if (duration == null) {// checks for null or undefined
|
|
duration = {};
|
|
} else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
|
|
diffRes = momentsDifference(local__createLocal(duration.from), local__createLocal(duration.to));
|
|
|
|
duration = {};
|
|
duration.ms = diffRes.milliseconds;
|
|
duration.M = diffRes.months;
|
|
}
|
|
|
|
ret = new Duration(duration);
|
|
|
|
if (isDuration(input) && hasOwnProp(input, '_locale')) {
|
|
ret._locale = input._locale;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
create__createDuration.fn = Duration.prototype;
|
|
|
|
function parseIso (inp, sign) {
|
|
// We'd normally use ~~inp for this, but unfortunately it also
|
|
// converts floats to ints.
|
|
// inp may be undefined, so careful calling replace on it.
|
|
var res = inp && parseFloat(inp.replace(',', '.'));
|
|
// apply sign while we're at it
|
|
return (isNaN(res) ? 0 : res) * sign;
|
|
}
|
|
|
|
function positiveMomentsDifference(base, other) {
|
|
var res = {milliseconds: 0, months: 0};
|
|
|
|
res.months = other.month() - base.month() +
|
|
(other.year() - base.year()) * 12;
|
|
if (base.clone().add(res.months, 'M').isAfter(other)) {
|
|
--res.months;
|
|
}
|
|
|
|
res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
|
|
|
|
return res;
|
|
}
|
|
|
|
function momentsDifference(base, other) {
|
|
var res;
|
|
other = cloneWithOffset(other, base);
|
|
if (base.isBefore(other)) {
|
|
res = positiveMomentsDifference(base, other);
|
|
} else {
|
|
res = positiveMomentsDifference(other, base);
|
|
res.milliseconds = -res.milliseconds;
|
|
res.months = -res.months;
|
|
}
|
|
|
|
return res;
|
|
}
|
|
|
|
function createAdder(direction, name) {
|
|
return function (val, period) {
|
|
var dur, tmp;
|
|
//invert the arguments, but complain about it
|
|
if (period !== null && !isNaN(+period)) {
|
|
deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period).');
|
|
tmp = val; val = period; period = tmp;
|
|
}
|
|
|
|
val = typeof val === 'string' ? +val : val;
|
|
dur = create__createDuration(val, period);
|
|
add_subtract__addSubtract(this, dur, direction);
|
|
return this;
|
|
};
|
|
}
|
|
|
|
function add_subtract__addSubtract (mom, duration, isAdding, updateOffset) {
|
|
var milliseconds = duration._milliseconds,
|
|
days = duration._days,
|
|
months = duration._months;
|
|
updateOffset = updateOffset == null ? true : updateOffset;
|
|
|
|
if (milliseconds) {
|
|
mom._d.setTime(+mom._d + milliseconds * isAdding);
|
|
}
|
|
if (days) {
|
|
get_set__set(mom, 'Date', get_set__get(mom, 'Date') + days * isAdding);
|
|
}
|
|
if (months) {
|
|
setMonth(mom, get_set__get(mom, 'Month') + months * isAdding);
|
|
}
|
|
if (updateOffset) {
|
|
utils_hooks__hooks.updateOffset(mom, days || months);
|
|
}
|
|
}
|
|
|
|
var add_subtract__add = createAdder(1, 'add');
|
|
var add_subtract__subtract = createAdder(-1, 'subtract');
|
|
|
|
function moment_calendar__calendar (time) {
|
|
// We want to compare the start of today, vs this.
|
|
// Getting start-of-today depends on whether we're local/utc/offset or not.
|
|
var now = time || local__createLocal(),
|
|
sod = cloneWithOffset(now, this).startOf('day'),
|
|
diff = this.diff(sod, 'days', true),
|
|
format = diff < -6 ? 'sameElse' :
|
|
diff < -1 ? 'lastWeek' :
|
|
diff < 0 ? 'lastDay' :
|
|
diff < 1 ? 'sameDay' :
|
|
diff < 2 ? 'nextDay' :
|
|
diff < 7 ? 'nextWeek' : 'sameElse';
|
|
return this.format(this.localeData().calendar(format, this, local__createLocal(now)));
|
|
}
|
|
|
|
function clone () {
|
|
return new Moment(this);
|
|
}
|
|
|
|
function isAfter (input, units) {
|
|
var inputMs;
|
|
units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
|
|
if (units === 'millisecond') {
|
|
input = isMoment(input) ? input : local__createLocal(input);
|
|
return +this > +input;
|
|
} else {
|
|
inputMs = isMoment(input) ? +input : +local__createLocal(input);
|
|
return inputMs < +this.clone().startOf(units);
|
|
}
|
|
}
|
|
|
|
function isBefore (input, units) {
|
|
var inputMs;
|
|
units = normalizeUnits(typeof units !== 'undefined' ? units : 'millisecond');
|
|
if (units === 'millisecond') {
|
|
input = isMoment(input) ? input : local__createLocal(input);
|
|
return +this < +input;
|
|
} else {
|
|
inputMs = isMoment(input) ? +input : +local__createLocal(input);
|
|
return +this.clone().endOf(units) < inputMs;
|
|
}
|
|
}
|
|
|
|
function isBetween (from, to, units) {
|
|
return this.isAfter(from, units) && this.isBefore(to, units);
|
|
}
|
|
|
|
function isSame (input, units) {
|
|
var inputMs;
|
|
units = normalizeUnits(units || 'millisecond');
|
|
if (units === 'millisecond') {
|
|
input = isMoment(input) ? input : local__createLocal(input);
|
|
return +this === +input;
|
|
} else {
|
|
inputMs = +local__createLocal(input);
|
|
return +(this.clone().startOf(units)) <= inputMs && inputMs <= +(this.clone().endOf(units));
|
|
}
|
|
}
|
|
|
|
function absFloor (number) {
|
|
if (number < 0) {
|
|
return Math.ceil(number);
|
|
} else {
|
|
return Math.floor(number);
|
|
}
|
|
}
|
|
|
|
function diff (input, units, asFloat) {
|
|
var that = cloneWithOffset(input, this),
|
|
zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4,
|
|
delta, output;
|
|
|
|
units = normalizeUnits(units);
|
|
|
|
if (units === 'year' || units === 'month' || units === 'quarter') {
|
|
output = monthDiff(this, that);
|
|
if (units === 'quarter') {
|
|
output = output / 3;
|
|
} else if (units === 'year') {
|
|
output = output / 12;
|
|
}
|
|
} else {
|
|
delta = this - that;
|
|
output = units === 'second' ? delta / 1e3 : // 1000
|
|
units === 'minute' ? delta / 6e4 : // 1000 * 60
|
|
units === 'hour' ? delta / 36e5 : // 1000 * 60 * 60
|
|
units === 'day' ? (delta - zoneDelta) / 864e5 : // 1000 * 60 * 60 * 24, negate dst
|
|
units === 'week' ? (delta - zoneDelta) / 6048e5 : // 1000 * 60 * 60 * 24 * 7, negate dst
|
|
delta;
|
|
}
|
|
return asFloat ? output : absFloor(output);
|
|
}
|
|
|
|
function monthDiff (a, b) {
|
|
// difference in months
|
|
var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
|
|
// b is in (anchor - 1 month, anchor + 1 month)
|
|
anchor = a.clone().add(wholeMonthDiff, 'months'),
|
|
anchor2, adjust;
|
|
|
|
if (b - anchor < 0) {
|
|
anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
|
|
// linear across the month
|
|
adjust = (b - anchor) / (anchor - anchor2);
|
|
} else {
|
|
anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
|
|
// linear across the month
|
|
adjust = (b - anchor) / (anchor2 - anchor);
|
|
}
|
|
|
|
return -(wholeMonthDiff + adjust);
|
|
}
|
|
|
|
utils_hooks__hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
|
|
|
|
function toString () {
|
|
return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
|
|
}
|
|
|
|
function moment_format__toISOString () {
|
|
var m = this.clone().utc();
|
|
if (0 < m.year() && m.year() <= 9999) {
|
|
if ('function' === typeof Date.prototype.toISOString) {
|
|
// native implementation is ~50x faster, use it when we can
|
|
return this.toDate().toISOString();
|
|
} else {
|
|
return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
|
|
}
|
|
} else {
|
|
return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
|
|
}
|
|
}
|
|
|
|
function format (inputString) {
|
|
var output = formatMoment(this, inputString || utils_hooks__hooks.defaultFormat);
|
|
return this.localeData().postformat(output);
|
|
}
|
|
|
|
function from (time, withoutSuffix) {
|
|
if (!this.isValid()) {
|
|
return this.localeData().invalidDate();
|
|
}
|
|
return create__createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
|
|
}
|
|
|
|
function fromNow (withoutSuffix) {
|
|
return this.from(local__createLocal(), withoutSuffix);
|
|
}
|
|
|
|
function to (time, withoutSuffix) {
|
|
if (!this.isValid()) {
|
|
return this.localeData().invalidDate();
|
|
}
|
|
return create__createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
|
|
}
|
|
|
|
function toNow (withoutSuffix) {
|
|
return this.to(local__createLocal(), withoutSuffix);
|
|
}
|
|
|
|
function locale (key) {
|
|
var newLocaleData;
|
|
|
|
if (key === undefined) {
|
|
return this._locale._abbr;
|
|
} else {
|
|
newLocaleData = locale_locales__getLocale(key);
|
|
if (newLocaleData != null) {
|
|
this._locale = newLocaleData;
|
|
}
|
|
return this;
|
|
}
|
|
}
|
|
|
|
var lang = deprecate(
|
|
'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
|
|
function (key) {
|
|
if (key === undefined) {
|
|
return this.localeData();
|
|
} else {
|
|
return this.locale(key);
|
|
}
|
|
}
|
|
);
|
|
|
|
function localeData () {
|
|
return this._locale;
|
|
}
|
|
|
|
function startOf (units) {
|
|
units = normalizeUnits(units);
|
|
// the following switch intentionally omits break keywords
|
|
// to utilize falling through the cases.
|
|
switch (units) {
|
|
case 'year':
|
|
this.month(0);
|
|
/* falls through */
|
|
case 'quarter':
|
|
case 'month':
|
|
this.date(1);
|
|
/* falls through */
|
|
case 'week':
|
|
case 'isoWeek':
|
|
case 'day':
|
|
this.hours(0);
|
|
/* falls through */
|
|
case 'hour':
|
|
this.minutes(0);
|
|
/* falls through */
|
|
case 'minute':
|
|
this.seconds(0);
|
|
/* falls through */
|
|
case 'second':
|
|
this.milliseconds(0);
|
|
}
|
|
|
|
// weeks are a special case
|
|
if (units === 'week') {
|
|
this.weekday(0);
|
|
}
|
|
if (units === 'isoWeek') {
|
|
this.isoWeekday(1);
|
|
}
|
|
|
|
// quarters are also special
|
|
if (units === 'quarter') {
|
|
this.month(Math.floor(this.month() / 3) * 3);
|
|
}
|
|
|
|
return this;
|
|
}
|
|
|
|
function endOf (units) {
|
|
units = normalizeUnits(units);
|
|
if (units === undefined || units === 'millisecond') {
|
|
return this;
|
|
}
|
|
return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
|
|
}
|
|
|
|
function to_type__valueOf () {
|
|
return +this._d - ((this._offset || 0) * 60000);
|
|
}
|
|
|
|
function unix () {
|
|
return Math.floor(+this / 1000);
|
|
}
|
|
|
|
function toDate () {
|
|
return this._offset ? new Date(+this) : this._d;
|
|
}
|
|
|
|
function toArray () {
|
|
var m = this;
|
|
return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
|
|
}
|
|
|
|
function moment_valid__isValid () {
|
|
return valid__isValid(this);
|
|
}
|
|
|
|
function parsingFlags () {
|
|
return extend({}, getParsingFlags(this));
|
|
}
|
|
|
|
function invalidAt () {
|
|
return getParsingFlags(this).overflow;
|
|
}
|
|
|
|
addFormatToken(0, ['gg', 2], 0, function () {
|
|
return this.weekYear() % 100;
|
|
});
|
|
|
|
addFormatToken(0, ['GG', 2], 0, function () {
|
|
return this.isoWeekYear() % 100;
|
|
});
|
|
|
|
function addWeekYearFormatToken (token, getter) {
|
|
addFormatToken(0, [token, token.length], 0, getter);
|
|
}
|
|
|
|
addWeekYearFormatToken('gggg', 'weekYear');
|
|
addWeekYearFormatToken('ggggg', 'weekYear');
|
|
addWeekYearFormatToken('GGGG', 'isoWeekYear');
|
|
addWeekYearFormatToken('GGGGG', 'isoWeekYear');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('weekYear', 'gg');
|
|
addUnitAlias('isoWeekYear', 'GG');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('G', matchSigned);
|
|
addRegexToken('g', matchSigned);
|
|
addRegexToken('GG', match1to2, match2);
|
|
addRegexToken('gg', match1to2, match2);
|
|
addRegexToken('GGGG', match1to4, match4);
|
|
addRegexToken('gggg', match1to4, match4);
|
|
addRegexToken('GGGGG', match1to6, match6);
|
|
addRegexToken('ggggg', match1to6, match6);
|
|
|
|
addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
|
|
week[token.substr(0, 2)] = toInt(input);
|
|
});
|
|
|
|
addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
|
|
week[token] = utils_hooks__hooks.parseTwoDigitYear(input);
|
|
});
|
|
|
|
// HELPERS
|
|
|
|
function weeksInYear(year, dow, doy) {
|
|
return weekOfYear(local__createLocal([year, 11, 31 + dow - doy]), dow, doy).week;
|
|
}
|
|
|
|
// MOMENTS
|
|
|
|
function getSetWeekYear (input) {
|
|
var year = weekOfYear(this, this.localeData()._week.dow, this.localeData()._week.doy).year;
|
|
return input == null ? year : this.add((input - year), 'y');
|
|
}
|
|
|
|
function getSetISOWeekYear (input) {
|
|
var year = weekOfYear(this, 1, 4).year;
|
|
return input == null ? year : this.add((input - year), 'y');
|
|
}
|
|
|
|
function getISOWeeksInYear () {
|
|
return weeksInYear(this.year(), 1, 4);
|
|
}
|
|
|
|
function getWeeksInYear () {
|
|
var weekInfo = this.localeData()._week;
|
|
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
|
|
}
|
|
|
|
addFormatToken('Q', 0, 0, 'quarter');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('quarter', 'Q');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('Q', match1);
|
|
addParseToken('Q', function (input, array) {
|
|
array[MONTH] = (toInt(input) - 1) * 3;
|
|
});
|
|
|
|
// MOMENTS
|
|
|
|
function getSetQuarter (input) {
|
|
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
|
|
}
|
|
|
|
addFormatToken('D', ['DD', 2], 'Do', 'date');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('date', 'D');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('D', match1to2);
|
|
addRegexToken('DD', match1to2, match2);
|
|
addRegexToken('Do', function (isStrict, locale) {
|
|
return isStrict ? locale._ordinalParse : locale._ordinalParseLenient;
|
|
});
|
|
|
|
addParseToken(['D', 'DD'], DATE);
|
|
addParseToken('Do', function (input, array) {
|
|
array[DATE] = toInt(input.match(match1to2)[0], 10);
|
|
});
|
|
|
|
// MOMENTS
|
|
|
|
var getSetDayOfMonth = makeGetSet('Date', true);
|
|
|
|
addFormatToken('d', 0, 'do', 'day');
|
|
|
|
addFormatToken('dd', 0, 0, function (format) {
|
|
return this.localeData().weekdaysMin(this, format);
|
|
});
|
|
|
|
addFormatToken('ddd', 0, 0, function (format) {
|
|
return this.localeData().weekdaysShort(this, format);
|
|
});
|
|
|
|
addFormatToken('dddd', 0, 0, function (format) {
|
|
return this.localeData().weekdays(this, format);
|
|
});
|
|
|
|
addFormatToken('e', 0, 0, 'weekday');
|
|
addFormatToken('E', 0, 0, 'isoWeekday');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('day', 'd');
|
|
addUnitAlias('weekday', 'e');
|
|
addUnitAlias('isoWeekday', 'E');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('d', match1to2);
|
|
addRegexToken('e', match1to2);
|
|
addRegexToken('E', match1to2);
|
|
addRegexToken('dd', matchWord);
|
|
addRegexToken('ddd', matchWord);
|
|
addRegexToken('dddd', matchWord);
|
|
|
|
addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config) {
|
|
var weekday = config._locale.weekdaysParse(input);
|
|
// if we didn't get a weekday name, mark the date as invalid
|
|
if (weekday != null) {
|
|
week.d = weekday;
|
|
} else {
|
|
getParsingFlags(config).invalidWeekday = input;
|
|
}
|
|
});
|
|
|
|
addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
|
|
week[token] = toInt(input);
|
|
});
|
|
|
|
// HELPERS
|
|
|
|
function parseWeekday(input, locale) {
|
|
if (typeof input === 'string') {
|
|
if (!isNaN(input)) {
|
|
input = parseInt(input, 10);
|
|
}
|
|
else {
|
|
input = locale.weekdaysParse(input);
|
|
if (typeof input !== 'number') {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
return input;
|
|
}
|
|
|
|
// LOCALES
|
|
|
|
var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
|
|
function localeWeekdays (m) {
|
|
return this._weekdays[m.day()];
|
|
}
|
|
|
|
var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
|
|
function localeWeekdaysShort (m) {
|
|
return this._weekdaysShort[m.day()];
|
|
}
|
|
|
|
var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
|
|
function localeWeekdaysMin (m) {
|
|
return this._weekdaysMin[m.day()];
|
|
}
|
|
|
|
function localeWeekdaysParse (weekdayName) {
|
|
var i, mom, regex;
|
|
|
|
if (!this._weekdaysParse) {
|
|
this._weekdaysParse = [];
|
|
}
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
// make the regex if we don't have it already
|
|
if (!this._weekdaysParse[i]) {
|
|
mom = local__createLocal([2000, 1]).day(i);
|
|
regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
|
|
this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
|
|
}
|
|
// test the regex
|
|
if (this._weekdaysParse[i].test(weekdayName)) {
|
|
return i;
|
|
}
|
|
}
|
|
}
|
|
|
|
// MOMENTS
|
|
|
|
function getSetDayOfWeek (input) {
|
|
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
|
|
if (input != null) {
|
|
input = parseWeekday(input, this.localeData());
|
|
return this.add(input - day, 'd');
|
|
} else {
|
|
return day;
|
|
}
|
|
}
|
|
|
|
function getSetLocaleDayOfWeek (input) {
|
|
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
|
|
return input == null ? weekday : this.add(input - weekday, 'd');
|
|
}
|
|
|
|
function getSetISODayOfWeek (input) {
|
|
// behaves the same as moment#day except
|
|
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
|
|
// as a setter, sunday should belong to the previous week.
|
|
return input == null ? this.day() || 7 : this.day(this.day() % 7 ? input : input - 7);
|
|
}
|
|
|
|
addFormatToken('H', ['HH', 2], 0, 'hour');
|
|
addFormatToken('h', ['hh', 2], 0, function () {
|
|
return this.hours() % 12 || 12;
|
|
});
|
|
|
|
function meridiem (token, lowercase) {
|
|
addFormatToken(token, 0, 0, function () {
|
|
return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
|
|
});
|
|
}
|
|
|
|
meridiem('a', true);
|
|
meridiem('A', false);
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('hour', 'h');
|
|
|
|
// PARSING
|
|
|
|
function matchMeridiem (isStrict, locale) {
|
|
return locale._meridiemParse;
|
|
}
|
|
|
|
addRegexToken('a', matchMeridiem);
|
|
addRegexToken('A', matchMeridiem);
|
|
addRegexToken('H', match1to2);
|
|
addRegexToken('h', match1to2);
|
|
addRegexToken('HH', match1to2, match2);
|
|
addRegexToken('hh', match1to2, match2);
|
|
|
|
addParseToken(['H', 'HH'], HOUR);
|
|
addParseToken(['a', 'A'], function (input, array, config) {
|
|
config._isPm = config._locale.isPM(input);
|
|
config._meridiem = input;
|
|
});
|
|
addParseToken(['h', 'hh'], function (input, array, config) {
|
|
array[HOUR] = toInt(input);
|
|
getParsingFlags(config).bigHour = true;
|
|
});
|
|
|
|
// LOCALES
|
|
|
|
function localeIsPM (input) {
|
|
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
|
|
// Using charAt should be more compatible.
|
|
return ((input + '').toLowerCase().charAt(0) === 'p');
|
|
}
|
|
|
|
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
|
|
function localeMeridiem (hours, minutes, isLower) {
|
|
if (hours > 11) {
|
|
return isLower ? 'pm' : 'PM';
|
|
} else {
|
|
return isLower ? 'am' : 'AM';
|
|
}
|
|
}
|
|
|
|
|
|
// MOMENTS
|
|
|
|
// Setting the hour should keep the time, because the user explicitly
|
|
// specified which hour he wants. So trying to maintain the same hour (in
|
|
// a new timezone) makes sense. Adding/subtracting hours does not follow
|
|
// this rule.
|
|
var getSetHour = makeGetSet('Hours', true);
|
|
|
|
addFormatToken('m', ['mm', 2], 0, 'minute');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('minute', 'm');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('m', match1to2);
|
|
addRegexToken('mm', match1to2, match2);
|
|
addParseToken(['m', 'mm'], MINUTE);
|
|
|
|
// MOMENTS
|
|
|
|
var getSetMinute = makeGetSet('Minutes', false);
|
|
|
|
addFormatToken('s', ['ss', 2], 0, 'second');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('second', 's');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('s', match1to2);
|
|
addRegexToken('ss', match1to2, match2);
|
|
addParseToken(['s', 'ss'], SECOND);
|
|
|
|
// MOMENTS
|
|
|
|
var getSetSecond = makeGetSet('Seconds', false);
|
|
|
|
addFormatToken('S', 0, 0, function () {
|
|
return ~~(this.millisecond() / 100);
|
|
});
|
|
|
|
addFormatToken(0, ['SS', 2], 0, function () {
|
|
return ~~(this.millisecond() / 10);
|
|
});
|
|
|
|
function millisecond__milliseconds (token) {
|
|
addFormatToken(0, [token, 3], 0, 'millisecond');
|
|
}
|
|
|
|
millisecond__milliseconds('SSS');
|
|
millisecond__milliseconds('SSSS');
|
|
|
|
// ALIASES
|
|
|
|
addUnitAlias('millisecond', 'ms');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('S', match1to3, match1);
|
|
addRegexToken('SS', match1to3, match2);
|
|
addRegexToken('SSS', match1to3, match3);
|
|
addRegexToken('SSSS', matchUnsigned);
|
|
addParseToken(['S', 'SS', 'SSS', 'SSSS'], function (input, array) {
|
|
array[MILLISECOND] = toInt(('0.' + input) * 1000);
|
|
});
|
|
|
|
// MOMENTS
|
|
|
|
var getSetMillisecond = makeGetSet('Milliseconds', false);
|
|
|
|
addFormatToken('z', 0, 0, 'zoneAbbr');
|
|
addFormatToken('zz', 0, 0, 'zoneName');
|
|
|
|
// MOMENTS
|
|
|
|
function getZoneAbbr () {
|
|
return this._isUTC ? 'UTC' : '';
|
|
}
|
|
|
|
function getZoneName () {
|
|
return this._isUTC ? 'Coordinated Universal Time' : '';
|
|
}
|
|
|
|
var momentPrototype__proto = Moment.prototype;
|
|
|
|
momentPrototype__proto.add = add_subtract__add;
|
|
momentPrototype__proto.calendar = moment_calendar__calendar;
|
|
momentPrototype__proto.clone = clone;
|
|
momentPrototype__proto.diff = diff;
|
|
momentPrototype__proto.endOf = endOf;
|
|
momentPrototype__proto.format = format;
|
|
momentPrototype__proto.from = from;
|
|
momentPrototype__proto.fromNow = fromNow;
|
|
momentPrototype__proto.to = to;
|
|
momentPrototype__proto.toNow = toNow;
|
|
momentPrototype__proto.get = getSet;
|
|
momentPrototype__proto.invalidAt = invalidAt;
|
|
momentPrototype__proto.isAfter = isAfter;
|
|
momentPrototype__proto.isBefore = isBefore;
|
|
momentPrototype__proto.isBetween = isBetween;
|
|
momentPrototype__proto.isSame = isSame;
|
|
momentPrototype__proto.isValid = moment_valid__isValid;
|
|
momentPrototype__proto.lang = lang;
|
|
momentPrototype__proto.locale = locale;
|
|
momentPrototype__proto.localeData = localeData;
|
|
momentPrototype__proto.max = prototypeMax;
|
|
momentPrototype__proto.min = prototypeMin;
|
|
momentPrototype__proto.parsingFlags = parsingFlags;
|
|
momentPrototype__proto.set = getSet;
|
|
momentPrototype__proto.startOf = startOf;
|
|
momentPrototype__proto.subtract = add_subtract__subtract;
|
|
momentPrototype__proto.toArray = toArray;
|
|
momentPrototype__proto.toDate = toDate;
|
|
momentPrototype__proto.toISOString = moment_format__toISOString;
|
|
momentPrototype__proto.toJSON = moment_format__toISOString;
|
|
momentPrototype__proto.toString = toString;
|
|
momentPrototype__proto.unix = unix;
|
|
momentPrototype__proto.valueOf = to_type__valueOf;
|
|
|
|
// Year
|
|
momentPrototype__proto.year = getSetYear;
|
|
momentPrototype__proto.isLeapYear = getIsLeapYear;
|
|
|
|
// Week Year
|
|
momentPrototype__proto.weekYear = getSetWeekYear;
|
|
momentPrototype__proto.isoWeekYear = getSetISOWeekYear;
|
|
|
|
// Quarter
|
|
momentPrototype__proto.quarter = momentPrototype__proto.quarters = getSetQuarter;
|
|
|
|
// Month
|
|
momentPrototype__proto.month = getSetMonth;
|
|
momentPrototype__proto.daysInMonth = getDaysInMonth;
|
|
|
|
// Week
|
|
momentPrototype__proto.week = momentPrototype__proto.weeks = getSetWeek;
|
|
momentPrototype__proto.isoWeek = momentPrototype__proto.isoWeeks = getSetISOWeek;
|
|
momentPrototype__proto.weeksInYear = getWeeksInYear;
|
|
momentPrototype__proto.isoWeeksInYear = getISOWeeksInYear;
|
|
|
|
// Day
|
|
momentPrototype__proto.date = getSetDayOfMonth;
|
|
momentPrototype__proto.day = momentPrototype__proto.days = getSetDayOfWeek;
|
|
momentPrototype__proto.weekday = getSetLocaleDayOfWeek;
|
|
momentPrototype__proto.isoWeekday = getSetISODayOfWeek;
|
|
momentPrototype__proto.dayOfYear = getSetDayOfYear;
|
|
|
|
// Hour
|
|
momentPrototype__proto.hour = momentPrototype__proto.hours = getSetHour;
|
|
|
|
// Minute
|
|
momentPrototype__proto.minute = momentPrototype__proto.minutes = getSetMinute;
|
|
|
|
// Second
|
|
momentPrototype__proto.second = momentPrototype__proto.seconds = getSetSecond;
|
|
|
|
// Millisecond
|
|
momentPrototype__proto.millisecond = momentPrototype__proto.milliseconds = getSetMillisecond;
|
|
|
|
// Offset
|
|
momentPrototype__proto.utcOffset = getSetOffset;
|
|
momentPrototype__proto.utc = setOffsetToUTC;
|
|
momentPrototype__proto.local = setOffsetToLocal;
|
|
momentPrototype__proto.parseZone = setOffsetToParsedOffset;
|
|
momentPrototype__proto.hasAlignedHourOffset = hasAlignedHourOffset;
|
|
momentPrototype__proto.isDST = isDaylightSavingTime;
|
|
momentPrototype__proto.isDSTShifted = isDaylightSavingTimeShifted;
|
|
momentPrototype__proto.isLocal = isLocal;
|
|
momentPrototype__proto.isUtcOffset = isUtcOffset;
|
|
momentPrototype__proto.isUtc = isUtc;
|
|
momentPrototype__proto.isUTC = isUtc;
|
|
|
|
// Timezone
|
|
momentPrototype__proto.zoneAbbr = getZoneAbbr;
|
|
momentPrototype__proto.zoneName = getZoneName;
|
|
|
|
// Deprecations
|
|
momentPrototype__proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
|
|
momentPrototype__proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
|
|
momentPrototype__proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
|
|
momentPrototype__proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. https://github.com/moment/moment/issues/1779', getSetZone);
|
|
|
|
var momentPrototype = momentPrototype__proto;
|
|
|
|
function moment__createUnix (input) {
|
|
return local__createLocal(input * 1000);
|
|
}
|
|
|
|
function moment__createInZone () {
|
|
return local__createLocal.apply(null, arguments).parseZone();
|
|
}
|
|
|
|
var defaultCalendar = {
|
|
sameDay : '[Today at] LT',
|
|
nextDay : '[Tomorrow at] LT',
|
|
nextWeek : 'dddd [at] LT',
|
|
lastDay : '[Yesterday at] LT',
|
|
lastWeek : '[Last] dddd [at] LT',
|
|
sameElse : 'L'
|
|
};
|
|
|
|
function locale_calendar__calendar (key, mom, now) {
|
|
var output = this._calendar[key];
|
|
return typeof output === 'function' ? output.call(mom, now) : output;
|
|
}
|
|
|
|
var defaultLongDateFormat = {
|
|
LTS : 'h:mm:ss A',
|
|
LT : 'h:mm A',
|
|
L : 'MM/DD/YYYY',
|
|
LL : 'MMMM D, YYYY',
|
|
LLL : 'MMMM D, YYYY LT',
|
|
LLLL : 'dddd, MMMM D, YYYY LT'
|
|
};
|
|
|
|
function longDateFormat (key) {
|
|
var output = this._longDateFormat[key];
|
|
if (!output && this._longDateFormat[key.toUpperCase()]) {
|
|
output = this._longDateFormat[key.toUpperCase()].replace(/MMMM|MM|DD|dddd/g, function (val) {
|
|
return val.slice(1);
|
|
});
|
|
this._longDateFormat[key] = output;
|
|
}
|
|
return output;
|
|
}
|
|
|
|
var defaultInvalidDate = 'Invalid date';
|
|
|
|
function invalidDate () {
|
|
return this._invalidDate;
|
|
}
|
|
|
|
var defaultOrdinal = '%d';
|
|
var defaultOrdinalParse = /\d{1,2}/;
|
|
|
|
function ordinal (number) {
|
|
return this._ordinal.replace('%d', number);
|
|
}
|
|
|
|
function preParsePostFormat (string) {
|
|
return string;
|
|
}
|
|
|
|
var defaultRelativeTime = {
|
|
future : 'in %s',
|
|
past : '%s ago',
|
|
s : 'a few seconds',
|
|
m : 'a minute',
|
|
mm : '%d minutes',
|
|
h : 'an hour',
|
|
hh : '%d hours',
|
|
d : 'a day',
|
|
dd : '%d days',
|
|
M : 'a month',
|
|
MM : '%d months',
|
|
y : 'a year',
|
|
yy : '%d years'
|
|
};
|
|
|
|
function relative__relativeTime (number, withoutSuffix, string, isFuture) {
|
|
var output = this._relativeTime[string];
|
|
return (typeof output === 'function') ?
|
|
output(number, withoutSuffix, string, isFuture) :
|
|
output.replace(/%d/i, number);
|
|
}
|
|
|
|
function pastFuture (diff, output) {
|
|
var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
|
|
return typeof format === 'function' ? format(output) : format.replace(/%s/i, output);
|
|
}
|
|
|
|
function locale_set__set (config) {
|
|
var prop, i;
|
|
for (i in config) {
|
|
prop = config[i];
|
|
if (typeof prop === 'function') {
|
|
this[i] = prop;
|
|
} else {
|
|
this['_' + i] = prop;
|
|
}
|
|
}
|
|
// Lenient ordinal parsing accepts just a number in addition to
|
|
// number + (possibly) stuff coming from _ordinalParseLenient.
|
|
this._ordinalParseLenient = new RegExp(this._ordinalParse.source + '|' + (/\d{1,2}/).source);
|
|
}
|
|
|
|
var prototype__proto = Locale.prototype;
|
|
|
|
prototype__proto._calendar = defaultCalendar;
|
|
prototype__proto.calendar = locale_calendar__calendar;
|
|
prototype__proto._longDateFormat = defaultLongDateFormat;
|
|
prototype__proto.longDateFormat = longDateFormat;
|
|
prototype__proto._invalidDate = defaultInvalidDate;
|
|
prototype__proto.invalidDate = invalidDate;
|
|
prototype__proto._ordinal = defaultOrdinal;
|
|
prototype__proto.ordinal = ordinal;
|
|
prototype__proto._ordinalParse = defaultOrdinalParse;
|
|
prototype__proto.preparse = preParsePostFormat;
|
|
prototype__proto.postformat = preParsePostFormat;
|
|
prototype__proto._relativeTime = defaultRelativeTime;
|
|
prototype__proto.relativeTime = relative__relativeTime;
|
|
prototype__proto.pastFuture = pastFuture;
|
|
prototype__proto.set = locale_set__set;
|
|
|
|
// Month
|
|
prototype__proto.months = localeMonths;
|
|
prototype__proto._months = defaultLocaleMonths;
|
|
prototype__proto.monthsShort = localeMonthsShort;
|
|
prototype__proto._monthsShort = defaultLocaleMonthsShort;
|
|
prototype__proto.monthsParse = localeMonthsParse;
|
|
|
|
// Week
|
|
prototype__proto.week = localeWeek;
|
|
prototype__proto._week = defaultLocaleWeek;
|
|
prototype__proto.firstDayOfYear = localeFirstDayOfYear;
|
|
prototype__proto.firstDayOfWeek = localeFirstDayOfWeek;
|
|
|
|
// Day of Week
|
|
prototype__proto.weekdays = localeWeekdays;
|
|
prototype__proto._weekdays = defaultLocaleWeekdays;
|
|
prototype__proto.weekdaysMin = localeWeekdaysMin;
|
|
prototype__proto._weekdaysMin = defaultLocaleWeekdaysMin;
|
|
prototype__proto.weekdaysShort = localeWeekdaysShort;
|
|
prototype__proto._weekdaysShort = defaultLocaleWeekdaysShort;
|
|
prototype__proto.weekdaysParse = localeWeekdaysParse;
|
|
|
|
// Hours
|
|
prototype__proto.isPM = localeIsPM;
|
|
prototype__proto._meridiemParse = defaultLocaleMeridiemParse;
|
|
prototype__proto.meridiem = localeMeridiem;
|
|
|
|
function lists__get (format, index, field, setter) {
|
|
var locale = locale_locales__getLocale();
|
|
var utc = create_utc__createUTC().set(setter, index);
|
|
return locale[field](utc, format);
|
|
}
|
|
|
|
function list (format, index, field, count, setter) {
|
|
if (typeof format === 'number') {
|
|
index = format;
|
|
format = undefined;
|
|
}
|
|
|
|
format = format || '';
|
|
|
|
if (index != null) {
|
|
return lists__get(format, index, field, setter);
|
|
}
|
|
|
|
var i;
|
|
var out = [];
|
|
for (i = 0; i < count; i++) {
|
|
out[i] = lists__get(format, i, field, setter);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
function lists__listMonths (format, index) {
|
|
return list(format, index, 'months', 12, 'month');
|
|
}
|
|
|
|
function lists__listMonthsShort (format, index) {
|
|
return list(format, index, 'monthsShort', 12, 'month');
|
|
}
|
|
|
|
function lists__listWeekdays (format, index) {
|
|
return list(format, index, 'weekdays', 7, 'day');
|
|
}
|
|
|
|
function lists__listWeekdaysShort (format, index) {
|
|
return list(format, index, 'weekdaysShort', 7, 'day');
|
|
}
|
|
|
|
function lists__listWeekdaysMin (format, index) {
|
|
return list(format, index, 'weekdaysMin', 7, 'day');
|
|
}
|
|
|
|
locale_locales__getSetGlobalLocale('en', {
|
|
ordinalParse: /\d{1,2}(th|st|nd|rd)/,
|
|
ordinal : function (number) {
|
|
var b = number % 10,
|
|
output = (toInt(number % 100 / 10) === 1) ? 'th' :
|
|
(b === 1) ? 'st' :
|
|
(b === 2) ? 'nd' :
|
|
(b === 3) ? 'rd' : 'th';
|
|
return number + output;
|
|
}
|
|
});
|
|
|
|
// Side effect imports
|
|
utils_hooks__hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', locale_locales__getSetGlobalLocale);
|
|
utils_hooks__hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', locale_locales__getLocale);
|
|
|
|
var mathAbs = Math.abs;
|
|
|
|
function duration_abs__abs () {
|
|
var data = this._data;
|
|
|
|
this._milliseconds = mathAbs(this._milliseconds);
|
|
this._days = mathAbs(this._days);
|
|
this._months = mathAbs(this._months);
|
|
|
|
data.milliseconds = mathAbs(data.milliseconds);
|
|
data.seconds = mathAbs(data.seconds);
|
|
data.minutes = mathAbs(data.minutes);
|
|
data.hours = mathAbs(data.hours);
|
|
data.months = mathAbs(data.months);
|
|
data.years = mathAbs(data.years);
|
|
|
|
return this;
|
|
}
|
|
|
|
function duration_add_subtract__addSubtract (duration, input, value, direction) {
|
|
var other = create__createDuration(input, value);
|
|
|
|
duration._milliseconds += direction * other._milliseconds;
|
|
duration._days += direction * other._days;
|
|
duration._months += direction * other._months;
|
|
|
|
return duration._bubble();
|
|
}
|
|
|
|
// supports only 2.0-style add(1, 's') or add(duration)
|
|
function duration_add_subtract__add (input, value) {
|
|
return duration_add_subtract__addSubtract(this, input, value, 1);
|
|
}
|
|
|
|
// supports only 2.0-style subtract(1, 's') or subtract(duration)
|
|
function duration_add_subtract__subtract (input, value) {
|
|
return duration_add_subtract__addSubtract(this, input, value, -1);
|
|
}
|
|
|
|
function bubble () {
|
|
var milliseconds = this._milliseconds;
|
|
var days = this._days;
|
|
var months = this._months;
|
|
var data = this._data;
|
|
var seconds, minutes, hours, years = 0;
|
|
|
|
// The following code bubbles up values, see the tests for
|
|
// examples of what that means.
|
|
data.milliseconds = milliseconds % 1000;
|
|
|
|
seconds = absFloor(milliseconds / 1000);
|
|
data.seconds = seconds % 60;
|
|
|
|
minutes = absFloor(seconds / 60);
|
|
data.minutes = minutes % 60;
|
|
|
|
hours = absFloor(minutes / 60);
|
|
data.hours = hours % 24;
|
|
|
|
days += absFloor(hours / 24);
|
|
|
|
// Accurately convert days to years, assume start from year 0.
|
|
years = absFloor(daysToYears(days));
|
|
days -= absFloor(yearsToDays(years));
|
|
|
|
// 30 days to a month
|
|
// TODO (iskren): Use anchor date (like 1st Jan) to compute this.
|
|
months += absFloor(days / 30);
|
|
days %= 30;
|
|
|
|
// 12 months -> 1 year
|
|
years += absFloor(months / 12);
|
|
months %= 12;
|
|
|
|
data.days = days;
|
|
data.months = months;
|
|
data.years = years;
|
|
|
|
return this;
|
|
}
|
|
|
|
function daysToYears (days) {
|
|
// 400 years have 146097 days (taking into account leap year rules)
|
|
return days * 400 / 146097;
|
|
}
|
|
|
|
function yearsToDays (years) {
|
|
// years * 365 + absFloor(years / 4) -
|
|
// absFloor(years / 100) + absFloor(years / 400);
|
|
return years * 146097 / 400;
|
|
}
|
|
|
|
function as (units) {
|
|
var days;
|
|
var months;
|
|
var milliseconds = this._milliseconds;
|
|
|
|
units = normalizeUnits(units);
|
|
|
|
if (units === 'month' || units === 'year') {
|
|
days = this._days + milliseconds / 864e5;
|
|
months = this._months + daysToYears(days) * 12;
|
|
return units === 'month' ? months : months / 12;
|
|
} else {
|
|
// handle milliseconds separately because of floating point math errors (issue #1867)
|
|
days = this._days + Math.round(yearsToDays(this._months / 12));
|
|
switch (units) {
|
|
case 'week' : return days / 7 + milliseconds / 6048e5;
|
|
case 'day' : return days + milliseconds / 864e5;
|
|
case 'hour' : return days * 24 + milliseconds / 36e5;
|
|
case 'minute' : return days * 1440 + milliseconds / 6e4;
|
|
case 'second' : return days * 86400 + milliseconds / 1000;
|
|
// Math.floor prevents floating point math errors here
|
|
case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
|
|
default: throw new Error('Unknown unit ' + units);
|
|
}
|
|
}
|
|
}
|
|
|
|
// TODO: Use this.as('ms')?
|
|
function duration_as__valueOf () {
|
|
return (
|
|
this._milliseconds +
|
|
this._days * 864e5 +
|
|
(this._months % 12) * 2592e6 +
|
|
toInt(this._months / 12) * 31536e6
|
|
);
|
|
}
|
|
|
|
function makeAs (alias) {
|
|
return function () {
|
|
return this.as(alias);
|
|
};
|
|
}
|
|
|
|
var asMilliseconds = makeAs('ms');
|
|
var asSeconds = makeAs('s');
|
|
var asMinutes = makeAs('m');
|
|
var asHours = makeAs('h');
|
|
var asDays = makeAs('d');
|
|
var asWeeks = makeAs('w');
|
|
var asMonths = makeAs('M');
|
|
var asYears = makeAs('y');
|
|
|
|
function duration_get__get (units) {
|
|
units = normalizeUnits(units);
|
|
return this[units + 's']();
|
|
}
|
|
|
|
function makeGetter(name) {
|
|
return function () {
|
|
return this._data[name];
|
|
};
|
|
}
|
|
|
|
var duration_get__milliseconds = makeGetter('milliseconds');
|
|
var seconds = makeGetter('seconds');
|
|
var minutes = makeGetter('minutes');
|
|
var hours = makeGetter('hours');
|
|
var days = makeGetter('days');
|
|
var months = makeGetter('months');
|
|
var years = makeGetter('years');
|
|
|
|
function weeks () {
|
|
return absFloor(this.days() / 7);
|
|
}
|
|
|
|
var round = Math.round;
|
|
var thresholds = {
|
|
s: 45, // seconds to minute
|
|
m: 45, // minutes to hour
|
|
h: 22, // hours to day
|
|
d: 26, // days to month
|
|
M: 11 // months to year
|
|
};
|
|
|
|
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
|
|
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
|
|
return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
|
|
}
|
|
|
|
function duration_humanize__relativeTime (posNegDuration, withoutSuffix, locale) {
|
|
var duration = create__createDuration(posNegDuration).abs();
|
|
var seconds = round(duration.as('s'));
|
|
var minutes = round(duration.as('m'));
|
|
var hours = round(duration.as('h'));
|
|
var days = round(duration.as('d'));
|
|
var months = round(duration.as('M'));
|
|
var years = round(duration.as('y'));
|
|
|
|
var a = seconds < thresholds.s && ['s', seconds] ||
|
|
minutes === 1 && ['m'] ||
|
|
minutes < thresholds.m && ['mm', minutes] ||
|
|
hours === 1 && ['h'] ||
|
|
hours < thresholds.h && ['hh', hours] ||
|
|
days === 1 && ['d'] ||
|
|
days < thresholds.d && ['dd', days] ||
|
|
months === 1 && ['M'] ||
|
|
months < thresholds.M && ['MM', months] ||
|
|
years === 1 && ['y'] || ['yy', years];
|
|
|
|
a[2] = withoutSuffix;
|
|
a[3] = +posNegDuration > 0;
|
|
a[4] = locale;
|
|
return substituteTimeAgo.apply(null, a);
|
|
}
|
|
|
|
// This function allows you to set a threshold for relative time strings
|
|
function duration_humanize__getSetRelativeTimeThreshold (threshold, limit) {
|
|
if (thresholds[threshold] === undefined) {
|
|
return false;
|
|
}
|
|
if (limit === undefined) {
|
|
return thresholds[threshold];
|
|
}
|
|
thresholds[threshold] = limit;
|
|
return true;
|
|
}
|
|
|
|
function humanize (withSuffix) {
|
|
var locale = this.localeData();
|
|
var output = duration_humanize__relativeTime(this, !withSuffix, locale);
|
|
|
|
if (withSuffix) {
|
|
output = locale.pastFuture(+this, output);
|
|
}
|
|
|
|
return locale.postformat(output);
|
|
}
|
|
|
|
var iso_string__abs = Math.abs;
|
|
|
|
function iso_string__toISOString() {
|
|
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
|
|
var Y = iso_string__abs(this.years());
|
|
var M = iso_string__abs(this.months());
|
|
var D = iso_string__abs(this.days());
|
|
var h = iso_string__abs(this.hours());
|
|
var m = iso_string__abs(this.minutes());
|
|
var s = iso_string__abs(this.seconds() + this.milliseconds() / 1000);
|
|
var total = this.asSeconds();
|
|
|
|
if (!total) {
|
|
// this is the same as C#'s (Noda) and python (isodate)...
|
|
// but not other JS (goog.date)
|
|
return 'P0D';
|
|
}
|
|
|
|
return (total < 0 ? '-' : '') +
|
|
'P' +
|
|
(Y ? Y + 'Y' : '') +
|
|
(M ? M + 'M' : '') +
|
|
(D ? D + 'D' : '') +
|
|
((h || m || s) ? 'T' : '') +
|
|
(h ? h + 'H' : '') +
|
|
(m ? m + 'M' : '') +
|
|
(s ? s + 'S' : '');
|
|
}
|
|
|
|
var duration_prototype__proto = Duration.prototype;
|
|
|
|
duration_prototype__proto.abs = duration_abs__abs;
|
|
duration_prototype__proto.add = duration_add_subtract__add;
|
|
duration_prototype__proto.subtract = duration_add_subtract__subtract;
|
|
duration_prototype__proto.as = as;
|
|
duration_prototype__proto.asMilliseconds = asMilliseconds;
|
|
duration_prototype__proto.asSeconds = asSeconds;
|
|
duration_prototype__proto.asMinutes = asMinutes;
|
|
duration_prototype__proto.asHours = asHours;
|
|
duration_prototype__proto.asDays = asDays;
|
|
duration_prototype__proto.asWeeks = asWeeks;
|
|
duration_prototype__proto.asMonths = asMonths;
|
|
duration_prototype__proto.asYears = asYears;
|
|
duration_prototype__proto.valueOf = duration_as__valueOf;
|
|
duration_prototype__proto._bubble = bubble;
|
|
duration_prototype__proto.get = duration_get__get;
|
|
duration_prototype__proto.milliseconds = duration_get__milliseconds;
|
|
duration_prototype__proto.seconds = seconds;
|
|
duration_prototype__proto.minutes = minutes;
|
|
duration_prototype__proto.hours = hours;
|
|
duration_prototype__proto.days = days;
|
|
duration_prototype__proto.weeks = weeks;
|
|
duration_prototype__proto.months = months;
|
|
duration_prototype__proto.years = years;
|
|
duration_prototype__proto.humanize = humanize;
|
|
duration_prototype__proto.toISOString = iso_string__toISOString;
|
|
duration_prototype__proto.toString = iso_string__toISOString;
|
|
duration_prototype__proto.toJSON = iso_string__toISOString;
|
|
duration_prototype__proto.locale = locale;
|
|
duration_prototype__proto.localeData = localeData;
|
|
|
|
// Deprecations
|
|
duration_prototype__proto.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', iso_string__toISOString);
|
|
duration_prototype__proto.lang = lang;
|
|
|
|
// Side effect imports
|
|
|
|
addFormatToken('X', 0, 0, 'unix');
|
|
addFormatToken('x', 0, 0, 'valueOf');
|
|
|
|
// PARSING
|
|
|
|
addRegexToken('x', matchSigned);
|
|
addRegexToken('X', matchTimestamp);
|
|
addParseToken('X', function (input, array, config) {
|
|
config._d = new Date(parseFloat(input, 10) * 1000);
|
|
});
|
|
addParseToken('x', function (input, array, config) {
|
|
config._d = new Date(toInt(input));
|
|
});
|
|
|
|
// Side effect imports
|
|
|
|
|
|
utils_hooks__hooks.version = '2.10.3';
|
|
|
|
setHookCallback(local__createLocal);
|
|
|
|
utils_hooks__hooks.fn = momentPrototype;
|
|
utils_hooks__hooks.min = min;
|
|
utils_hooks__hooks.max = max;
|
|
utils_hooks__hooks.utc = create_utc__createUTC;
|
|
utils_hooks__hooks.unix = moment__createUnix;
|
|
utils_hooks__hooks.months = lists__listMonths;
|
|
utils_hooks__hooks.isDate = isDate;
|
|
utils_hooks__hooks.locale = locale_locales__getSetGlobalLocale;
|
|
utils_hooks__hooks.invalid = valid__createInvalid;
|
|
utils_hooks__hooks.duration = create__createDuration;
|
|
utils_hooks__hooks.isMoment = isMoment;
|
|
utils_hooks__hooks.weekdays = lists__listWeekdays;
|
|
utils_hooks__hooks.parseZone = moment__createInZone;
|
|
utils_hooks__hooks.localeData = locale_locales__getLocale;
|
|
utils_hooks__hooks.isDuration = isDuration;
|
|
utils_hooks__hooks.monthsShort = lists__listMonthsShort;
|
|
utils_hooks__hooks.weekdaysMin = lists__listWeekdaysMin;
|
|
utils_hooks__hooks.defineLocale = defineLocale;
|
|
utils_hooks__hooks.weekdaysShort = lists__listWeekdaysShort;
|
|
utils_hooks__hooks.normalizeUnits = normalizeUnits;
|
|
utils_hooks__hooks.relativeTimeThreshold = duration_humanize__getSetRelativeTimeThreshold;
|
|
|
|
var _moment = utils_hooks__hooks;
|
|
|
|
return _moment;
|
|
|
|
}));
|
|
},{}],84:[function(require,module,exports){
|
|
module.exports={
|
|
"name": "mermaid",
|
|
"version": "0.4.0",
|
|
"description": "Markdownish syntax for generating flowcharts, sequence diagrams and gantt charts.",
|
|
"main": "src/main.js",
|
|
"keywords": [
|
|
"diagram",
|
|
"markdown",
|
|
"flowchart",
|
|
"sequence diagram",
|
|
"gantt"
|
|
],
|
|
"bin": {
|
|
"mermaid": "./bin/mermaid.js"
|
|
},
|
|
"scripts": {
|
|
"test": "gulp test"
|
|
},
|
|
"repository": {
|
|
"type": "git",
|
|
"url": "https://github.com/knsv/mermaid"
|
|
},
|
|
"author": "Knut Sveidqvist",
|
|
"license": "MIT",
|
|
"dependencies": {
|
|
"chalk": "^0.5.1",
|
|
"d3": "~3.4.13",
|
|
"dagre-d3": "~0.4.8",
|
|
"he": "^0.5.0",
|
|
"minimist": "^1.1.0",
|
|
"mkdirp": "^0.5.0",
|
|
"moment": "^2.9.0",
|
|
"semver": "^4.1.1",
|
|
"which": "^1.0.8"
|
|
},
|
|
"devDependencies": {
|
|
"async": "^0.9.0",
|
|
"browserify": "~6.2.0",
|
|
"clone": "^0.2.0",
|
|
"codeclimate-test-reporter": "0.0.4",
|
|
"d3": "~3.4.13",
|
|
"dateformat": "^1.0.11",
|
|
"event-stream": "^3.2.0",
|
|
"foundation": "^4.2.1-1",
|
|
"front-matter": "^0.2.0",
|
|
"gulp": "~3.8.9",
|
|
"gulp-browserify": "^0.5.0",
|
|
"gulp-bump": "^0.1.11",
|
|
"gulp-concat": "~2.4.1",
|
|
"gulp-data": "^1.1.1",
|
|
"gulp-ext-replace": "~0.1.0",
|
|
"gulp-hogan": "^1.1.0",
|
|
"gulp-insert": "^0.4.0",
|
|
"gulp-istanbul": "^0.4.0",
|
|
"gulp-jasmine": "~1.0.1",
|
|
"gulp-jison": "~1.0.0",
|
|
"gulp-jshint": "^1.9.0",
|
|
"gulp-less": "^3.0.1",
|
|
"gulp-rename": "~1.2.0",
|
|
"gulp-shell": "^0.2.10",
|
|
"gulp-tag-version": "^1.2.1",
|
|
"gulp-uglify": "~1.0.1",
|
|
"he": "^0.5.0",
|
|
"hogan.js": "^3.0.2",
|
|
"jasmine": "~2.0.1",
|
|
"jison": "~0.4.15",
|
|
"jshint-stylish": "^1.0.0",
|
|
"karma": "~0.12.20",
|
|
"karma-chrome-launcher": "~0.1.5",
|
|
"karma-jasmine": "~0.2.1",
|
|
"karma-requirejs": "~0.2.2",
|
|
"lodash": "^2.4.1",
|
|
"lodash._escapestringchar": "^2.4.1",
|
|
"lodash._objecttypes": "^2.4.1",
|
|
"lodash._reinterpolate": "^2.4.1",
|
|
"lodash._reunescapedhtml": "^2.4.1",
|
|
"lodash.defaults": "^2.4.1",
|
|
"lodash.templatesettings": "^2.4.1",
|
|
"lodash.values": "^2.4.1",
|
|
"marked": "^0.3.2",
|
|
"mock-browser": "^0.90.27",
|
|
"path": "^0.4.9",
|
|
"phantomjs": "^1.9.12",
|
|
"proxyquire": "^1.3.1",
|
|
"require-dir": "^0.3.0",
|
|
"rewire": "^2.1.3",
|
|
"rimraf": "^2.2.8",
|
|
"tape": "^3.0.3"
|
|
}
|
|
}
|
|
|
|
},{}],85:[function(require,module,exports){
|
|
/* global window */
|
|
console.log('Setting up d3');
|
|
var d3;
|
|
|
|
if (require) {
|
|
try {
|
|
d3 = require("d3");
|
|
} catch (e) {
|
|
console.log('Exception ... but ok');
|
|
//console.log(e);
|
|
}
|
|
}
|
|
|
|
//console.log(d3);
|
|
|
|
if (!d3) {
|
|
//if(typeof window !== 'undefined')
|
|
d3 = window.d3;
|
|
}
|
|
|
|
//if(typeof window === 'undefined'){
|
|
// window = {};
|
|
// window.d3 = d3;
|
|
//}
|
|
//console.log('window');
|
|
//console.log(window);
|
|
module.exports = d3;
|
|
|
|
},{"d3":"tokjIE"}],86:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 15-01-14.
|
|
*/
|
|
|
|
var message = '';
|
|
var info = false;
|
|
|
|
exports.setMessage = function(txt){
|
|
message = txt;
|
|
};
|
|
|
|
exports.getMessage = function(){
|
|
return message;
|
|
};
|
|
|
|
exports.setInfo = function(inf){
|
|
info = inf;
|
|
};
|
|
|
|
exports.getInfo = function(){
|
|
return info;
|
|
};
|
|
|
|
exports.parseError = function(err,hash){
|
|
mermaid.parseError(err,hash);
|
|
};
|
|
},{}],87:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 14-12-11.
|
|
*/
|
|
var db = require('./exampleDb');
|
|
var exampleParser = require('./parser/example.js');
|
|
var d3 = require('../../d3');
|
|
|
|
/**
|
|
* Draws a an info picture in the tag with id: id based on the graph definition in text.
|
|
* @param text
|
|
* @param id
|
|
*/
|
|
exports.draw = function (txt, id, ver) {
|
|
var parser;
|
|
parser = exampleParser.parser;
|
|
parser.yy = db;
|
|
|
|
// Parse the graph definition
|
|
parser.parse(txt);
|
|
|
|
// Fetch the default direction, use TD if none was found
|
|
var svg = d3.select('#'+id);
|
|
|
|
var textstring = "mermaid!";
|
|
var g = svg.append("g");
|
|
|
|
g.append("text") // text label for the x axis
|
|
.attr("x", 100)
|
|
.attr("y", 40)
|
|
.attr('class','version')
|
|
.attr('font-size','32px')
|
|
.style("text-anchor", "middle")
|
|
.text('mermaid '+ ver);
|
|
|
|
/*
|
|
var box = exports.bounds.getBounds();
|
|
|
|
var height = box.stopy-box.starty+2*conf.diagramMarginY;
|
|
var width = box.stopx-box.startx+2*conf.diagramMarginX;*/
|
|
|
|
svg.attr("height",100);
|
|
svg.attr("width", 400 );
|
|
//svg.attr("viewBox", '0 0 300 150');
|
|
};
|
|
},{"../../d3":85,"./exampleDb":86,"./parser/example.js":88}],88:[function(require,module,exports){
|
|
(function (process){
|
|
/* parser generated by jison 0.4.15 */
|
|
/*
|
|
Returns a Parser object of the following structure:
|
|
|
|
Parser: {
|
|
yy: {}
|
|
}
|
|
|
|
Parser.prototype: {
|
|
yy: {},
|
|
trace: function(),
|
|
symbols_: {associative list: name ==> number},
|
|
terminals_: {associative list: number ==> name},
|
|
productions_: [...],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
table: [...],
|
|
defaultActions: {...},
|
|
parseError: function(str, hash),
|
|
parse: function(input),
|
|
|
|
lexer: {
|
|
EOF: 1,
|
|
parseError: function(str, hash),
|
|
setInput: function(input),
|
|
input: function(),
|
|
unput: function(str),
|
|
more: function(),
|
|
less: function(n),
|
|
pastInput: function(),
|
|
upcomingInput: function(),
|
|
showPosition: function(),
|
|
test_match: function(regex_match_array, rule_index),
|
|
next: function(),
|
|
lex: function(),
|
|
begin: function(condition),
|
|
popState: function(),
|
|
_currentRules: function(),
|
|
topState: function(),
|
|
pushState: function(condition),
|
|
|
|
options: {
|
|
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
},
|
|
|
|
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
rules: [...],
|
|
conditions: {associative list: name ==> set},
|
|
}
|
|
}
|
|
|
|
|
|
token location info (@$, _$, etc.): {
|
|
first_line: n,
|
|
last_line: n,
|
|
first_column: n,
|
|
last_column: n,
|
|
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
}
|
|
|
|
|
|
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
text: (matched text)
|
|
token: (the produced terminal token, if any)
|
|
line: (yylineno)
|
|
}
|
|
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
loc: (yylloc)
|
|
expected: (string describing the set of expected tokens)
|
|
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
}
|
|
*/
|
|
var parser = (function(){
|
|
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[6,9,10,12];
|
|
var parser = {trace: function trace() { },
|
|
yy: {},
|
|
symbols_: {"error":2,"start":3,"info":4,"document":5,"EOF":6,"line":7,"statement":8,"NL":9,"showInfo":10,"message":11,"say":12,"TXT":13,"$accept":0,"$end":1},
|
|
terminals_: {2:"error",4:"info",6:"EOF",9:"NL",10:"showInfo",12:"say",13:"TXT"},
|
|
productions_: [0,[3,3],[5,0],[5,2],[7,1],[7,1],[8,1],[8,1],[11,2]],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
|
/* this == yyval */
|
|
|
|
var $0 = $$.length - 1;
|
|
switch (yystate) {
|
|
case 1:
|
|
return yy;
|
|
break;
|
|
case 4:
|
|
|
|
break;
|
|
case 6:
|
|
yy.setInfo(true);
|
|
break;
|
|
case 7:
|
|
yy.setMessage($$[$0]);
|
|
break;
|
|
case 8:
|
|
this.$ = $$[$0-1].substring(1).trim().replace(/\\n/gm, "\n");
|
|
break;
|
|
}
|
|
},
|
|
table: [{3:1,4:[1,2]},{1:[3]},o($V0,[2,2],{5:3}),{6:[1,4],7:5,8:6,9:[1,7],10:[1,8],11:9,12:[1,10]},{1:[2,1]},o($V0,[2,3]),o($V0,[2,4]),o($V0,[2,5]),o($V0,[2,6]),o($V0,[2,7]),{13:[1,11]},o($V0,[2,8])],
|
|
defaultActions: {4:[2,1]},
|
|
parseError: function parseError(str, hash) {
|
|
if (hash.recoverable) {
|
|
this.trace(str);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
parse: function parse(input) {
|
|
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
|
var args = lstack.slice.call(arguments, 1);
|
|
var lexer = Object.create(this.lexer);
|
|
var sharedState = { yy: {} };
|
|
for (var k in this.yy) {
|
|
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
sharedState.yy[k] = this.yy[k];
|
|
}
|
|
}
|
|
lexer.setInput(input, sharedState.yy);
|
|
sharedState.yy.lexer = lexer;
|
|
sharedState.yy.parser = this;
|
|
if (typeof lexer.yylloc == 'undefined') {
|
|
lexer.yylloc = {};
|
|
}
|
|
var yyloc = lexer.yylloc;
|
|
lstack.push(yyloc);
|
|
var ranges = lexer.options && lexer.options.ranges;
|
|
if (typeof sharedState.yy.parseError === 'function') {
|
|
this.parseError = sharedState.yy.parseError;
|
|
} else {
|
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
}
|
|
function popStack(n) {
|
|
stack.length = stack.length - 2 * n;
|
|
vstack.length = vstack.length - n;
|
|
lstack.length = lstack.length - n;
|
|
}
|
|
_token_stack:
|
|
function lex() {
|
|
var token;
|
|
token = lexer.lex() || EOF;
|
|
if (typeof token !== 'number') {
|
|
token = self.symbols_[token] || token;
|
|
}
|
|
return token;
|
|
}
|
|
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
|
while (true) {
|
|
state = stack[stack.length - 1];
|
|
if (this.defaultActions[state]) {
|
|
action = this.defaultActions[state];
|
|
} else {
|
|
if (symbol === null || typeof symbol == 'undefined') {
|
|
symbol = lex();
|
|
}
|
|
action = table[state] && table[state][symbol];
|
|
}
|
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
|
var errStr = '';
|
|
expected = [];
|
|
for (p in table[state]) {
|
|
if (this.terminals_[p] && p > TERROR) {
|
|
expected.push('\'' + this.terminals_[p] + '\'');
|
|
}
|
|
}
|
|
if (lexer.showPosition) {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
|
} else {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
|
}
|
|
this.parseError(errStr, {
|
|
text: lexer.match,
|
|
token: this.terminals_[symbol] || symbol,
|
|
line: lexer.yylineno,
|
|
loc: yyloc,
|
|
expected: expected
|
|
});
|
|
}
|
|
if (action[0] instanceof Array && action.length > 1) {
|
|
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
|
}
|
|
switch (action[0]) {
|
|
case 1:
|
|
stack.push(symbol);
|
|
vstack.push(lexer.yytext);
|
|
lstack.push(lexer.yylloc);
|
|
stack.push(action[1]);
|
|
symbol = null;
|
|
if (!preErrorSymbol) {
|
|
yyleng = lexer.yyleng;
|
|
yytext = lexer.yytext;
|
|
yylineno = lexer.yylineno;
|
|
yyloc = lexer.yylloc;
|
|
if (recovering > 0) {
|
|
recovering--;
|
|
}
|
|
} else {
|
|
symbol = preErrorSymbol;
|
|
preErrorSymbol = null;
|
|
}
|
|
break;
|
|
case 2:
|
|
len = this.productions_[action[1]][1];
|
|
yyval.$ = vstack[vstack.length - len];
|
|
yyval._$ = {
|
|
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
last_line: lstack[lstack.length - 1].last_line,
|
|
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
last_column: lstack[lstack.length - 1].last_column
|
|
};
|
|
if (ranges) {
|
|
yyval._$.range = [
|
|
lstack[lstack.length - (len || 1)].range[0],
|
|
lstack[lstack.length - 1].range[1]
|
|
];
|
|
}
|
|
r = this.performAction.apply(yyval, [
|
|
yytext,
|
|
yyleng,
|
|
yylineno,
|
|
sharedState.yy,
|
|
action[1],
|
|
vstack,
|
|
lstack
|
|
].concat(args));
|
|
if (typeof r !== 'undefined') {
|
|
return r;
|
|
}
|
|
if (len) {
|
|
stack = stack.slice(0, -1 * len * 2);
|
|
vstack = vstack.slice(0, -1 * len);
|
|
lstack = lstack.slice(0, -1 * len);
|
|
}
|
|
stack.push(this.productions_[action[1]][0]);
|
|
vstack.push(yyval.$);
|
|
lstack.push(yyval._$);
|
|
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
stack.push(newState);
|
|
break;
|
|
case 3:
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}};
|
|
/* generated by jison-lex 0.3.4 */
|
|
var lexer = (function(){
|
|
var lexer = ({
|
|
|
|
EOF:1,
|
|
|
|
parseError:function parseError(str, hash) {
|
|
if (this.yy.parser) {
|
|
this.yy.parser.parseError(str, hash);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
|
|
// resets the lexer, sets new input
|
|
setInput:function (input, yy) {
|
|
this.yy = yy || this.yy || {};
|
|
this._input = input;
|
|
this._more = this._backtrack = this.done = false;
|
|
this.yylineno = this.yyleng = 0;
|
|
this.yytext = this.matched = this.match = '';
|
|
this.conditionStack = ['INITIAL'];
|
|
this.yylloc = {
|
|
first_line: 1,
|
|
first_column: 0,
|
|
last_line: 1,
|
|
last_column: 0
|
|
};
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [0,0];
|
|
}
|
|
this.offset = 0;
|
|
return this;
|
|
},
|
|
|
|
// consumes and returns one char from the input
|
|
input:function () {
|
|
var ch = this._input[0];
|
|
this.yytext += ch;
|
|
this.yyleng++;
|
|
this.offset++;
|
|
this.match += ch;
|
|
this.matched += ch;
|
|
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno++;
|
|
this.yylloc.last_line++;
|
|
} else {
|
|
this.yylloc.last_column++;
|
|
}
|
|
if (this.options.ranges) {
|
|
this.yylloc.range[1]++;
|
|
}
|
|
|
|
this._input = this._input.slice(1);
|
|
return ch;
|
|
},
|
|
|
|
// unshifts one char (or a string) into the input
|
|
unput:function (ch) {
|
|
var len = ch.length;
|
|
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
|
|
this._input = ch + this._input;
|
|
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
//this.yyleng -= len;
|
|
this.offset -= len;
|
|
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
this.match = this.match.substr(0, this.match.length - 1);
|
|
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
|
|
if (lines.length - 1) {
|
|
this.yylineno -= lines.length - 1;
|
|
}
|
|
var r = this.yylloc.range;
|
|
|
|
this.yylloc = {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: lines ?
|
|
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
|
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
|
this.yylloc.first_column - len
|
|
};
|
|
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
}
|
|
this.yyleng = this.yytext.length;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, caches matched text and appends it on next action
|
|
more:function () {
|
|
this._more = true;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
|
reject:function () {
|
|
if (this.options.backtrack_lexer) {
|
|
this._backtrack = true;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// retain first n characters of the match
|
|
less:function (n) {
|
|
this.unput(this.match.slice(n));
|
|
},
|
|
|
|
// displays already matched input, i.e. for error messages
|
|
pastInput:function () {
|
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays upcoming input, i.e. for error messages
|
|
upcomingInput:function () {
|
|
var next = this.match;
|
|
if (next.length < 20) {
|
|
next += this._input.substr(0, 20-next.length);
|
|
}
|
|
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
showPosition:function () {
|
|
var pre = this.pastInput();
|
|
var c = new Array(pre.length + 1).join("-");
|
|
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
},
|
|
|
|
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
test_match:function (match, indexed_rule) {
|
|
var token,
|
|
lines,
|
|
backup;
|
|
|
|
if (this.options.backtrack_lexer) {
|
|
// save context
|
|
backup = {
|
|
yylineno: this.yylineno,
|
|
yylloc: {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.last_line,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: this.yylloc.last_column
|
|
},
|
|
yytext: this.yytext,
|
|
match: this.match,
|
|
matches: this.matches,
|
|
matched: this.matched,
|
|
yyleng: this.yyleng,
|
|
offset: this.offset,
|
|
_more: this._more,
|
|
_input: this._input,
|
|
yy: this.yy,
|
|
conditionStack: this.conditionStack.slice(0),
|
|
done: this.done
|
|
};
|
|
if (this.options.ranges) {
|
|
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
}
|
|
}
|
|
|
|
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno += lines.length;
|
|
}
|
|
this.yylloc = {
|
|
first_line: this.yylloc.last_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.last_column,
|
|
last_column: lines ?
|
|
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
|
this.yylloc.last_column + match[0].length
|
|
};
|
|
this.yytext += match[0];
|
|
this.match += match[0];
|
|
this.matches = match;
|
|
this.yyleng = this.yytext.length;
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
}
|
|
this._more = false;
|
|
this._backtrack = false;
|
|
this._input = this._input.slice(match[0].length);
|
|
this.matched += match[0];
|
|
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
if (this.done && this._input) {
|
|
this.done = false;
|
|
}
|
|
if (token) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
// recover context
|
|
for (var k in backup) {
|
|
this[k] = backup[k];
|
|
}
|
|
return false; // rule action called reject() implying the next rule should be tested instead.
|
|
}
|
|
return false;
|
|
},
|
|
|
|
// return next match in input
|
|
next:function () {
|
|
if (this.done) {
|
|
return this.EOF;
|
|
}
|
|
if (!this._input) {
|
|
this.done = true;
|
|
}
|
|
|
|
var token,
|
|
match,
|
|
tempMatch,
|
|
index;
|
|
if (!this._more) {
|
|
this.yytext = '';
|
|
this.match = '';
|
|
}
|
|
var rules = this._currentRules();
|
|
for (var i = 0; i < rules.length; i++) {
|
|
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
match = tempMatch;
|
|
index = i;
|
|
if (this.options.backtrack_lexer) {
|
|
token = this.test_match(tempMatch, rules[i]);
|
|
if (token !== false) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
match = false;
|
|
continue; // rule action called reject() implying a rule MISmatch.
|
|
} else {
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
} else if (!this.options.flex) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (match) {
|
|
token = this.test_match(match, rules[index]);
|
|
if (token !== false) {
|
|
return token;
|
|
}
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
if (this._input === "") {
|
|
return this.EOF;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
}
|
|
},
|
|
|
|
// return next match that has a token
|
|
lex:function lex() {
|
|
var r = this.next();
|
|
if (r) {
|
|
return r;
|
|
} else {
|
|
return this.lex();
|
|
}
|
|
},
|
|
|
|
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
begin:function begin(condition) {
|
|
this.conditionStack.push(condition);
|
|
},
|
|
|
|
// pop the previously active lexer condition state off the condition stack
|
|
popState:function popState() {
|
|
var n = this.conditionStack.length - 1;
|
|
if (n > 0) {
|
|
return this.conditionStack.pop();
|
|
} else {
|
|
return this.conditionStack[0];
|
|
}
|
|
},
|
|
|
|
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
_currentRules:function _currentRules() {
|
|
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
} else {
|
|
return this.conditions["INITIAL"].rules;
|
|
}
|
|
},
|
|
|
|
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
topState:function topState(n) {
|
|
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
if (n >= 0) {
|
|
return this.conditionStack[n];
|
|
} else {
|
|
return "INITIAL";
|
|
}
|
|
},
|
|
|
|
// alias for begin(condition)
|
|
pushState:function pushState(condition) {
|
|
this.begin(condition);
|
|
},
|
|
|
|
// return the number of states currently on the stack
|
|
stateStackSize:function stateStackSize() {
|
|
return this.conditionStack.length;
|
|
},
|
|
options: {"case-insensitive":true},
|
|
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
|
// Pre-lexer code can go here
|
|
|
|
var YYSTATE=YY_START;
|
|
switch($avoiding_name_collisions) {
|
|
case 0:return 9;
|
|
break;
|
|
case 1:return 10;
|
|
break;
|
|
case 2:return 4;
|
|
break;
|
|
case 3:return 12;
|
|
break;
|
|
case 4:return 13;
|
|
break;
|
|
case 5:return 6;
|
|
break;
|
|
case 6:return 'INVALID';
|
|
break;
|
|
}
|
|
},
|
|
rules: [/^(?:[\n]+)/i,/^(?:showInfo\b)/i,/^(?:info\b)/i,/^(?:say\b)/i,/^(?::[^#\n;]+)/i,/^(?:$)/i,/^(?:.)/i],
|
|
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6],"inclusive":true}}
|
|
});
|
|
return lexer;
|
|
})();
|
|
parser.lexer = lexer;
|
|
function Parser () {
|
|
this.yy = {};
|
|
}
|
|
Parser.prototype = parser;parser.Parser = Parser;
|
|
return new Parser;
|
|
})();
|
|
|
|
|
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
|
exports.parser = parser;
|
|
exports.Parser = parser.Parser;
|
|
exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
|
exports.main = function commonjsMain(args) {
|
|
if (!args[1]) {
|
|
console.log('Usage: '+args[0]+' FILE');
|
|
process.exit(1);
|
|
}
|
|
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
|
return exports.parser.parse(source);
|
|
};
|
|
if (typeof module !== 'undefined' && require.main === module) {
|
|
exports.main(process.argv.slice(1));
|
|
}
|
|
}
|
|
}).call(this,require("1YiZ5S"))
|
|
},{"1YiZ5S":81,"fs":79,"path":80}],89:[function(require,module,exports){
|
|
/* global window */
|
|
|
|
var dagreD3;
|
|
//console.log('setting up dagre-d3');
|
|
if (require) {
|
|
try {
|
|
dagreD3 = require("dagre-d3");
|
|
//console.log('Got it (dagre-d3)');
|
|
} catch (e) {console.log('Could not load dagre-d3');}
|
|
}
|
|
|
|
if (!dagreD3) {
|
|
dagreD3 = window.dagreD3;
|
|
}
|
|
|
|
module.exports = dagreD3;
|
|
|
|
},{"dagre-d3":1}],90:[function(require,module,exports){
|
|
(function (global){
|
|
/**
|
|
* Created by knut on 14-12-11.
|
|
*/
|
|
var graph = require('./graphDb');
|
|
var flow = require('./parser/flow');
|
|
var dot = require('./parser/dot');
|
|
var d3 = require('../../d3');
|
|
var dagreD3 = require('./dagre-d3');
|
|
var conf = {
|
|
};
|
|
module.exports.setConf = function(cnf){
|
|
var keys = Object.keys(cnf);
|
|
var i;
|
|
for(i=0;i<keys.length;i++){
|
|
conf[keys[i]] = cnf[keys[i]];
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Function that adds the vertices found in the graph definition to the graph to be rendered.
|
|
* @param vert Object containing the vertices.
|
|
* @param g The graph that is to be drawn.
|
|
*/
|
|
exports.addVertices = function (vert, g) {
|
|
var keys = Object.keys(vert);
|
|
|
|
var styleFromStyleArr = function(styleStr,arr){
|
|
var i;
|
|
// Create a compound style definition from the style definitions found for the node in the graph definition
|
|
for (i = 0; i < arr.length; i++) {
|
|
if (typeof arr[i] !== 'undefined') {
|
|
styleStr = styleStr + arr[i] + ';';
|
|
}
|
|
}
|
|
|
|
return styleStr;
|
|
};
|
|
|
|
// Iterate through each item in the vertice object (containing all the vertices found) in the graph definition
|
|
keys.forEach(function (id) {
|
|
var vertice = vert[id];
|
|
var verticeText;
|
|
|
|
var i;
|
|
|
|
/**
|
|
* Variable for storing the classes for the vertice
|
|
* @type {string}
|
|
*/
|
|
var classStr = '';
|
|
|
|
//console.log(vertice.classes);
|
|
|
|
if(vertice.classes.length >0){
|
|
classStr = vertice.classes.join(" ");
|
|
}
|
|
|
|
/**
|
|
* Variable for storing the extracted style for the vertice
|
|
* @type {string}
|
|
*/
|
|
var style = '';
|
|
// Create a compound style definition from the style definitions found for the node in the graph definition
|
|
style = styleFromStyleArr(style, vertice.styles);
|
|
|
|
// Use vertice id as text in the box if no text is provided by the graph definition
|
|
if (typeof vertice.text === 'undefined') {
|
|
verticeText = vertice.id;
|
|
}
|
|
else {
|
|
verticeText = vertice.text;
|
|
}
|
|
|
|
var labelTypeStr = '';
|
|
if(global.mermaid.htmlLabels) {
|
|
labelTypeStr = 'html';
|
|
} else {
|
|
verticeText = verticeText.replace(/<br>/g, "\n");
|
|
labelTypeStr = 'text';
|
|
}
|
|
|
|
var radious = 0;
|
|
var _shape = '';
|
|
|
|
// Set the shape based parameters
|
|
switch(vertice.type){
|
|
case 'round':
|
|
radious = 5;
|
|
_shape = 'rect';
|
|
break;
|
|
case 'square':
|
|
_shape = 'rect';
|
|
break;
|
|
case 'diamond':
|
|
_shape = 'question';
|
|
break;
|
|
case 'odd':
|
|
_shape = 'rect_left_inv_arrow';
|
|
break;
|
|
case 'odd_right':
|
|
_shape = 'rect_left_inv_arrow';
|
|
break;
|
|
case 'circle':
|
|
_shape = 'circle';
|
|
break;
|
|
default:
|
|
_shape = 'rect';
|
|
}
|
|
// Add the node
|
|
g.setNode(vertice.id, {labelType: labelTypeStr, shape:_shape, label: verticeText, rx: radious, ry: radious, class: classStr, style: style, id:vertice.id});
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Add edges to graph based on parsed graph defninition
|
|
* @param {Object} edges The edges to add to the graph
|
|
* @param {Object} g The graph object
|
|
*/
|
|
exports.addEdges = function (edges, g) {
|
|
var cnt=0;
|
|
var aHead;
|
|
|
|
var defaultStyle;
|
|
if(typeof edges.defaultStyle !== 'undefined'){
|
|
defaultStyle = edges.defaultStyle.toString().replace(/,/g , ';');
|
|
|
|
}
|
|
|
|
edges.forEach(function (edge) {
|
|
cnt++;
|
|
|
|
// Set link type for rendering
|
|
if(edge.type === 'arrow_open'){
|
|
aHead = 'none';
|
|
}
|
|
else{
|
|
aHead = 'normal';
|
|
}
|
|
|
|
var style = '';
|
|
|
|
|
|
if(typeof edge.style !== 'undefined'){
|
|
edge.style.forEach(function(s){
|
|
style = style + s +';';
|
|
});
|
|
}
|
|
else{
|
|
switch(edge.stroke){
|
|
case 'normal':
|
|
style = 'fill:none';
|
|
if(typeof defaultStyle !== 'undefined'){
|
|
style = defaultStyle;
|
|
}
|
|
break;
|
|
case 'dotted':
|
|
style = 'stroke: #333; fill:none;stroke-width:2px;stroke-dasharray:3;';
|
|
break;
|
|
case 'thick':
|
|
style = 'stroke: #333; stroke-width: 3.5px;fill:none';
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Add the edge to the graph
|
|
if (typeof edge.text === 'undefined') {
|
|
if(typeof edge.style === 'undefined'){
|
|
g.setEdge(edge.start, edge.end,{ style: style, arrowhead: aHead},cnt);
|
|
}else{
|
|
g.setEdge(edge.start, edge.end, {
|
|
style: style, arrowheadStyle: "fill: #333", arrowhead: aHead
|
|
},cnt);
|
|
}
|
|
}
|
|
// Edge with text
|
|
else {
|
|
var edgeText = edge.text.replace(/<br>/g, "\n");
|
|
if(typeof edge.style === 'undefined'){
|
|
if (global.mermaid.htmlLabels){
|
|
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
|
}else{
|
|
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
|
|
}
|
|
}else{
|
|
g.setEdge(edge.start, edge.end, {
|
|
labelType: "text", style: style, arrowheadStyle: "fill: #333", label: edgeText, arrowhead: aHead
|
|
},cnt);
|
|
}
|
|
}
|
|
});
|
|
};
|
|
|
|
/**
|
|
* Returns the all the styles from classDef statements in the graph definition.
|
|
* @returns {object} classDef styles
|
|
*/
|
|
exports.getClasses = function (text, isDot) {
|
|
var parser;
|
|
graph.clear();
|
|
if(isDot){
|
|
parser = dot.parser;
|
|
|
|
}else{
|
|
parser = flow.parser;
|
|
}
|
|
parser.yy = graph;
|
|
|
|
// Parse the graph definition
|
|
parser.parse(text);
|
|
|
|
var classDefStylesObj = {};
|
|
var classDefStyleStr = '';
|
|
|
|
var classes = graph.getClasses();
|
|
|
|
// Add default class if undefined
|
|
if(typeof(classes.default) === 'undefined') {
|
|
classes.default = {id:'default'};
|
|
classes.default.styles = ['fill:#ffa','stroke:#666','stroke-width:3px'];
|
|
classes.default.nodeLabelStyles = ['fill:#000','stroke:none','font-weight:300','font-family:"Helvetica Neue",Helvetica,Arial,sans-serf','font-size:14px'];
|
|
classes.default.edgeLabelStyles = ['fill:#000','stroke:none','font-weight:300','font-family:"Helvetica Neue",Helvetica,Arial,sans-serf','font-size:14px'];
|
|
}
|
|
return classes;
|
|
};
|
|
|
|
/**
|
|
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
|
* @param text
|
|
* @param id
|
|
*/
|
|
exports.draw = function (text, id,isDot) {
|
|
|
|
var parser;
|
|
graph.clear();
|
|
if(isDot){
|
|
parser = dot.parser;
|
|
|
|
}else{
|
|
parser = flow.parser;
|
|
}
|
|
parser.yy = graph;
|
|
|
|
// Parse the graph definition
|
|
try{
|
|
|
|
parser.parse(text);
|
|
}
|
|
catch(err){
|
|
|
|
}
|
|
|
|
// Fetch the default direction, use TD if none was found
|
|
var dir;
|
|
dir = graph.getDirection();
|
|
if(typeof dir === 'undefined'){
|
|
dir='TD';
|
|
}
|
|
|
|
// Create the input mermaid.graph
|
|
var g = new dagreD3.graphlib.Graph({
|
|
multigraph:true,
|
|
compound: true
|
|
})
|
|
.setGraph({
|
|
rankdir: dir,
|
|
marginx: 20,
|
|
marginy: 20
|
|
|
|
})
|
|
.setDefaultEdgeLabel(function () {
|
|
return {};
|
|
});
|
|
|
|
var subG;
|
|
var subGraphs = graph.getSubGraphs();
|
|
var i = 0;
|
|
for(i=subGraphs.length-1;i>=0;i--){
|
|
subG = subGraphs[i];
|
|
graph.addVertex(subG.id,undefined,undefined,undefined);
|
|
}
|
|
|
|
// Fetch the verices/nodes and edges/links from the parsed graph definition
|
|
var vert = graph.getVertices();
|
|
|
|
//console.log(vert);
|
|
var edges = graph.getEdges();
|
|
|
|
i = 0;
|
|
var j;
|
|
for(i=subGraphs.length-1;i>=0;i--){
|
|
subG = subGraphs[i];
|
|
|
|
d3.selectAll('cluster').append('text');
|
|
|
|
for(j=0;j<subG.nodes.length;j++){
|
|
//console.log('Setting node',subG.nodes[j],' to subgraph '+id);
|
|
g.setParent(subG.nodes[j],subG.id);
|
|
}
|
|
}
|
|
exports.addVertices(vert, g);
|
|
exports.addEdges(edges, g);
|
|
|
|
// Create the renderer
|
|
var render = new dagreD3.render();
|
|
|
|
// Add custom shape for rhombus type of boc (decision)
|
|
render.shapes().question = function (parent, bbox, node) {
|
|
var w = bbox.width,
|
|
h = bbox.height,
|
|
s = (w + h) * 0.8,
|
|
points = [
|
|
{x: s / 2, y: 0},
|
|
{x: s, y: -s / 2},
|
|
{x: s / 2, y: -s},
|
|
{x: 0, y: -s / 2}
|
|
];
|
|
var shapeSvg = parent.insert("polygon", ":first-child")
|
|
.attr("points", points.map(function (d) {
|
|
return d.x + "," + d.y;
|
|
}).join(" "))
|
|
.attr("rx", 5)
|
|
.attr("ry", 5)
|
|
.attr("transform", "translate(" + (-s / 2) + "," + (s * 2 / 4) + ")");
|
|
node.intersect = function (point) {
|
|
return dagreD3.intersect.polygon(node, points, point);
|
|
};
|
|
return shapeSvg;
|
|
};
|
|
|
|
// Add custom shape for box with inverted arrow on left side
|
|
render.shapes().rect_left_inv_arrow = function (parent, bbox, node) {
|
|
var w = bbox.width,
|
|
h = bbox.height,
|
|
points = [
|
|
{x: -h/2, y: 0},
|
|
{x: w, y: 0},
|
|
{x: w, y: -h},
|
|
{x: -h/2, y: -h},
|
|
{x: 0, y: -h/2},
|
|
];
|
|
var shapeSvg = parent.insert("polygon", ":first-child")
|
|
.attr("points", points.map(function (d) {
|
|
return d.x + "," + d.y;
|
|
}).join(" "))
|
|
.attr("transform", "translate(" + (-w / 2) + "," + (h * 2 / 4) + ")");
|
|
node.intersect = function (point) {
|
|
return dagreD3.intersect.polygon(node, points, point);
|
|
};
|
|
return shapeSvg;
|
|
};
|
|
|
|
// Add custom shape for box with inverted arrow on right side
|
|
render.shapes().rect_right_inv_arrow = function (parent, bbox, node) {
|
|
var w = bbox.width,
|
|
h = bbox.height,
|
|
points = [
|
|
{x: 0, y: 0},
|
|
{x: w+h/2, y: 0},
|
|
{x: w, y: -h/2},
|
|
{x: w+h/2, y: -h},
|
|
{x: 0, y: -h},
|
|
];
|
|
var shapeSvg = parent.insert("polygon", ":first-child")
|
|
.attr("points", points.map(function (d) {
|
|
return d.x + "," + d.y;
|
|
}).join(" "))
|
|
.attr("transform", "translate(" + (-w / 2) + "," + (h * 2 / 4) + ")");
|
|
node.intersect = function (point) {
|
|
return dagreD3.intersect.polygon(node, points, point);
|
|
};
|
|
return shapeSvg;
|
|
};
|
|
|
|
// Add our custom arrow - an empty arrowhead
|
|
render.arrows().none = function normal(parent, id, edge, type) {
|
|
var marker = parent.append("marker")
|
|
.attr("id", id)
|
|
.attr("viewBox", "0 0 10 10")
|
|
.attr("refX", 9)
|
|
.attr("refY", 5)
|
|
.attr("markerUnits", "strokeWidth")
|
|
.attr("markerWidth", 8)
|
|
.attr("markerHeight", 6)
|
|
.attr("orient", "auto");
|
|
|
|
var path = marker.append("path")
|
|
.attr("d", "M 0 0 L 0 0 L 0 0 z");
|
|
dagreD3.util.applyStyle(path, edge[type + "Style"]);
|
|
};
|
|
|
|
// Set up an SVG group so that we can translate the final graph.
|
|
var svg = d3.select("#" + id);
|
|
svgGroup = d3.select("#" + id + " g");
|
|
|
|
// Run the renderer. This is what draws the final graph.
|
|
render(d3.select("#" + id + " g"), g);
|
|
var svgb = document.querySelector("#" + id);
|
|
|
|
/*
|
|
var xPos = document.querySelectorAll('.clusters rect')[0].x.baseVal.value;
|
|
var width = document.querySelectorAll('.clusters rect')[0].width.baseVal.value;
|
|
var cluster = d3.selectAll('.cluster');
|
|
var te = cluster.append('text');
|
|
te.attr('x', xPos+width/2);
|
|
te.attr('y', 12);
|
|
//te.stroke('black');
|
|
te.attr('id', 'apa12');
|
|
te.style('text-anchor', 'middle');
|
|
te.text('Title for cluster');
|
|
*/
|
|
// Center the graph
|
|
svg.attr("height", g.graph().height );
|
|
if(typeof conf.width === 'undefined'){
|
|
svg.attr("width", g.graph().width );
|
|
}else{
|
|
svg.attr("width", conf.width );
|
|
}
|
|
//svg.attr("viewBox", svgb.getBBox().x + ' 0 '+ g.graph().width+' '+ g.graph().height);
|
|
svg.attr("viewBox", '0 0 ' + (g.graph().width+20) + ' ' + (g.graph().height+20));
|
|
|
|
// Index nodes
|
|
graph.indexNodes('sunGraph'+i);
|
|
|
|
for(i=0;i<subGraphs.length;i++){
|
|
var pos = graph.getDepthFirstPos(i);
|
|
subG = subGraphs[i];
|
|
|
|
if (subG.title !== 'undefined') {
|
|
var clusterRects = document.querySelectorAll('#' + id + ' #' + subG.id + ' rect');
|
|
//console.log('looking up: #' + id + ' #' + subG.id)
|
|
var clusterEl = document.querySelectorAll('#' + id + ' #' + subG.id);
|
|
|
|
var xPos = clusterRects[0].x.baseVal.value;
|
|
var yPos = clusterRects[0].y.baseVal.value;
|
|
var width = clusterRects[0].width.baseVal.value;
|
|
var cluster = d3.select(clusterEl[0]);
|
|
var te = cluster.append('text');
|
|
te.attr('x', xPos + width / 2);
|
|
te.attr('y', yPos + 14);
|
|
te.attr('fill', 'black');
|
|
te.attr('stroke', 'none');
|
|
te.attr('id', id + 'Text');
|
|
te.style('text-anchor', 'middle');
|
|
|
|
if(typeof subG.title === 'undefined'){
|
|
te.text('Undef');
|
|
}else{
|
|
//te.text(subGraphs[subGraphs.length-i-1].title);
|
|
te.text(subG.title);
|
|
|
|
console.log('Setting subg - '+i+' to title '+subGraphs[pos].title);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../../d3":85,"./dagre-d3":89,"./graphDb":91,"./parser/dot":92,"./parser/flow":93}],91:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 14-11-03.
|
|
*/
|
|
|
|
var vertices = {};
|
|
var edges = [];
|
|
var classes = [];
|
|
var subGraphs = [];
|
|
var subCount=0;
|
|
var direction;
|
|
// Functions to be run after graph rendering
|
|
var funs = [];
|
|
/**
|
|
* Function called by parser when a node definition has been found
|
|
* @param id
|
|
* @param text
|
|
* @param type
|
|
* @param style
|
|
*/
|
|
exports.addVertex = function (id, text, type, style) {
|
|
var txt;
|
|
|
|
if(typeof id === 'undefined'){
|
|
return;
|
|
}
|
|
if(id.trim().length === 0){
|
|
return;
|
|
}
|
|
|
|
if (typeof vertices[id] === 'undefined') {
|
|
vertices[id] = {id: id, styles: [], classes:[]};
|
|
}
|
|
if (typeof text !== 'undefined') {
|
|
txt = text.trim();
|
|
|
|
// strip quotes if string starts and exnds with a quote
|
|
if(txt[0] === '"' && txt[txt.length-1] === '"'){
|
|
txt = txt.substring(1,txt.length-1);
|
|
}
|
|
|
|
vertices[id].text = txt;
|
|
}
|
|
if (typeof type !== 'undefined') {
|
|
vertices[id].type = type;
|
|
}
|
|
if (typeof type !== 'undefined') {
|
|
vertices[id].type = type;
|
|
}
|
|
if (typeof style !== 'undefined') {
|
|
if (style !== null) {
|
|
style.forEach(function (s) {
|
|
vertices[id].styles.push(s);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Function called by parser when a link/edge definition has been found
|
|
* @param start
|
|
* @param end
|
|
* @param type
|
|
* @param linktext
|
|
*/
|
|
exports.addLink = function (start, end, type, linktext) {
|
|
//console.log('Got edge', start, end);
|
|
var edge = {start: start, end: end, type: undefined, text: ''};
|
|
linktext = type.text;
|
|
|
|
if (typeof linktext !== 'undefined') {
|
|
edge.text = linktext.trim();
|
|
|
|
// strip quotes if string starts and exnds with a quote
|
|
if(edge.text[0] === '"' && edge.text[edge.text.length-1] === '"'){
|
|
edge.text = edge.text.substring(1,edge.text.length-1);
|
|
}
|
|
}
|
|
|
|
if (typeof type !== 'undefined') {
|
|
edge.type = type.type;
|
|
edge.stroke = type.stroke;
|
|
}
|
|
edges.push(edge);
|
|
};
|
|
/**
|
|
* Updates a link with a style
|
|
* @param pos
|
|
* @param style
|
|
*/
|
|
exports.updateLink = function (pos, style) {
|
|
var position = pos.substr(1);
|
|
|
|
if(pos === 'default'){
|
|
edges.defaultStyle = style;
|
|
}else{
|
|
edges[pos].style = style;
|
|
}
|
|
};
|
|
|
|
exports.addClass = function (id, style) {
|
|
if (typeof classes[id] === 'undefined') {
|
|
classes[id] = {id: id, styles: []};
|
|
}
|
|
|
|
if (typeof style !== 'undefined') {
|
|
if (style !== null) {
|
|
style.forEach(function (s) {
|
|
classes[id].styles.push(s);
|
|
});
|
|
}
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Called by parser when a graph definition is found, stores the direction of the chart.
|
|
* @param dir
|
|
*/
|
|
exports.setDirection = function (dir) {
|
|
direction = dir;
|
|
};
|
|
|
|
/**
|
|
* Called by parser when a graph definition is found, stores the direction of the chart.
|
|
* @param dir
|
|
*/
|
|
exports.setClass = function (id,className) {
|
|
if(id.indexOf(',')>0){
|
|
id.split(',').forEach(function(id2){
|
|
if(typeof vertices[id2] !== 'undefined'){
|
|
vertices[id2].classes.push(className);
|
|
}
|
|
});
|
|
}else{
|
|
if(typeof vertices[id] !== 'undefined'){
|
|
vertices[id].classes.push(className);
|
|
}
|
|
}
|
|
};
|
|
/**
|
|
* Called by parser when a graph definition is found, stores the direction of the chart.
|
|
* @param dir
|
|
*/
|
|
exports.setClickEvent = function (id,functionName) {
|
|
|
|
|
|
if(id.indexOf(',')>0){
|
|
id.split(',').forEach(function(id2) {
|
|
if (typeof vertices[id2] !== 'undefined') {
|
|
funs.push(function () {
|
|
var elem = document.getElementById(id2);
|
|
if (elem !== null) {
|
|
elem.onclick = function () {
|
|
eval(functionName + '(\'' + id2 + '\')'); // jshint ignore:line
|
|
};
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}else{
|
|
//console.log('Checking now for ::'+id);
|
|
if(typeof vertices[id] !== 'undefined'){
|
|
funs.push(function(){
|
|
var elem = document.getElementById(id);
|
|
if(elem !== null){
|
|
//console.log('id was NOT null: '+id);
|
|
elem.onclick = function(){eval(functionName+'(\'' + id + '\')');}; // jshint ignore:line
|
|
}
|
|
else{
|
|
//console.log('id was null: '+id);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
};
|
|
|
|
exports.bindFunctions = function(){
|
|
//setTimeout(function(){
|
|
funs.forEach(function(fun){
|
|
fun();
|
|
});
|
|
//},1000);
|
|
|
|
};
|
|
exports.getDirection = function () {
|
|
return direction;
|
|
};
|
|
/**
|
|
* Retrieval function for fetching the found nodes after parsing has completed.
|
|
* @returns {{}|*|vertices}
|
|
*/
|
|
exports.getVertices = function () {
|
|
return vertices;
|
|
};
|
|
|
|
/**
|
|
* Retrieval function for fetching the found links after parsing has completed.
|
|
* @returns {{}|*|edges}
|
|
*/
|
|
exports.getEdges = function () {
|
|
return edges;
|
|
};
|
|
|
|
/**
|
|
* Retrieval function for fetching the found class definitions after parsing has completed.
|
|
* @returns {{}|*|classes}
|
|
*/
|
|
exports.getClasses = function () {
|
|
return classes;
|
|
};
|
|
|
|
/**
|
|
* Clears the internal graph db so that a new graph can be parsed.
|
|
*/
|
|
exports.clear = function () {
|
|
vertices = {};
|
|
classes = {};
|
|
edges = [];
|
|
funs = [];
|
|
subGraphs = [];
|
|
subCount = 0;
|
|
};
|
|
/**
|
|
*
|
|
* @returns {string}
|
|
*/
|
|
exports.defaultStyle = function () {
|
|
return "fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;";
|
|
};
|
|
|
|
/**
|
|
* Clears the internal graph db so that a new graph can be parsed.
|
|
*/
|
|
exports.addSubGraph = function (list, title) {
|
|
function uniq(a) {
|
|
var prims = {"boolean":{}, "number":{}, "string":{}}, objs = [];
|
|
|
|
return a.filter(function(item) {
|
|
var type = typeof item;
|
|
if(item===' '){
|
|
return false;
|
|
}
|
|
if(type in prims)
|
|
return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);
|
|
else
|
|
return objs.indexOf(item) >= 0 ? false : objs.push(item);
|
|
});
|
|
}
|
|
|
|
var nodeList = [];
|
|
|
|
nodeList = uniq(nodeList.concat.apply(nodeList,list));
|
|
|
|
|
|
var subGraph = {id:'subGraph'+subCount, nodes:nodeList,title:title};
|
|
//console.log('subGraph:' + subGraph.title + subGraph.id);
|
|
//console.log(subGraph.nodes);
|
|
subGraphs.push(subGraph);
|
|
subCount = subCount + 1;
|
|
return subGraph.id;
|
|
};
|
|
|
|
var getPosForId = function(id){
|
|
var i;
|
|
for(i=0;i<subGraphs.length;i++){
|
|
if(subGraphs[i].id===id){
|
|
//console.log('Found pos for ',id,' ',i);
|
|
return i;
|
|
}
|
|
}
|
|
//console.log('No pos found for ',id,' ',i);
|
|
return -1;
|
|
};
|
|
var secCount = -1;
|
|
var posCrossRef = [];
|
|
var indexNodes = function (id, pos) {
|
|
var nodes = subGraphs[pos].nodes;
|
|
secCount = secCount + 1;
|
|
if(secCount>2000){
|
|
return;
|
|
|
|
}
|
|
//var nPos = getPosForId(subGraphs[pos].id);
|
|
posCrossRef[secCount]=pos;
|
|
console.log('Setting ',' ',secCount,' to ',pos);
|
|
// Check if match
|
|
if(subGraphs[pos].id === id){
|
|
return {
|
|
result:true,
|
|
count:0
|
|
};
|
|
}
|
|
|
|
|
|
var count = 0;
|
|
var posCount = 1;
|
|
while(count<nodes.length){
|
|
var childPos = getPosForId(nodes[count]);
|
|
// Ignore regular nodes (pos will be -1)
|
|
if(childPos>=0){
|
|
var res = indexNodes(id,childPos);
|
|
if(res.result){
|
|
return {
|
|
result:true,
|
|
count:posCount+res.count
|
|
};
|
|
}else{
|
|
posCount = posCount + res.count;
|
|
}
|
|
}
|
|
count = count +1;
|
|
}
|
|
|
|
return {
|
|
result:false,
|
|
count:posCount
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.getDepthFirstPos = function (pos) {
|
|
return posCrossRef[pos];
|
|
};
|
|
exports.indexNodes = function (id) {
|
|
secCount = -1;
|
|
if(subGraphs.length>0){
|
|
indexNodes('none',subGraphs.length-1,0);
|
|
}
|
|
};
|
|
|
|
exports.getSubGraphs = function (list) {
|
|
return subGraphs;
|
|
};
|
|
|
|
exports.parseError = function(err,hash){
|
|
mermaid.parseError(err,hash);
|
|
};
|
|
},{}],92:[function(require,module,exports){
|
|
(function (process){
|
|
/* parser generated by jison 0.4.15 */
|
|
/*
|
|
Returns a Parser object of the following structure:
|
|
|
|
Parser: {
|
|
yy: {}
|
|
}
|
|
|
|
Parser.prototype: {
|
|
yy: {},
|
|
trace: function(),
|
|
symbols_: {associative list: name ==> number},
|
|
terminals_: {associative list: number ==> name},
|
|
productions_: [...],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
table: [...],
|
|
defaultActions: {...},
|
|
parseError: function(str, hash),
|
|
parse: function(input),
|
|
|
|
lexer: {
|
|
EOF: 1,
|
|
parseError: function(str, hash),
|
|
setInput: function(input),
|
|
input: function(),
|
|
unput: function(str),
|
|
more: function(),
|
|
less: function(n),
|
|
pastInput: function(),
|
|
upcomingInput: function(),
|
|
showPosition: function(),
|
|
test_match: function(regex_match_array, rule_index),
|
|
next: function(),
|
|
lex: function(),
|
|
begin: function(condition),
|
|
popState: function(),
|
|
_currentRules: function(),
|
|
topState: function(),
|
|
pushState: function(condition),
|
|
|
|
options: {
|
|
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
},
|
|
|
|
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
rules: [...],
|
|
conditions: {associative list: name ==> set},
|
|
}
|
|
}
|
|
|
|
|
|
token location info (@$, _$, etc.): {
|
|
first_line: n,
|
|
last_line: n,
|
|
first_column: n,
|
|
last_column: n,
|
|
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
}
|
|
|
|
|
|
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
text: (matched text)
|
|
token: (the produced terminal token, if any)
|
|
line: (yylineno)
|
|
}
|
|
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
loc: (yylloc)
|
|
expected: (string describing the set of expected tokens)
|
|
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
}
|
|
*/
|
|
var parser = (function(){
|
|
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,5],$V1=[1,6],$V2=[1,12],$V3=[1,13],$V4=[1,14],$V5=[1,15],$V6=[1,16],$V7=[1,17],$V8=[1,18],$V9=[1,19],$Va=[1,20],$Vb=[1,21],$Vc=[1,22],$Vd=[8,16,17,18,19,20,21,22,23,24,25,26],$Ve=[1,37],$Vf=[1,33],$Vg=[1,34],$Vh=[1,35],$Vi=[1,36],$Vj=[8,10,16,17,18,19,20,21,22,23,24,25,26,28,32,37,39,40,45,57,58],$Vk=[10,28],$Vl=[10,28,37,57,58],$Vm=[2,49],$Vn=[1,45],$Vo=[1,48],$Vp=[1,49],$Vq=[1,52],$Vr=[2,65],$Vs=[1,65],$Vt=[1,66],$Vu=[1,67],$Vv=[1,68],$Vw=[1,69],$Vx=[1,70],$Vy=[1,71],$Vz=[1,72],$VA=[1,73],$VB=[8,16,17,18,19,20,21,22,23,24,25,26,47],$VC=[10,28,37];
|
|
var parser = {trace: function trace() { },
|
|
yy: {},
|
|
symbols_: {"error":2,"expressions":3,"graph":4,"EOF":5,"graphStatement":6,"idStatement":7,"{":8,"stmt_list":9,"}":10,"strict":11,"GRAPH":12,"DIGRAPH":13,"textNoTags":14,"textNoTagsToken":15,"ALPHA":16,"NUM":17,"COLON":18,"PLUS":19,"EQUALS":20,"MULT":21,"DOT":22,"BRKT":23,"SPACE":24,"MINUS":25,"keywords":26,"stmt":27,";":28,"node_stmt":29,"edge_stmt":30,"attr_stmt":31,"=":32,"subgraph":33,"attr_list":34,"NODE":35,"EDGE":36,"[":37,"a_list":38,"]":39,",":40,"edgeRHS":41,"node_id":42,"edgeop":43,"port":44,":":45,"compass_pt":46,"SUBGRAPH":47,"n":48,"ne":49,"e":50,"se":51,"s":52,"sw":53,"w":54,"nw":55,"c":56,"ARROW_POINT":57,"ARROW_OPEN":58,"$accept":0,"$end":1},
|
|
terminals_: {2:"error",5:"EOF",8:"{",10:"}",11:"strict",12:"GRAPH",13:"DIGRAPH",16:"ALPHA",17:"NUM",18:"COLON",19:"PLUS",20:"EQUALS",21:"MULT",22:"DOT",23:"BRKT",24:"SPACE",25:"MINUS",26:"keywords",28:";",32:"=",35:"NODE",36:"EDGE",37:"[",39:"]",40:",",45:":",47:"SUBGRAPH",48:"n",49:"ne",50:"e",51:"se",52:"s",53:"sw",54:"w",55:"nw",56:"c",57:"ARROW_POINT",58:"ARROW_OPEN"},
|
|
productions_: [0,[3,2],[4,5],[4,6],[4,4],[6,1],[6,1],[7,1],[14,1],[14,2],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[15,1],[9,1],[9,3],[27,1],[27,1],[27,1],[27,3],[27,1],[31,2],[31,2],[31,2],[34,4],[34,3],[34,3],[34,2],[38,5],[38,5],[38,3],[30,3],[30,3],[30,2],[30,2],[41,3],[41,3],[41,2],[41,2],[29,2],[29,1],[42,2],[42,1],[44,4],[44,2],[44,2],[33,5],[33,4],[33,3],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,1],[46,0],[43,1],[43,1]],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
|
/* this == yyval */
|
|
|
|
var $0 = $$.length - 1;
|
|
switch (yystate) {
|
|
case 1:
|
|
this.$=$$[$0-1];
|
|
break;
|
|
case 2:
|
|
this.$=$$[$0-4];
|
|
break;
|
|
case 3:
|
|
this.$=$$[$0-5];
|
|
break;
|
|
case 4:
|
|
this.$=$$[$0-3];
|
|
break;
|
|
case 8: case 10: case 11:
|
|
this.$=$$[$0];
|
|
break;
|
|
case 9:
|
|
this.$=$$[$0-1]+''+$$[$0];
|
|
break;
|
|
case 12: case 13: case 14: case 15: case 16: case 18: case 19: case 20:
|
|
this.$ = $$[$0];
|
|
break;
|
|
case 17:
|
|
this.$ = '<br>';
|
|
break;
|
|
case 39:
|
|
this.$='oy';
|
|
break;
|
|
case 40:
|
|
|
|
yy.addLink($$[$0-1],$$[$0].id,$$[$0].op);
|
|
this.$='oy';
|
|
break;
|
|
case 42:
|
|
|
|
yy.addLink($$[$0-1],$$[$0].id,$$[$0].op);
|
|
this.$={op:$$[$0-2],id:$$[$0-1]};
|
|
|
|
break;
|
|
case 44:
|
|
|
|
this.$={op:$$[$0-1],id:$$[$0]};
|
|
|
|
break;
|
|
case 48:
|
|
yy.addVertex($$[$0-1]);this.$=$$[$0-1];
|
|
break;
|
|
case 49:
|
|
yy.addVertex($$[$0]);this.$=$$[$0];
|
|
break;
|
|
case 66:
|
|
this.$='arrow';
|
|
break;
|
|
case 67:
|
|
this.$='arrow_open';
|
|
break;
|
|
}
|
|
},
|
|
table: [{3:1,4:2,6:3,11:[1,4],12:$V0,13:$V1},{1:[3]},{5:[1,7]},{7:8,8:[1,9],14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{6:23,12:$V0,13:$V1},o($Vd,[2,5]),o($Vd,[2,6]),{1:[2,1]},{8:[1,24]},{7:30,8:$Ve,9:25,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},o([8,10,28,32,37,39,40,45,57,58],[2,7],{15:38,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc}),o($Vj,[2,8]),o($Vj,[2,10]),o($Vj,[2,11]),o($Vj,[2,12]),o($Vj,[2,13]),o($Vj,[2,14]),o($Vj,[2,15]),o($Vj,[2,16]),o($Vj,[2,17]),o($Vj,[2,18]),o($Vj,[2,19]),o($Vj,[2,20]),{7:39,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{7:30,8:$Ve,9:40,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{10:[1,41]},{10:[2,21],28:[1,42]},o($Vk,[2,23]),o($Vk,[2,24]),o($Vk,[2,25]),o($Vl,$Vm,{44:44,32:[1,43],45:$Vn}),o($Vk,[2,27],{41:46,43:47,57:$Vo,58:$Vp}),o($Vk,[2,47],{43:47,34:50,41:51,37:$Vq,57:$Vo,58:$Vp}),{34:53,37:$Vq},{34:54,37:$Vq},{34:55,37:$Vq},{7:56,8:[1,57],14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{7:30,8:$Ve,9:58,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},o($Vj,[2,9]),{8:[1,59]},{10:[1,60]},{5:[2,4]},{7:30,8:$Ve,9:61,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{7:62,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},o($Vl,[2,48]),o($Vl,$Vr,{14:10,15:11,7:63,46:64,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,48:$Vs,49:$Vt,50:$Vu,51:$Vv,52:$Vw,53:$Vx,54:$Vy,55:$Vz,56:$VA}),o($Vk,[2,41],{34:74,37:$Vq}),{7:77,8:$Ve,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,33:76,42:75,47:$Vi},o($VB,[2,66]),o($VB,[2,67]),o($Vk,[2,46]),o($Vk,[2,40],{34:78,37:$Vq}),{7:81,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,38:79,39:[1,80]},o($Vk,[2,28]),o($Vk,[2,29]),o($Vk,[2,30]),{8:[1,82]},{7:30,8:$Ve,9:83,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{10:[1,84]},{7:30,8:$Ve,9:85,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{5:[2,2]},{10:[2,22]},o($Vk,[2,26]),o($Vl,[2,51],{45:[1,86]}),o($Vl,[2,52]),o($Vl,[2,56]),o($Vl,[2,57]),o($Vl,[2,58]),o($Vl,[2,59]),o($Vl,[2,60]),o($Vl,[2,61]),o($Vl,[2,62]),o($Vl,[2,63]),o($Vl,[2,64]),o($Vk,[2,38]),o($VC,[2,44],{43:47,41:87,57:$Vo,58:$Vp}),o($VC,[2,45],{43:47,41:88,57:$Vo,58:$Vp}),o($Vl,$Vm,{44:44,45:$Vn}),o($Vk,[2,39]),{39:[1,89]},o($Vk,[2,34],{34:90,37:$Vq}),{32:[1,91]},{7:30,8:$Ve,9:92,12:$Vf,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,27:26,29:27,30:28,31:29,33:31,35:$Vg,36:$Vh,42:32,47:$Vi},{10:[1,93]},o($Vl,[2,55]),{10:[1,94]},o($Vl,$Vr,{46:95,48:$Vs,49:$Vt,50:$Vu,51:$Vv,52:$Vw,53:$Vx,54:$Vy,55:$Vz,56:$VA}),o($VC,[2,42]),o($VC,[2,43]),o($Vk,[2,33],{34:96,37:$Vq}),o($Vk,[2,32]),{7:97,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc},{10:[1,98]},o($Vl,[2,54]),{5:[2,3]},o($Vl,[2,50]),o($Vk,[2,31]),{28:[1,99],39:[2,37],40:[1,100]},o($Vl,[2,53]),{7:81,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,38:101},{7:81,14:10,15:11,16:$V2,17:$V3,18:$V4,19:$V5,20:$V6,21:$V7,22:$V8,23:$V9,24:$Va,25:$Vb,26:$Vc,38:102},{39:[2,35]},{39:[2,36]}],
|
|
defaultActions: {7:[2,1],41:[2,4],60:[2,2],61:[2,22],94:[2,3],101:[2,35],102:[2,36]},
|
|
parseError: function parseError(str, hash) {
|
|
if (hash.recoverable) {
|
|
this.trace(str);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
parse: function parse(input) {
|
|
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
|
var args = lstack.slice.call(arguments, 1);
|
|
var lexer = Object.create(this.lexer);
|
|
var sharedState = { yy: {} };
|
|
for (var k in this.yy) {
|
|
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
sharedState.yy[k] = this.yy[k];
|
|
}
|
|
}
|
|
lexer.setInput(input, sharedState.yy);
|
|
sharedState.yy.lexer = lexer;
|
|
sharedState.yy.parser = this;
|
|
if (typeof lexer.yylloc == 'undefined') {
|
|
lexer.yylloc = {};
|
|
}
|
|
var yyloc = lexer.yylloc;
|
|
lstack.push(yyloc);
|
|
var ranges = lexer.options && lexer.options.ranges;
|
|
if (typeof sharedState.yy.parseError === 'function') {
|
|
this.parseError = sharedState.yy.parseError;
|
|
} else {
|
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
}
|
|
function popStack(n) {
|
|
stack.length = stack.length - 2 * n;
|
|
vstack.length = vstack.length - n;
|
|
lstack.length = lstack.length - n;
|
|
}
|
|
_token_stack:
|
|
function lex() {
|
|
var token;
|
|
token = lexer.lex() || EOF;
|
|
if (typeof token !== 'number') {
|
|
token = self.symbols_[token] || token;
|
|
}
|
|
return token;
|
|
}
|
|
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
|
while (true) {
|
|
state = stack[stack.length - 1];
|
|
if (this.defaultActions[state]) {
|
|
action = this.defaultActions[state];
|
|
} else {
|
|
if (symbol === null || typeof symbol == 'undefined') {
|
|
symbol = lex();
|
|
}
|
|
action = table[state] && table[state][symbol];
|
|
}
|
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
|
var errStr = '';
|
|
expected = [];
|
|
for (p in table[state]) {
|
|
if (this.terminals_[p] && p > TERROR) {
|
|
expected.push('\'' + this.terminals_[p] + '\'');
|
|
}
|
|
}
|
|
if (lexer.showPosition) {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
|
} else {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
|
}
|
|
this.parseError(errStr, {
|
|
text: lexer.match,
|
|
token: this.terminals_[symbol] || symbol,
|
|
line: lexer.yylineno,
|
|
loc: yyloc,
|
|
expected: expected
|
|
});
|
|
}
|
|
if (action[0] instanceof Array && action.length > 1) {
|
|
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
|
}
|
|
switch (action[0]) {
|
|
case 1:
|
|
stack.push(symbol);
|
|
vstack.push(lexer.yytext);
|
|
lstack.push(lexer.yylloc);
|
|
stack.push(action[1]);
|
|
symbol = null;
|
|
if (!preErrorSymbol) {
|
|
yyleng = lexer.yyleng;
|
|
yytext = lexer.yytext;
|
|
yylineno = lexer.yylineno;
|
|
yyloc = lexer.yylloc;
|
|
if (recovering > 0) {
|
|
recovering--;
|
|
}
|
|
} else {
|
|
symbol = preErrorSymbol;
|
|
preErrorSymbol = null;
|
|
}
|
|
break;
|
|
case 2:
|
|
len = this.productions_[action[1]][1];
|
|
yyval.$ = vstack[vstack.length - len];
|
|
yyval._$ = {
|
|
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
last_line: lstack[lstack.length - 1].last_line,
|
|
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
last_column: lstack[lstack.length - 1].last_column
|
|
};
|
|
if (ranges) {
|
|
yyval._$.range = [
|
|
lstack[lstack.length - (len || 1)].range[0],
|
|
lstack[lstack.length - 1].range[1]
|
|
];
|
|
}
|
|
r = this.performAction.apply(yyval, [
|
|
yytext,
|
|
yyleng,
|
|
yylineno,
|
|
sharedState.yy,
|
|
action[1],
|
|
vstack,
|
|
lstack
|
|
].concat(args));
|
|
if (typeof r !== 'undefined') {
|
|
return r;
|
|
}
|
|
if (len) {
|
|
stack = stack.slice(0, -1 * len * 2);
|
|
vstack = vstack.slice(0, -1 * len);
|
|
lstack = lstack.slice(0, -1 * len);
|
|
}
|
|
stack.push(this.productions_[action[1]][0]);
|
|
vstack.push(yyval.$);
|
|
lstack.push(yyval._$);
|
|
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
stack.push(newState);
|
|
break;
|
|
case 3:
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}};
|
|
|
|
/* generated by jison-lex 0.3.4 */
|
|
var lexer = (function(){
|
|
var lexer = ({
|
|
|
|
EOF:1,
|
|
|
|
parseError:function parseError(str, hash) {
|
|
if (this.yy.parser) {
|
|
this.yy.parser.parseError(str, hash);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
|
|
// resets the lexer, sets new input
|
|
setInput:function (input, yy) {
|
|
this.yy = yy || this.yy || {};
|
|
this._input = input;
|
|
this._more = this._backtrack = this.done = false;
|
|
this.yylineno = this.yyleng = 0;
|
|
this.yytext = this.matched = this.match = '';
|
|
this.conditionStack = ['INITIAL'];
|
|
this.yylloc = {
|
|
first_line: 1,
|
|
first_column: 0,
|
|
last_line: 1,
|
|
last_column: 0
|
|
};
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [0,0];
|
|
}
|
|
this.offset = 0;
|
|
return this;
|
|
},
|
|
|
|
// consumes and returns one char from the input
|
|
input:function () {
|
|
var ch = this._input[0];
|
|
this.yytext += ch;
|
|
this.yyleng++;
|
|
this.offset++;
|
|
this.match += ch;
|
|
this.matched += ch;
|
|
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno++;
|
|
this.yylloc.last_line++;
|
|
} else {
|
|
this.yylloc.last_column++;
|
|
}
|
|
if (this.options.ranges) {
|
|
this.yylloc.range[1]++;
|
|
}
|
|
|
|
this._input = this._input.slice(1);
|
|
return ch;
|
|
},
|
|
|
|
// unshifts one char (or a string) into the input
|
|
unput:function (ch) {
|
|
var len = ch.length;
|
|
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
|
|
this._input = ch + this._input;
|
|
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
//this.yyleng -= len;
|
|
this.offset -= len;
|
|
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
this.match = this.match.substr(0, this.match.length - 1);
|
|
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
|
|
if (lines.length - 1) {
|
|
this.yylineno -= lines.length - 1;
|
|
}
|
|
var r = this.yylloc.range;
|
|
|
|
this.yylloc = {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: lines ?
|
|
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
|
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
|
this.yylloc.first_column - len
|
|
};
|
|
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
}
|
|
this.yyleng = this.yytext.length;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, caches matched text and appends it on next action
|
|
more:function () {
|
|
this._more = true;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
|
reject:function () {
|
|
if (this.options.backtrack_lexer) {
|
|
this._backtrack = true;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// retain first n characters of the match
|
|
less:function (n) {
|
|
this.unput(this.match.slice(n));
|
|
},
|
|
|
|
// displays already matched input, i.e. for error messages
|
|
pastInput:function () {
|
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays upcoming input, i.e. for error messages
|
|
upcomingInput:function () {
|
|
var next = this.match;
|
|
if (next.length < 20) {
|
|
next += this._input.substr(0, 20-next.length);
|
|
}
|
|
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
showPosition:function () {
|
|
var pre = this.pastInput();
|
|
var c = new Array(pre.length + 1).join("-");
|
|
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
},
|
|
|
|
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
test_match:function (match, indexed_rule) {
|
|
var token,
|
|
lines,
|
|
backup;
|
|
|
|
if (this.options.backtrack_lexer) {
|
|
// save context
|
|
backup = {
|
|
yylineno: this.yylineno,
|
|
yylloc: {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.last_line,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: this.yylloc.last_column
|
|
},
|
|
yytext: this.yytext,
|
|
match: this.match,
|
|
matches: this.matches,
|
|
matched: this.matched,
|
|
yyleng: this.yyleng,
|
|
offset: this.offset,
|
|
_more: this._more,
|
|
_input: this._input,
|
|
yy: this.yy,
|
|
conditionStack: this.conditionStack.slice(0),
|
|
done: this.done
|
|
};
|
|
if (this.options.ranges) {
|
|
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
}
|
|
}
|
|
|
|
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno += lines.length;
|
|
}
|
|
this.yylloc = {
|
|
first_line: this.yylloc.last_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.last_column,
|
|
last_column: lines ?
|
|
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
|
this.yylloc.last_column + match[0].length
|
|
};
|
|
this.yytext += match[0];
|
|
this.match += match[0];
|
|
this.matches = match;
|
|
this.yyleng = this.yytext.length;
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
}
|
|
this._more = false;
|
|
this._backtrack = false;
|
|
this._input = this._input.slice(match[0].length);
|
|
this.matched += match[0];
|
|
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
if (this.done && this._input) {
|
|
this.done = false;
|
|
}
|
|
if (token) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
// recover context
|
|
for (var k in backup) {
|
|
this[k] = backup[k];
|
|
}
|
|
return false; // rule action called reject() implying the next rule should be tested instead.
|
|
}
|
|
return false;
|
|
},
|
|
|
|
// return next match in input
|
|
next:function () {
|
|
if (this.done) {
|
|
return this.EOF;
|
|
}
|
|
if (!this._input) {
|
|
this.done = true;
|
|
}
|
|
|
|
var token,
|
|
match,
|
|
tempMatch,
|
|
index;
|
|
if (!this._more) {
|
|
this.yytext = '';
|
|
this.match = '';
|
|
}
|
|
var rules = this._currentRules();
|
|
for (var i = 0; i < rules.length; i++) {
|
|
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
match = tempMatch;
|
|
index = i;
|
|
if (this.options.backtrack_lexer) {
|
|
token = this.test_match(tempMatch, rules[i]);
|
|
if (token !== false) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
match = false;
|
|
continue; // rule action called reject() implying a rule MISmatch.
|
|
} else {
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
} else if (!this.options.flex) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (match) {
|
|
token = this.test_match(match, rules[index]);
|
|
if (token !== false) {
|
|
return token;
|
|
}
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
if (this._input === "") {
|
|
return this.EOF;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
}
|
|
},
|
|
|
|
// return next match that has a token
|
|
lex:function lex() {
|
|
var r = this.next();
|
|
if (r) {
|
|
return r;
|
|
} else {
|
|
return this.lex();
|
|
}
|
|
},
|
|
|
|
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
begin:function begin(condition) {
|
|
this.conditionStack.push(condition);
|
|
},
|
|
|
|
// pop the previously active lexer condition state off the condition stack
|
|
popState:function popState() {
|
|
var n = this.conditionStack.length - 1;
|
|
if (n > 0) {
|
|
return this.conditionStack.pop();
|
|
} else {
|
|
return this.conditionStack[0];
|
|
}
|
|
},
|
|
|
|
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
_currentRules:function _currentRules() {
|
|
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
} else {
|
|
return this.conditions["INITIAL"].rules;
|
|
}
|
|
},
|
|
|
|
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
topState:function topState(n) {
|
|
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
if (n >= 0) {
|
|
return this.conditionStack[n];
|
|
} else {
|
|
return "INITIAL";
|
|
}
|
|
},
|
|
|
|
// alias for begin(condition)
|
|
pushState:function pushState(condition) {
|
|
this.begin(condition);
|
|
},
|
|
|
|
// return the number of states currently on the stack
|
|
stateStackSize:function stateStackSize() {
|
|
return this.conditionStack.length;
|
|
},
|
|
options: {},
|
|
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
|
var YYSTATE=YY_START;
|
|
switch($avoiding_name_collisions) {
|
|
case 0:return 'STYLE';
|
|
break;
|
|
case 1:return 'LINKSTYLE';
|
|
break;
|
|
case 2:return 'CLASSDEF';
|
|
break;
|
|
case 3:return 'CLASS';
|
|
break;
|
|
case 4:return 'CLICK';
|
|
break;
|
|
case 5:return 12;
|
|
break;
|
|
case 6:return 13;
|
|
break;
|
|
case 7:return 47;
|
|
break;
|
|
case 8:return 35;
|
|
break;
|
|
case 9:return 36;
|
|
break;
|
|
case 10:return 'DIR';
|
|
break;
|
|
case 11:return 'DIR';
|
|
break;
|
|
case 12:return 'DIR';
|
|
break;
|
|
case 13:return 'DIR';
|
|
break;
|
|
case 14:return 'DIR';
|
|
break;
|
|
case 15:return 'DIR';
|
|
break;
|
|
case 16:return 17;
|
|
break;
|
|
case 17:return 23;
|
|
break;
|
|
case 18:return 18;
|
|
break;
|
|
case 19:return 28;
|
|
break;
|
|
case 20:return 40;
|
|
break;
|
|
case 21:return 32;
|
|
break;
|
|
case 22:return 21;
|
|
break;
|
|
case 23:return 22;
|
|
break;
|
|
case 24:return 'ARROW_CROSS';
|
|
break;
|
|
case 25:return 57;
|
|
break;
|
|
case 26:return 'ARROW_CIRCLE';
|
|
break;
|
|
case 27:return 58;
|
|
break;
|
|
case 28:return 25;
|
|
break;
|
|
case 29:return 19;
|
|
break;
|
|
case 30:return 20;
|
|
break;
|
|
case 31:return 16;
|
|
break;
|
|
case 32:return 'PIPE';
|
|
break;
|
|
case 33:return 'PS';
|
|
break;
|
|
case 34:return 'PE';
|
|
break;
|
|
case 35:return 37;
|
|
break;
|
|
case 36:return 39;
|
|
break;
|
|
case 37:return 8
|
|
break;
|
|
case 38:return 10
|
|
break;
|
|
case 39:return 'QUOTE';
|
|
break;
|
|
case 40:return 24;
|
|
break;
|
|
case 41:return 'NEWLINE';
|
|
break;
|
|
case 42:return 5;
|
|
break;
|
|
}
|
|
},
|
|
rules: [/^(?:style\b)/,/^(?:linkStyle\b)/,/^(?:classDef\b)/,/^(?:class\b)/,/^(?:click\b)/,/^(?:graph\b)/,/^(?:digraph\b)/,/^(?:subgraph\b)/,/^(?:node\b)/,/^(?:edge\b)/,/^(?:LR\b)/,/^(?:RL\b)/,/^(?:TB\b)/,/^(?:BT\b)/,/^(?:TD\b)/,/^(?:BR\b)/,/^(?:[0-9])/,/^(?:#)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:=)/,/^(?:\*)/,/^(?:\.)/,/^(?:--[x])/,/^(?:->)/,/^(?:--[o])/,/^(?:--)/,/^(?:-)/,/^(?:\+)/,/^(?:=)/,/^(?:[\u0021-\u0027\u002A-\u002E\u003F\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC_])/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:")/,/^(?:\s)/,/^(?:\n)/,/^(?:$)/],
|
|
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"inclusive":true}}
|
|
});
|
|
return lexer;
|
|
})();
|
|
parser.lexer = lexer;
|
|
function Parser () {
|
|
this.yy = {};
|
|
}
|
|
Parser.prototype = parser;parser.Parser = Parser;
|
|
return new Parser;
|
|
})();
|
|
|
|
|
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
|
exports.parser = parser;
|
|
exports.Parser = parser.Parser;
|
|
exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
|
exports.main = function commonjsMain(args) {
|
|
if (!args[1]) {
|
|
console.log('Usage: '+args[0]+' FILE');
|
|
process.exit(1);
|
|
}
|
|
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
|
return exports.parser.parse(source);
|
|
};
|
|
if (typeof module !== 'undefined' && require.main === module) {
|
|
exports.main(process.argv.slice(1));
|
|
}
|
|
}
|
|
}).call(this,require("1YiZ5S"))
|
|
},{"1YiZ5S":81,"fs":79,"path":80}],93:[function(require,module,exports){
|
|
(function (process){
|
|
/* parser generated by jison 0.4.15 */
|
|
/*
|
|
Returns a Parser object of the following structure:
|
|
|
|
Parser: {
|
|
yy: {}
|
|
}
|
|
|
|
Parser.prototype: {
|
|
yy: {},
|
|
trace: function(),
|
|
symbols_: {associative list: name ==> number},
|
|
terminals_: {associative list: number ==> name},
|
|
productions_: [...],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
table: [...],
|
|
defaultActions: {...},
|
|
parseError: function(str, hash),
|
|
parse: function(input),
|
|
|
|
lexer: {
|
|
EOF: 1,
|
|
parseError: function(str, hash),
|
|
setInput: function(input),
|
|
input: function(),
|
|
unput: function(str),
|
|
more: function(),
|
|
less: function(n),
|
|
pastInput: function(),
|
|
upcomingInput: function(),
|
|
showPosition: function(),
|
|
test_match: function(regex_match_array, rule_index),
|
|
next: function(),
|
|
lex: function(),
|
|
begin: function(condition),
|
|
popState: function(),
|
|
_currentRules: function(),
|
|
topState: function(),
|
|
pushState: function(condition),
|
|
|
|
options: {
|
|
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
},
|
|
|
|
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
rules: [...],
|
|
conditions: {associative list: name ==> set},
|
|
}
|
|
}
|
|
|
|
|
|
token location info (@$, _$, etc.): {
|
|
first_line: n,
|
|
last_line: n,
|
|
first_column: n,
|
|
last_column: n,
|
|
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
}
|
|
|
|
|
|
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
text: (matched text)
|
|
token: (the produced terminal token, if any)
|
|
line: (yylineno)
|
|
}
|
|
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
loc: (yylloc)
|
|
expected: (string describing the set of expected tokens)
|
|
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
}
|
|
*/
|
|
var parser = (function(){
|
|
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[1,3],$V2=[1,5],$V3=[1,8,9,10,11,13,30,67,68,69,70,71,77,81,83,84,86,87,89,90,91],$V4=[2,2],$V5=[1,12],$V6=[1,13],$V7=[1,14],$V8=[1,15],$V9=[1,31],$Va=[1,22],$Vb=[1,24],$Vc=[1,25],$Vd=[1,26],$Ve=[1,27],$Vf=[1,28],$Vg=[1,34],$Vh=[1,36],$Vi=[1,33],$Vj=[1,35],$Vk=[1,41],$Vl=[1,40],$Vm=[1,37],$Vn=[1,38],$Vo=[1,39],$Vp=[1,8,9,10,11,13,30,32,67,68,69,70,71,77,81,83,84,86,87,89,90,91],$Vq=[1,49],$Vr=[1,48],$Vs=[1,50],$Vt=[1,67],$Vu=[1,75],$Vv=[1,76],$Vw=[1,61],$Vx=[1,60],$Vy=[1,80],$Vz=[1,79],$VA=[1,77],$VB=[1,78],$VC=[1,68],$VD=[1,63],$VE=[1,62],$VF=[1,70],$VG=[1,71],$VH=[1,72],$VI=[1,73],$VJ=[1,74],$VK=[1,65],$VL=[1,64],$VM=[8,9,11],$VN=[8,9,11,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61],$VO=[1,109],$VP=[8,9,10,11,13,15,36,38,40,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,77,81,83,84,86,87,89,90,91],$VQ=[8,9,10,11,12,13,15,16,17,18,30,32,36,37,38,39,40,41,44,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,67,68,69,70,71,74,77,79,81,83,84,86,87,89,90,91],$VR=[1,112],$VS=[1,113],$VT=[8,9,10,11,13,30,32,67,68,69,70,71,77,81,83,84,86,87,89,90,91],$VU=[8,9,10,11,12,13,15,16,17,18,30,32,37,39,41,44,47,48,49,50,51,53,54,55,56,57,58,59,60,61,62,67,68,69,70,71,74,77,79,81,83,84,86,87,89,90,91],$VV=[13,77,81,83,84,86,87,89,90,91],$VW=[13,62,77,81,83,84,86,87,89,90,91],$VX=[1,183],$VY=[1,180],$VZ=[1,187],$V_=[1,184],$V$=[1,181],$V01=[1,188],$V11=[1,178],$V21=[1,179],$V31=[1,182],$V41=[1,185],$V51=[1,186],$V61=[1,201],$V71=[8,9,11,81],$V81=[8,9,10,11,44,67,76,77,79,81,83,84,85,86,87];
|
|
var parser = {trace: function trace() { },
|
|
yy: {},
|
|
symbols_: {"error":2,"mermaidDoc":3,"graphConfig":4,"document":5,"line":6,"statement":7,"SEMI":8,"NEWLINE":9,"SPACE":10,"EOF":11,"GRAPH":12,"DIR":13,"FirstStmtSeperator":14,"TAGEND":15,"TAGSTART":16,"UP":17,"DOWN":18,"ending":19,"endToken":20,"spaceList":21,"spaceListNewline":22,"verticeStatement":23,"separator":24,"styleStatement":25,"linkStyleStatement":26,"classDefStatement":27,"classStatement":28,"clickStatement":29,"subgraph":30,"text":31,"end":32,"vertex":33,"link":34,"alphaNum":35,"SQS":36,"SQE":37,"PS":38,"PE":39,"DIAMOND_START":40,"DIAMOND_STOP":41,"alphaNumStatement":42,"alphaNumToken":43,"MINUS":44,"linkStatement":45,"arrowText":46,"--":47,"ARROW_POINT":48,"ARROW_CIRCLE":49,"ARROW_CROSS":50,"ARROW_OPEN":51,"-.":52,"DOTTED_ARROW_POINT":53,"DOTTED_ARROW_CIRCLE":54,"DOTTED_ARROW_CROSS":55,"DOTTED_ARROW_OPEN":56,"==":57,"THICK_ARROW_POINT":58,"THICK_ARROW_CIRCLE":59,"THICK_ARROW_CROSS":60,"THICK_ARROW_OPEN":61,"PIPE":62,"textToken":63,"commentText":64,"commentToken":65,"keywords":66,"STYLE":67,"LINKSTYLE":68,"CLASSDEF":69,"CLASS":70,"CLICK":71,"textNoTags":72,"textNoTagsToken":73,"DEFAULT":74,"stylesOpt":75,"HEX":76,"NUM":77,"commentStatement":78,"PCT":79,"style":80,"COMMA":81,"styleComponent":82,"ALPHA":83,"COLON":84,"UNIT":85,"BRKT":86,"DOT":87,"graphCodeTokens":88,"PLUS":89,"EQUALS":90,"MULT":91,"TAG_START":92,"TAG_END":93,"QUOTE":94,"$accept":0,"$end":1},
|
|
terminals_: {2:"error",8:"SEMI",9:"NEWLINE",10:"SPACE",11:"EOF",12:"GRAPH",13:"DIR",15:"TAGEND",16:"TAGSTART",17:"UP",18:"DOWN",30:"subgraph",32:"end",36:"SQS",37:"SQE",38:"PS",39:"PE",40:"DIAMOND_START",41:"DIAMOND_STOP",44:"MINUS",47:"--",48:"ARROW_POINT",49:"ARROW_CIRCLE",50:"ARROW_CROSS",51:"ARROW_OPEN",52:"-.",53:"DOTTED_ARROW_POINT",54:"DOTTED_ARROW_CIRCLE",55:"DOTTED_ARROW_CROSS",56:"DOTTED_ARROW_OPEN",57:"==",58:"THICK_ARROW_POINT",59:"THICK_ARROW_CIRCLE",60:"THICK_ARROW_CROSS",61:"THICK_ARROW_OPEN",62:"PIPE",67:"STYLE",68:"LINKSTYLE",69:"CLASSDEF",70:"CLASS",71:"CLICK",74:"DEFAULT",76:"HEX",77:"NUM",79:"PCT",81:"COMMA",83:"ALPHA",84:"COLON",85:"UNIT",86:"BRKT",87:"DOT",89:"PLUS",90:"EQUALS",91:"MULT",92:"TAG_START",93:"TAG_END",94:"QUOTE"},
|
|
productions_: [0,[3,2],[5,0],[5,2],[6,1],[6,1],[6,1],[6,1],[6,1],[4,2],[4,2],[4,4],[4,4],[4,4],[4,4],[4,4],[19,2],[19,1],[20,1],[20,1],[20,1],[14,1],[14,1],[14,2],[22,2],[22,2],[22,1],[22,1],[21,2],[21,1],[7,2],[7,2],[7,2],[7,2],[7,2],[7,2],[7,5],[7,4],[24,1],[24,1],[24,1],[23,3],[23,1],[33,4],[33,5],[33,6],[33,7],[33,4],[33,5],[33,4],[33,5],[33,4],[33,5],[33,1],[33,2],[35,1],[35,2],[42,1],[42,1],[42,3],[34,2],[34,3],[34,1],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[34,3],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[45,1],[46,3],[31,1],[31,2],[64,1],[64,2],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[66,1],[72,1],[72,2],[27,5],[27,5],[28,5],[29,5],[25,5],[25,5],[26,5],[26,5],[78,3],[75,1],[75,3],[80,1],[80,2],[82,1],[82,1],[82,1],[82,1],[82,1],[82,1],[82,1],[82,1],[82,1],[82,1],[82,1],[65,1],[65,1],[63,1],[63,1],[63,1],[63,1],[63,1],[63,1],[63,1],[73,1],[73,1],[73,1],[73,1],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[43,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1],[88,1]],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
|
/* this == yyval */
|
|
|
|
var $0 = $$.length - 1;
|
|
switch (yystate) {
|
|
case 2:
|
|
this.$ = [];
|
|
break;
|
|
case 3:
|
|
|
|
if($$[$0] !== []){
|
|
$$[$0-1].push($$[$0]);
|
|
}
|
|
this.$=$$[$0-1];
|
|
break;
|
|
case 4: case 55: case 57: case 58: case 88: case 90: case 103:
|
|
this.$=$$[$0];
|
|
break;
|
|
case 11:
|
|
yy.setDirection($$[$0-1]);this.$ = $$[$0-1];
|
|
break;
|
|
case 12:
|
|
yy.setDirection("LR");this.$ = $$[$0-1];
|
|
break;
|
|
case 13:
|
|
yy.setDirection("RL");this.$ = $$[$0-1];
|
|
break;
|
|
case 14:
|
|
yy.setDirection("BT");this.$ = $$[$0-1];
|
|
break;
|
|
case 15:
|
|
yy.setDirection("TB");this.$ = $$[$0-1];
|
|
break;
|
|
case 30:
|
|
this.$=$$[$0-1]
|
|
break;
|
|
case 31: case 32: case 33: case 34: case 35:
|
|
this.$=[];
|
|
break;
|
|
case 36:
|
|
this.$=yy.addSubGraph($$[$0-1],$$[$0-3]);
|
|
break;
|
|
case 37:
|
|
this.$=yy.addSubGraph($$[$0-1],undefined);
|
|
break;
|
|
case 41:
|
|
yy.addLink($$[$0-2],$$[$0],$$[$0-1]);this.$ = [$$[$0-2],$$[$0]];
|
|
break;
|
|
case 42:
|
|
this.$ = [$$[$0]];
|
|
break;
|
|
case 43:
|
|
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'square');
|
|
break;
|
|
case 44:
|
|
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'square');
|
|
break;
|
|
case 45:
|
|
this.$ = $$[$0-5];yy.addVertex($$[$0-5],$$[$0-2],'circle');
|
|
break;
|
|
case 46:
|
|
this.$ = $$[$0-6];yy.addVertex($$[$0-6],$$[$0-3],'circle');
|
|
break;
|
|
case 47:
|
|
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'round');
|
|
break;
|
|
case 48:
|
|
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'round');
|
|
break;
|
|
case 49:
|
|
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'diamond');
|
|
break;
|
|
case 50:
|
|
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'diamond');
|
|
break;
|
|
case 51:
|
|
this.$ = $$[$0-3];yy.addVertex($$[$0-3],$$[$0-1],'odd');
|
|
break;
|
|
case 52:
|
|
this.$ = $$[$0-4];yy.addVertex($$[$0-4],$$[$0-2],'odd');
|
|
break;
|
|
case 53:
|
|
this.$ = $$[$0];yy.addVertex($$[$0]);
|
|
break;
|
|
case 54:
|
|
this.$ = $$[$0-1];yy.addVertex($$[$0-1]);
|
|
break;
|
|
case 56: case 89: case 91: case 104:
|
|
this.$=$$[$0-1]+''+$$[$0];
|
|
break;
|
|
case 59:
|
|
this.$=$$[$0-2]+'-'+$$[$0];
|
|
break;
|
|
case 60:
|
|
$$[$0-1].text = $$[$0];this.$ = $$[$0-1];
|
|
break;
|
|
case 61:
|
|
$$[$0-2].text = $$[$0-1];this.$ = $$[$0-2];
|
|
break;
|
|
case 62:
|
|
this.$ = $$[$0];
|
|
break;
|
|
case 63:
|
|
this.$ = {"type":"arrow","stroke":"normal","text":$$[$0-1]};
|
|
break;
|
|
case 64:
|
|
this.$ = {"type":"arrow_circle","stroke":"normal","text":$$[$0-1]};
|
|
break;
|
|
case 65:
|
|
this.$ = {"type":"arrow_cross","stroke":"normal","text":$$[$0-1]};
|
|
break;
|
|
case 66:
|
|
this.$ = {"type":"arrow_open","stroke":"normal","text":$$[$0-1]};
|
|
break;
|
|
case 67:
|
|
this.$ = {"type":"arrow","stroke":"dotted","text":$$[$0-1]};
|
|
break;
|
|
case 68:
|
|
this.$ = {"type":"arrow_circle","stroke":"dotted","text":$$[$0-1]};
|
|
break;
|
|
case 69:
|
|
this.$ = {"type":"arrow_cross","stroke":"dotted","text":$$[$0-1]};
|
|
break;
|
|
case 70:
|
|
this.$ = {"type":"arrow_open","stroke":"dotted","text":$$[$0-1]};
|
|
break;
|
|
case 71:
|
|
this.$ = {"type":"arrow","stroke":"thick","text":$$[$0-1]};
|
|
break;
|
|
case 72:
|
|
this.$ = {"type":"arrow_circle","stroke":"thick","text":$$[$0-1]};
|
|
break;
|
|
case 73:
|
|
this.$ = {"type":"arrow_cross","stroke":"thick","text":$$[$0-1]};
|
|
break;
|
|
case 74:
|
|
this.$ = {"type":"arrow_open","stroke":"thick","text":$$[$0-1]};
|
|
break;
|
|
case 75:
|
|
this.$ = {"type":"arrow","stroke":"normal"};
|
|
break;
|
|
case 76:
|
|
this.$ = {"type":"arrow_circle","stroke":"normal"};
|
|
break;
|
|
case 77:
|
|
this.$ = {"type":"arrow_cross","stroke":"normal"};
|
|
break;
|
|
case 78:
|
|
this.$ = {"type":"arrow_open","stroke":"normal"};
|
|
break;
|
|
case 79:
|
|
this.$ = {"type":"arrow","stroke":"dotted"};
|
|
break;
|
|
case 80:
|
|
this.$ = {"type":"arrow_circle","stroke":"dotted"};
|
|
break;
|
|
case 81:
|
|
this.$ = {"type":"arrow_cross","stroke":"dotted"};
|
|
break;
|
|
case 82:
|
|
this.$ = {"type":"arrow_open","stroke":"dotted"};
|
|
break;
|
|
case 83:
|
|
this.$ = {"type":"arrow","stroke":"thick"};
|
|
break;
|
|
case 84:
|
|
this.$ = {"type":"arrow_circle","stroke":"thick"};
|
|
break;
|
|
case 85:
|
|
this.$ = {"type":"arrow_cross","stroke":"thick"};
|
|
break;
|
|
case 86:
|
|
this.$ = {"type":"arrow_open","stroke":"thick"};
|
|
break;
|
|
case 87:
|
|
this.$ = $$[$0-1];
|
|
break;
|
|
case 105: case 106:
|
|
this.$ = $$[$0-4];yy.addClass($$[$0-2],$$[$0]);
|
|
break;
|
|
case 107:
|
|
this.$ = $$[$0-4];yy.setClass($$[$0-2], $$[$0]);
|
|
break;
|
|
case 108:
|
|
this.$ = $$[$0-4];yy.setClickEvent($$[$0-2], $$[$0]);
|
|
break;
|
|
case 109:
|
|
this.$ = $$[$0-4];yy.addVertex($$[$0-2],undefined,undefined,$$[$0]);
|
|
break;
|
|
case 110: case 111: case 112:
|
|
this.$ = $$[$0-4];yy.updateLink($$[$0-2],$$[$0]);
|
|
break;
|
|
case 114:
|
|
this.$ = [$$[$0]]
|
|
break;
|
|
case 115:
|
|
$$[$0-2].push($$[$0]);this.$ = $$[$0-2];
|
|
break;
|
|
case 117:
|
|
this.$ = $$[$0-1] + $$[$0];
|
|
break;
|
|
}
|
|
},
|
|
table: [{3:1,4:2,9:$V0,10:$V1,12:$V2},{1:[3]},o($V3,$V4,{5:6}),{4:7,9:$V0,10:$V1,12:$V2},{4:8,9:$V0,10:$V1,12:$V2},{10:[1,9]},{1:[2,1],6:10,7:11,8:$V5,9:$V6,10:$V7,11:$V8,13:$V9,23:16,25:17,26:18,27:19,28:20,29:21,30:$Va,33:23,35:29,42:30,43:32,67:$Vb,68:$Vc,69:$Vd,70:$Ve,71:$Vf,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($V3,[2,9]),o($V3,[2,10]),{13:[1,42],15:[1,43],16:[1,44],17:[1,45],18:[1,46]},o($Vp,[2,3]),o($Vp,[2,4]),o($Vp,[2,5]),o($Vp,[2,6]),o($Vp,[2,7]),o($Vp,[2,8]),{8:$Vq,9:$Vr,11:$Vs,24:47},{8:$Vq,9:$Vr,11:$Vs,24:51},{8:$Vq,9:$Vr,11:$Vs,24:52},{8:$Vq,9:$Vr,11:$Vs,24:53},{8:$Vq,9:$Vr,11:$Vs,24:54},{8:$Vq,9:$Vr,11:$Vs,24:55},{8:$Vq,9:$Vr,10:$Vt,11:$Vs,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,24:57,30:$VA,31:56,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VM,[2,42],{34:81,45:82,47:[1,83],48:[1,86],49:[1,87],50:[1,88],51:[1,89],52:[1,84],53:[1,90],54:[1,91],55:[1,92],56:[1,93],57:[1,85],58:[1,94],59:[1,95],60:[1,96],61:[1,97]}),{10:[1,98]},{10:[1,99]},{10:[1,100]},{10:[1,101]},{10:[1,102]},o($VN,[2,53],{43:32,21:107,42:108,10:$VO,13:$V9,15:[1,106],36:[1,103],38:[1,104],40:[1,105],77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo}),o($VP,[2,55]),o($VP,[2,57]),o($VP,[2,58],{44:[1,110]}),o($VQ,[2,142]),o($VQ,[2,143]),o($VQ,[2,144]),o($VQ,[2,145]),o($VQ,[2,146]),o($VQ,[2,147]),o($VQ,[2,148]),o($VQ,[2,149]),o($VQ,[2,150]),{8:$VR,9:$VS,10:$VO,14:111,21:114},{8:$VR,9:$VS,10:$VO,14:115,21:114},{8:$VR,9:$VS,10:$VO,14:116,21:114},{8:$VR,9:$VS,10:$VO,14:117,21:114},{8:$VR,9:$VS,10:$VO,14:118,21:114},o($Vp,[2,30]),o($Vp,[2,38]),o($Vp,[2,39]),o($Vp,[2,40]),o($Vp,[2,31]),o($Vp,[2,32]),o($Vp,[2,33]),o($Vp,[2,34]),o($Vp,[2,35]),{8:$Vq,9:$Vr,10:$Vt,11:$Vs,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,24:119,30:$VA,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VT,$V4,{5:121}),o($VU,[2,88]),o($VU,[2,131]),o($VU,[2,132]),o($VU,[2,133]),o($VU,[2,134]),o($VU,[2,135]),o($VU,[2,136]),o($VU,[2,137]),o($VU,[2,138]),o($VU,[2,139]),o($VU,[2,140]),o($VU,[2,141]),o($VU,[2,92]),o($VU,[2,93]),o($VU,[2,94]),o($VU,[2,95]),o($VU,[2,96]),o($VU,[2,97]),o($VU,[2,98]),o($VU,[2,99]),o($VU,[2,100]),o($VU,[2,101]),o($VU,[2,102]),{13:$V9,33:122,35:29,42:30,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VV,[2,62],{46:123,62:[1,124]}),{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:125,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:126,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:127,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VW,[2,75]),o($VW,[2,76]),o($VW,[2,77]),o($VW,[2,78]),o($VW,[2,79]),o($VW,[2,80]),o($VW,[2,81]),o($VW,[2,82]),o($VW,[2,83]),o($VW,[2,84]),o($VW,[2,85]),o($VW,[2,86]),{13:$V9,35:128,42:30,43:32,76:[1,129],77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{74:[1,130],77:[1,131]},{13:$V9,35:133,42:30,43:32,74:[1,132],77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{13:$V9,35:134,42:30,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{13:$V9,35:135,42:30,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:136,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:138,32:$VB,38:[1,137],43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:139,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:140,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VN,[2,54]),o($VP,[2,56]),o($VN,[2,29],{21:141,10:$VO}),{43:142,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($V3,[2,11]),o($V3,[2,21]),o($V3,[2,22]),{9:[1,143]},o($V3,[2,12]),o($V3,[2,13]),o($V3,[2,14]),o($V3,[2,15]),o($VT,$V4,{5:144}),o($VU,[2,89]),{6:10,7:11,8:$V5,9:$V6,10:$V7,11:$V8,13:$V9,23:16,25:17,26:18,27:19,28:20,29:21,30:$Va,32:[1,145],33:23,35:29,42:30,43:32,67:$Vb,68:$Vc,69:$Vd,70:$Ve,71:$Vf,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VM,[2,41]),o($VV,[2,60],{10:[1,146]}),{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:147,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,43:66,44:$VC,47:$VD,48:[1,148],49:[1,149],50:[1,150],51:[1,151],57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,43:66,44:$VC,47:$VD,53:[1,152],54:[1,153],55:[1,154],56:[1,155],57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,43:66,44:$VC,47:$VD,57:$VE,58:[1,156],59:[1,157],60:[1,158],61:[1,159],63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:[1,160],13:$V9,42:108,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:[1,161]},{10:[1,162]},{10:[1,163]},{10:[1,164]},{10:[1,165],13:$V9,42:108,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:[1,166],13:$V9,42:108,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:[1,167],13:$V9,42:108,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,37:[1,168],43:66,44:$VC,47:$VD,57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,31:169,32:$VB,43:66,44:$VC,47:$VD,57:$VE,63:58,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,39:[1,170],43:66,44:$VC,47:$VD,57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,41:[1,171],43:66,44:$VC,47:$VD,57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,37:[1,172],43:66,44:$VC,47:$VD,57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VN,[2,28]),o($VP,[2,59]),o($V3,[2,23]),{6:10,7:11,8:$V5,9:$V6,10:$V7,11:$V8,13:$V9,23:16,25:17,26:18,27:19,28:20,29:21,30:$Va,32:[1,173],33:23,35:29,42:30,43:32,67:$Vb,68:$Vc,69:$Vd,70:$Ve,71:$Vf,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($Vp,[2,37]),o($VV,[2,61]),{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,43:66,44:$VC,47:$VD,57:$VE,62:[1,174],63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VV,[2,63]),o($VV,[2,64]),o($VV,[2,65]),o($VV,[2,66]),o($VV,[2,67]),o($VV,[2,68]),o($VV,[2,69]),o($VV,[2,70]),o($VV,[2,71]),o($VV,[2,72]),o($VV,[2,73]),o($VV,[2,74]),{10:$VX,44:$VY,67:$VZ,75:175,76:$V_,77:$V$,79:$V01,80:176,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},{10:$VX,44:$VY,67:$VZ,75:189,76:$V_,77:$V$,79:$V01,80:176,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},{10:$VX,44:$VY,67:$VZ,75:190,76:$V_,77:$V$,79:$V01,80:176,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},{10:$VX,44:$VY,67:$VZ,75:191,76:$V_,77:$V$,79:$V01,80:176,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},{10:$VX,44:$VY,67:$VZ,75:192,76:$V_,77:$V$,79:$V01,80:176,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},{10:$VX,44:$VY,67:$VZ,75:193,76:$V_,77:$V$,79:$V01,80:176,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},{13:$V9,35:194,42:30,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},{13:$V9,35:195,42:30,43:32,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VN,[2,43],{21:196,10:$VO}),{10:$Vt,12:$Vu,13:$Vv,15:$Vw,16:$Vx,17:$Vy,18:$Vz,30:$VA,32:$VB,39:[1,197],43:66,44:$VC,47:$VD,57:$VE,63:120,66:69,67:$VF,68:$VG,69:$VH,70:$VI,71:$VJ,73:59,74:$VK,77:$Vg,79:$VL,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo},o($VN,[2,47],{21:198,10:$VO}),o($VN,[2,49],{21:199,10:$VO}),o($VN,[2,51],{21:200,10:$VO}),o($Vp,[2,36]),o([10,13,77,81,83,84,86,87,89,90,91],[2,87]),o($VM,[2,109],{81:$V61}),o($V71,[2,114],{82:202,10:$VX,44:$VY,67:$VZ,76:$V_,77:$V$,79:$V01,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51}),o($V81,[2,116]),o($V81,[2,118]),o($V81,[2,119]),o($V81,[2,120]),o($V81,[2,121]),o($V81,[2,122]),o($V81,[2,123]),o($V81,[2,124]),o($V81,[2,125]),o($V81,[2,126]),o($V81,[2,127]),o($V81,[2,128]),o($VM,[2,110],{81:$V61}),o($VM,[2,111],{81:$V61}),o($VM,[2,112],{81:$V61}),o($VM,[2,105],{81:$V61}),o($VM,[2,106],{81:$V61}),o($VM,[2,107],{43:32,42:108,13:$V9,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo}),o($VM,[2,108],{43:32,42:108,13:$V9,77:$Vg,81:$Vh,83:$Vi,84:$Vj,86:$Vk,87:$Vl,89:$Vm,90:$Vn,91:$Vo}),o($VN,[2,44]),{39:[1,203]},o($VN,[2,48]),o($VN,[2,50]),o($VN,[2,52]),{10:$VX,44:$VY,67:$VZ,76:$V_,77:$V$,79:$V01,80:204,82:177,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51},o($V81,[2,117]),o($VN,[2,45],{21:205,10:$VO}),o($V71,[2,115],{82:202,10:$VX,44:$VY,67:$VZ,76:$V_,77:$V$,79:$V01,83:$V11,84:$V21,85:$V31,86:$V41,87:$V51}),o($VN,[2,46])],
|
|
defaultActions: {},
|
|
parseError: function parseError(str, hash) {
|
|
if (hash.recoverable) {
|
|
this.trace(str);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
parse: function parse(input) {
|
|
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
|
var args = lstack.slice.call(arguments, 1);
|
|
var lexer = Object.create(this.lexer);
|
|
var sharedState = { yy: {} };
|
|
for (var k in this.yy) {
|
|
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
sharedState.yy[k] = this.yy[k];
|
|
}
|
|
}
|
|
lexer.setInput(input, sharedState.yy);
|
|
sharedState.yy.lexer = lexer;
|
|
sharedState.yy.parser = this;
|
|
if (typeof lexer.yylloc == 'undefined') {
|
|
lexer.yylloc = {};
|
|
}
|
|
var yyloc = lexer.yylloc;
|
|
lstack.push(yyloc);
|
|
var ranges = lexer.options && lexer.options.ranges;
|
|
if (typeof sharedState.yy.parseError === 'function') {
|
|
this.parseError = sharedState.yy.parseError;
|
|
} else {
|
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
}
|
|
function popStack(n) {
|
|
stack.length = stack.length - 2 * n;
|
|
vstack.length = vstack.length - n;
|
|
lstack.length = lstack.length - n;
|
|
}
|
|
_token_stack:
|
|
function lex() {
|
|
var token;
|
|
token = lexer.lex() || EOF;
|
|
if (typeof token !== 'number') {
|
|
token = self.symbols_[token] || token;
|
|
}
|
|
return token;
|
|
}
|
|
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
|
while (true) {
|
|
state = stack[stack.length - 1];
|
|
if (this.defaultActions[state]) {
|
|
action = this.defaultActions[state];
|
|
} else {
|
|
if (symbol === null || typeof symbol == 'undefined') {
|
|
symbol = lex();
|
|
}
|
|
action = table[state] && table[state][symbol];
|
|
}
|
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
|
var errStr = '';
|
|
expected = [];
|
|
for (p in table[state]) {
|
|
if (this.terminals_[p] && p > TERROR) {
|
|
expected.push('\'' + this.terminals_[p] + '\'');
|
|
}
|
|
}
|
|
if (lexer.showPosition) {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
|
} else {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
|
}
|
|
this.parseError(errStr, {
|
|
text: lexer.match,
|
|
token: this.terminals_[symbol] || symbol,
|
|
line: lexer.yylineno,
|
|
loc: yyloc,
|
|
expected: expected
|
|
});
|
|
}
|
|
if (action[0] instanceof Array && action.length > 1) {
|
|
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
|
}
|
|
switch (action[0]) {
|
|
case 1:
|
|
stack.push(symbol);
|
|
vstack.push(lexer.yytext);
|
|
lstack.push(lexer.yylloc);
|
|
stack.push(action[1]);
|
|
symbol = null;
|
|
if (!preErrorSymbol) {
|
|
yyleng = lexer.yyleng;
|
|
yytext = lexer.yytext;
|
|
yylineno = lexer.yylineno;
|
|
yyloc = lexer.yylloc;
|
|
if (recovering > 0) {
|
|
recovering--;
|
|
}
|
|
} else {
|
|
symbol = preErrorSymbol;
|
|
preErrorSymbol = null;
|
|
}
|
|
break;
|
|
case 2:
|
|
len = this.productions_[action[1]][1];
|
|
yyval.$ = vstack[vstack.length - len];
|
|
yyval._$ = {
|
|
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
last_line: lstack[lstack.length - 1].last_line,
|
|
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
last_column: lstack[lstack.length - 1].last_column
|
|
};
|
|
if (ranges) {
|
|
yyval._$.range = [
|
|
lstack[lstack.length - (len || 1)].range[0],
|
|
lstack[lstack.length - 1].range[1]
|
|
];
|
|
}
|
|
r = this.performAction.apply(yyval, [
|
|
yytext,
|
|
yyleng,
|
|
yylineno,
|
|
sharedState.yy,
|
|
action[1],
|
|
vstack,
|
|
lstack
|
|
].concat(args));
|
|
if (typeof r !== 'undefined') {
|
|
return r;
|
|
}
|
|
if (len) {
|
|
stack = stack.slice(0, -1 * len * 2);
|
|
vstack = vstack.slice(0, -1 * len);
|
|
lstack = lstack.slice(0, -1 * len);
|
|
}
|
|
stack.push(this.productions_[action[1]][0]);
|
|
vstack.push(yyval.$);
|
|
lstack.push(yyval._$);
|
|
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
stack.push(newState);
|
|
break;
|
|
case 3:
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}};
|
|
|
|
/* generated by jison-lex 0.3.4 */
|
|
var lexer = (function(){
|
|
var lexer = ({
|
|
|
|
EOF:1,
|
|
|
|
parseError:function parseError(str, hash) {
|
|
if (this.yy.parser) {
|
|
this.yy.parser.parseError(str, hash);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
|
|
// resets the lexer, sets new input
|
|
setInput:function (input, yy) {
|
|
this.yy = yy || this.yy || {};
|
|
this._input = input;
|
|
this._more = this._backtrack = this.done = false;
|
|
this.yylineno = this.yyleng = 0;
|
|
this.yytext = this.matched = this.match = '';
|
|
this.conditionStack = ['INITIAL'];
|
|
this.yylloc = {
|
|
first_line: 1,
|
|
first_column: 0,
|
|
last_line: 1,
|
|
last_column: 0
|
|
};
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [0,0];
|
|
}
|
|
this.offset = 0;
|
|
return this;
|
|
},
|
|
|
|
// consumes and returns one char from the input
|
|
input:function () {
|
|
var ch = this._input[0];
|
|
this.yytext += ch;
|
|
this.yyleng++;
|
|
this.offset++;
|
|
this.match += ch;
|
|
this.matched += ch;
|
|
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno++;
|
|
this.yylloc.last_line++;
|
|
} else {
|
|
this.yylloc.last_column++;
|
|
}
|
|
if (this.options.ranges) {
|
|
this.yylloc.range[1]++;
|
|
}
|
|
|
|
this._input = this._input.slice(1);
|
|
return ch;
|
|
},
|
|
|
|
// unshifts one char (or a string) into the input
|
|
unput:function (ch) {
|
|
var len = ch.length;
|
|
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
|
|
this._input = ch + this._input;
|
|
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
//this.yyleng -= len;
|
|
this.offset -= len;
|
|
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
this.match = this.match.substr(0, this.match.length - 1);
|
|
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
|
|
if (lines.length - 1) {
|
|
this.yylineno -= lines.length - 1;
|
|
}
|
|
var r = this.yylloc.range;
|
|
|
|
this.yylloc = {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: lines ?
|
|
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
|
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
|
this.yylloc.first_column - len
|
|
};
|
|
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
}
|
|
this.yyleng = this.yytext.length;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, caches matched text and appends it on next action
|
|
more:function () {
|
|
this._more = true;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
|
reject:function () {
|
|
if (this.options.backtrack_lexer) {
|
|
this._backtrack = true;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// retain first n characters of the match
|
|
less:function (n) {
|
|
this.unput(this.match.slice(n));
|
|
},
|
|
|
|
// displays already matched input, i.e. for error messages
|
|
pastInput:function () {
|
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays upcoming input, i.e. for error messages
|
|
upcomingInput:function () {
|
|
var next = this.match;
|
|
if (next.length < 20) {
|
|
next += this._input.substr(0, 20-next.length);
|
|
}
|
|
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
showPosition:function () {
|
|
var pre = this.pastInput();
|
|
var c = new Array(pre.length + 1).join("-");
|
|
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
},
|
|
|
|
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
test_match:function (match, indexed_rule) {
|
|
var token,
|
|
lines,
|
|
backup;
|
|
|
|
if (this.options.backtrack_lexer) {
|
|
// save context
|
|
backup = {
|
|
yylineno: this.yylineno,
|
|
yylloc: {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.last_line,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: this.yylloc.last_column
|
|
},
|
|
yytext: this.yytext,
|
|
match: this.match,
|
|
matches: this.matches,
|
|
matched: this.matched,
|
|
yyleng: this.yyleng,
|
|
offset: this.offset,
|
|
_more: this._more,
|
|
_input: this._input,
|
|
yy: this.yy,
|
|
conditionStack: this.conditionStack.slice(0),
|
|
done: this.done
|
|
};
|
|
if (this.options.ranges) {
|
|
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
}
|
|
}
|
|
|
|
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno += lines.length;
|
|
}
|
|
this.yylloc = {
|
|
first_line: this.yylloc.last_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.last_column,
|
|
last_column: lines ?
|
|
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
|
this.yylloc.last_column + match[0].length
|
|
};
|
|
this.yytext += match[0];
|
|
this.match += match[0];
|
|
this.matches = match;
|
|
this.yyleng = this.yytext.length;
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
}
|
|
this._more = false;
|
|
this._backtrack = false;
|
|
this._input = this._input.slice(match[0].length);
|
|
this.matched += match[0];
|
|
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
if (this.done && this._input) {
|
|
this.done = false;
|
|
}
|
|
if (token) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
// recover context
|
|
for (var k in backup) {
|
|
this[k] = backup[k];
|
|
}
|
|
return false; // rule action called reject() implying the next rule should be tested instead.
|
|
}
|
|
return false;
|
|
},
|
|
|
|
// return next match in input
|
|
next:function () {
|
|
if (this.done) {
|
|
return this.EOF;
|
|
}
|
|
if (!this._input) {
|
|
this.done = true;
|
|
}
|
|
|
|
var token,
|
|
match,
|
|
tempMatch,
|
|
index;
|
|
if (!this._more) {
|
|
this.yytext = '';
|
|
this.match = '';
|
|
}
|
|
var rules = this._currentRules();
|
|
for (var i = 0; i < rules.length; i++) {
|
|
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
match = tempMatch;
|
|
index = i;
|
|
if (this.options.backtrack_lexer) {
|
|
token = this.test_match(tempMatch, rules[i]);
|
|
if (token !== false) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
match = false;
|
|
continue; // rule action called reject() implying a rule MISmatch.
|
|
} else {
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
} else if (!this.options.flex) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (match) {
|
|
token = this.test_match(match, rules[index]);
|
|
if (token !== false) {
|
|
return token;
|
|
}
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
if (this._input === "") {
|
|
return this.EOF;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
}
|
|
},
|
|
|
|
// return next match that has a token
|
|
lex:function lex() {
|
|
var r = this.next();
|
|
if (r) {
|
|
return r;
|
|
} else {
|
|
return this.lex();
|
|
}
|
|
},
|
|
|
|
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
begin:function begin(condition) {
|
|
this.conditionStack.push(condition);
|
|
},
|
|
|
|
// pop the previously active lexer condition state off the condition stack
|
|
popState:function popState() {
|
|
var n = this.conditionStack.length - 1;
|
|
if (n > 0) {
|
|
return this.conditionStack.pop();
|
|
} else {
|
|
return this.conditionStack[0];
|
|
}
|
|
},
|
|
|
|
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
_currentRules:function _currentRules() {
|
|
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
} else {
|
|
return this.conditions["INITIAL"].rules;
|
|
}
|
|
},
|
|
|
|
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
topState:function topState(n) {
|
|
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
if (n >= 0) {
|
|
return this.conditionStack[n];
|
|
} else {
|
|
return "INITIAL";
|
|
}
|
|
},
|
|
|
|
// alias for begin(condition)
|
|
pushState:function pushState(condition) {
|
|
this.begin(condition);
|
|
},
|
|
|
|
// return the number of states currently on the stack
|
|
stateStackSize:function stateStackSize() {
|
|
return this.conditionStack.length;
|
|
},
|
|
options: {},
|
|
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
|
var YYSTATE=YY_START;
|
|
switch($avoiding_name_collisions) {
|
|
case 0:/* do nothing */
|
|
break;
|
|
case 1:return 67;
|
|
break;
|
|
case 2:return 74;
|
|
break;
|
|
case 3:return 68;
|
|
break;
|
|
case 4:return 69;
|
|
break;
|
|
case 5:return 70;
|
|
break;
|
|
case 6:return 71;
|
|
break;
|
|
case 7:return 12;
|
|
break;
|
|
case 8:return 30;
|
|
break;
|
|
case 9:return 32;
|
|
break;
|
|
case 10:return 13;
|
|
break;
|
|
case 11:return 13;
|
|
break;
|
|
case 12:return 13;
|
|
break;
|
|
case 13:return 13;
|
|
break;
|
|
case 14:return 13;
|
|
break;
|
|
case 15:return 13;
|
|
break;
|
|
case 16:return 77;
|
|
break;
|
|
case 17:return 86;
|
|
break;
|
|
case 18:return 84;
|
|
break;
|
|
case 19:return 8;
|
|
break;
|
|
case 20:return 81;
|
|
break;
|
|
case 21:return 91;
|
|
break;
|
|
case 22:return 16;
|
|
break;
|
|
case 23:return 15;
|
|
break;
|
|
case 24:return 17;
|
|
break;
|
|
case 25:return 18;
|
|
break;
|
|
case 26:return 50;
|
|
break;
|
|
case 27:return 48;
|
|
break;
|
|
case 28:return 49;
|
|
break;
|
|
case 29:return 51;
|
|
break;
|
|
case 30:return 55;
|
|
break;
|
|
case 31:return 53;
|
|
break;
|
|
case 32:return 54;
|
|
break;
|
|
case 33:return 56;
|
|
break;
|
|
case 34:return 55;
|
|
break;
|
|
case 35:return 53;
|
|
break;
|
|
case 36:return 54;
|
|
break;
|
|
case 37:return 56;
|
|
break;
|
|
case 38:return 60;
|
|
break;
|
|
case 39:return 58;
|
|
break;
|
|
case 40:return 59;
|
|
break;
|
|
case 41:return 61;
|
|
break;
|
|
case 42:return 47;
|
|
break;
|
|
case 43:return 52;
|
|
break;
|
|
case 44:return 57;
|
|
break;
|
|
case 45:return 44;
|
|
break;
|
|
case 46:return 87;
|
|
break;
|
|
case 47:return 89;
|
|
break;
|
|
case 48:return 79;
|
|
break;
|
|
case 49:return 90;
|
|
break;
|
|
case 50:return 90;
|
|
break;
|
|
case 51:return 83;
|
|
break;
|
|
case 52:return 62;
|
|
break;
|
|
case 53:return 38;
|
|
break;
|
|
case 54:return 39;
|
|
break;
|
|
case 55:return 36;
|
|
break;
|
|
case 56:return 37;
|
|
break;
|
|
case 57:return 40
|
|
break;
|
|
case 58:return 41
|
|
break;
|
|
case 59:return 94;
|
|
break;
|
|
case 60:return 9;
|
|
break;
|
|
case 61:return 10;
|
|
break;
|
|
case 62:return 11;
|
|
break;
|
|
}
|
|
},
|
|
rules: [/^(?:%%[^\n]*)/,/^(?:style\b)/,/^(?:default\b)/,/^(?:linkStyle\b)/,/^(?:classDef\b)/,/^(?:class\b)/,/^(?:click\b)/,/^(?:graph\b)/,/^(?:subgraph\b)/,/^(?:end\s*)/,/^(?:LR\b)/,/^(?:RL\b)/,/^(?:TB\b)/,/^(?:BT\b)/,/^(?:TD\b)/,/^(?:BR\b)/,/^(?:[0-9]+)/,/^(?:#)/,/^(?::)/,/^(?:;)/,/^(?:,)/,/^(?:\*)/,/^(?:<)/,/^(?:>)/,/^(?:\^)/,/^(?:v\b)/,/^(?:\s*--[x]\s*)/,/^(?:\s*-->\s*)/,/^(?:\s*--[o]\s*)/,/^(?:\s*---\s*)/,/^(?:\s*-\.-[x]\s*)/,/^(?:\s*-\.->\s*)/,/^(?:\s*-\.-[o]\s*)/,/^(?:\s*-\.-\s*)/,/^(?:\s*.-[x]\s*)/,/^(?:\s*\.->\s*)/,/^(?:\s*\.-[o]\s*)/,/^(?:\s*\.-\s*)/,/^(?:\s*==[x]\s*)/,/^(?:\s*==>\s*)/,/^(?:\s*==[o]\s*)/,/^(?:\s*==[\=]\s*)/,/^(?:\s*--\s*)/,/^(?:\s*-\.\s*)/,/^(?:\s*==\s*)/,/^(?:-)/,/^(?:\.)/,/^(?:\+)/,/^(?:%)/,/^(?:=)/,/^(?:=)/,/^(?:[\u0021-\u0027\u002A-\u002E\u003F\u0041-\u005A\u005C\u005F-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6]|[\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377]|[\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5]|[\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA]|[\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE]|[\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA]|[\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0]|[\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977]|[\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2]|[\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A]|[\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39]|[\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8]|[\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C]|[\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C]|[\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99]|[\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0]|[\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D]|[\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3]|[\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10]|[\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1]|[\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81]|[\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3]|[\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6]|[\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A]|[\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081]|[\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D]|[\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0]|[\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310]|[\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C]|[\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711]|[\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7]|[\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C]|[\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16]|[\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF]|[\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC]|[\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D]|[\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D]|[\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3]|[\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F]|[\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128]|[\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184]|[\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3]|[\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6]|[\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE]|[\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C]|[\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D]|[\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC]|[\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B]|[\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788]|[\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805]|[\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB]|[\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28]|[\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5]|[\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4]|[\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E]|[\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D]|[\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36]|[\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D]|[\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC]|[\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF]|[\uFFD2-\uFFD7\uFFDA-\uFFDC_\/])/,/^(?:\|)/,/^(?:\()/,/^(?:\))/,/^(?:\[)/,/^(?:\])/,/^(?:\{)/,/^(?:\})/,/^(?:")/,/^(?:\n+)/,/^(?:\s)/,/^(?:$)/],
|
|
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62],"inclusive":true}}
|
|
});
|
|
return lexer;
|
|
})();
|
|
parser.lexer = lexer;
|
|
function Parser () {
|
|
this.yy = {};
|
|
}
|
|
Parser.prototype = parser;parser.Parser = Parser;
|
|
return new Parser;
|
|
})();
|
|
|
|
|
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
|
exports.parser = parser;
|
|
exports.Parser = parser.Parser;
|
|
exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
|
exports.main = function commonjsMain(args) {
|
|
if (!args[1]) {
|
|
console.log('Usage: '+args[0]+' FILE');
|
|
process.exit(1);
|
|
}
|
|
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
|
return exports.parser.parse(source);
|
|
};
|
|
if (typeof module !== 'undefined' && require.main === module) {
|
|
exports.main(process.argv.slice(1));
|
|
}
|
|
}
|
|
}).call(this,require("1YiZ5S"))
|
|
},{"1YiZ5S":81,"fs":79,"path":80}],94:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 15-01-14.
|
|
*/
|
|
var moment = require('moment');
|
|
|
|
var dateFormat = '';
|
|
var title = '';
|
|
var sections = [];
|
|
var tasks = [];
|
|
var currentSection = '';
|
|
|
|
exports.clear = function(){
|
|
sections = [];
|
|
tasks = [];
|
|
currentSection = '';
|
|
title = '';
|
|
taskCnt = 0;
|
|
lastTask = undefined;
|
|
};
|
|
|
|
exports.setDateFormat = function(txt){
|
|
dateFormat = txt;
|
|
};
|
|
|
|
exports.getDateFormat = function(){
|
|
return dateFormat;
|
|
};
|
|
exports.setTitle = function(txt){
|
|
title = txt;
|
|
};
|
|
|
|
exports.getTitle = function(){
|
|
return title;
|
|
};
|
|
|
|
exports.addSection = function(txt){
|
|
currentSection = txt;
|
|
sections.push(txt);
|
|
};
|
|
|
|
exports.findTaskById = function(id) {
|
|
var i;
|
|
for(i=0;i<tasks.length;i++){
|
|
if(tasks[i].id === id){
|
|
return tasks[i];
|
|
}
|
|
}
|
|
};
|
|
|
|
exports.getTasks=function(){
|
|
var i;
|
|
for(i=10000;i<tasks.length;i++){
|
|
tasks[i].startTime = moment(tasks[i].startTime).format(dateFormat);
|
|
tasks[i].endTime = moment(tasks[i].endTime).format(dateFormat);
|
|
}
|
|
|
|
return tasks;
|
|
};
|
|
|
|
|
|
var getStartDate = function(prevTime, dateFormat, str){
|
|
//console.log('Deciding start date:'+str);
|
|
//console.log('with dateformat:'+dateFormat);
|
|
|
|
str = str.trim();
|
|
|
|
// Test for after
|
|
var re = /^after\s+([\d\w\-]+)/;
|
|
var afterStatement = re.exec(str.trim());
|
|
if(afterStatement!==null){
|
|
var task = exports.findTaskById(afterStatement[1]);
|
|
if(typeof task === 'undefined'){
|
|
var dt = new Date();
|
|
dt.setHours(0,0,0,0);
|
|
return dt;
|
|
}
|
|
return task.endTime;
|
|
}
|
|
|
|
// Check for actual date set
|
|
if(moment(str,dateFormat.trim(),true).isValid()){
|
|
return moment(str,dateFormat.trim(),true).toDate();
|
|
}else{
|
|
console.log('Invalid date:'+str);
|
|
console.log('With date format:'+dateFormat.trim());
|
|
console.log('----');
|
|
}
|
|
|
|
// Default date - now
|
|
return new Date();
|
|
};
|
|
|
|
var getEndDate = function(prevTime, dateFormat, str){
|
|
str = str.trim();
|
|
|
|
// Check for actual date
|
|
if(moment(str,dateFormat.trim(),true).isValid()){
|
|
|
|
return moment(str,dateFormat.trim()).toDate();
|
|
}
|
|
|
|
var d = moment(prevTime);
|
|
// Check for length
|
|
var re = /^([\d]+)([wdh])/;
|
|
var durationStatement = re.exec(str.trim());
|
|
|
|
if(durationStatement!== null){
|
|
switch(durationStatement[2]){
|
|
case 'h':
|
|
d.add(durationStatement[1], 'hours');
|
|
break;
|
|
case 'd':
|
|
d.add(durationStatement[1], 'days');
|
|
break;
|
|
case 'w':
|
|
d.add(durationStatement[1], 'weeks');
|
|
break;
|
|
}
|
|
return d.toDate();
|
|
}
|
|
// Default date - now
|
|
return d.toDate();
|
|
};
|
|
|
|
var taskCnt = 0;
|
|
var parseId = function(idStr){
|
|
if(typeof idStr === 'undefined'){
|
|
taskCnt = taskCnt + 1;
|
|
return 'task'+taskCnt;
|
|
}
|
|
return idStr;
|
|
};
|
|
// id, startDate, endDate
|
|
// id, startDate, length
|
|
// id, after x, endDate
|
|
// id, after x, length
|
|
// startDate, endDate
|
|
// startDate, length
|
|
// after x, endDate
|
|
// after x, length
|
|
// endDate
|
|
// length
|
|
|
|
var compileData = function(prevTask, dataStr){
|
|
var ds;
|
|
|
|
if(dataStr.substr(0,1) === ':'){
|
|
ds = dataStr.substr(1,dataStr.length);
|
|
}
|
|
else{
|
|
ds=dataStr;
|
|
}
|
|
|
|
var data = ds.split(',');
|
|
|
|
|
|
var task = {};
|
|
var df = exports.getDateFormat();
|
|
|
|
|
|
// Get tags like active, done cand crit
|
|
var matchFound = true;
|
|
while(matchFound){
|
|
matchFound = false;
|
|
if(data[0].match(/^\s*active\s*$/)){
|
|
task.active = true;
|
|
data.shift(1);
|
|
matchFound = true;
|
|
|
|
}
|
|
if(data[0].match(/^\s*done\s*$/)){
|
|
task.done = true;
|
|
data.shift(1);
|
|
matchFound = true;
|
|
}
|
|
if(data[0].match(/^\s*crit\s*$/)){
|
|
task.crit = true;
|
|
data.shift(1);
|
|
matchFound = true;
|
|
}
|
|
}
|
|
var i;
|
|
for(i=0;i<data.length;i++){
|
|
data[i] = data[i].trim();
|
|
}
|
|
|
|
|
|
switch(data.length){
|
|
case 1:
|
|
task.id = parseId();
|
|
task.startTime = prevTask.endTime;
|
|
task.endTime = getEndDate(task.startTime, df, data[0]);
|
|
break;
|
|
case 2:
|
|
task.id = parseId();
|
|
task.startTime = getStartDate(undefined, df, data[0]);
|
|
task.endTime = getEndDate(task.startTime, df, data[1]);
|
|
break;
|
|
case 3:
|
|
task.id = parseId(data[0]);
|
|
task.startTime = getStartDate(undefined, df, data[1]);
|
|
task.endTime = getEndDate(task.startTime, df, data[2]);
|
|
break;
|
|
default:
|
|
|
|
}
|
|
|
|
return task;
|
|
};
|
|
|
|
|
|
var lastTask;
|
|
exports.addTask = function(descr,data){
|
|
|
|
var newTask = {
|
|
section:currentSection,
|
|
type:currentSection,
|
|
description:descr,
|
|
task:descr
|
|
};
|
|
var taskInfo = compileData(lastTask, data);
|
|
newTask.startTime = taskInfo.startTime;
|
|
newTask.endTime = taskInfo.endTime;
|
|
newTask.id = taskInfo.id;
|
|
newTask.active = taskInfo.active;
|
|
newTask.done = taskInfo.done;
|
|
newTask.crit = taskInfo.crit;
|
|
lastTask = newTask;
|
|
tasks.push(newTask);
|
|
};
|
|
|
|
exports.parseError = function(err,hash){
|
|
mermaid.parseError(err,hash);
|
|
};
|
|
},{"moment":83}],95:[function(require,module,exports){
|
|
var gantt = require('./parser/gantt').parser;
|
|
gantt.yy = require('./ganttDb');
|
|
var d3 = require('../../d3');
|
|
var moment = require('moment');
|
|
|
|
|
|
var daysInChart;
|
|
var conf = {
|
|
titleTopMargin: 25,
|
|
barHeight: 20,
|
|
barGap: 4,
|
|
topPadding: 50,
|
|
sidePadding: 75,
|
|
gridLineStartPadding: 35,
|
|
fontSize: 11,
|
|
fontFamily: '"Open-Sans", "sans-serif"'
|
|
};
|
|
module.exports.setConf = function (cnf) {
|
|
var keys = Object.keys(cnf);
|
|
|
|
keys.forEach(function (key) {
|
|
conf[key] = cnf[key];
|
|
});
|
|
};
|
|
var w;
|
|
module.exports.draw = function (text, id) {
|
|
gantt.yy.clear();
|
|
gantt.parse(text);
|
|
var elem = document.getElementById(id);
|
|
w = elem.offsetWidth;
|
|
|
|
if (typeof w === 'undefined') {
|
|
w = 1200;
|
|
}
|
|
|
|
var taskArray = gantt.yy.getTasks();
|
|
|
|
// Set height based on number of tasks
|
|
var h = taskArray.length * (conf.barHeight + conf.barGap) + 2 * conf.topPadding;
|
|
|
|
elem.setAttribute('height', "100%");
|
|
// Set viewBox
|
|
elem.setAttribute('viewBox','0 0 '+w+' '+h);
|
|
var svg = d3.select('#' + id);
|
|
|
|
|
|
|
|
|
|
var dateFormat = d3.time.format("%Y-%m-%d");
|
|
|
|
var startDate = d3.min(taskArray, function (d) {
|
|
return d.startTime;
|
|
});
|
|
var endDate = d3.max(taskArray, function (d) {
|
|
return d.endTime;
|
|
});
|
|
|
|
// Set timescale
|
|
var timeScale = d3.time.scale()
|
|
.domain([d3.min(taskArray, function (d) {
|
|
return d.startTime;
|
|
}),
|
|
d3.max(taskArray, function (d) {
|
|
return d.endTime;
|
|
})])
|
|
.rangeRound([0, w - 150]);
|
|
//.nice(d3.time.monday);
|
|
|
|
var categories = [];
|
|
|
|
daysInChart = moment.duration(endDate-startDate).asDays();
|
|
|
|
for (var i = 0; i < taskArray.length; i++) {
|
|
categories.push(taskArray[i].type);
|
|
}
|
|
|
|
var catsUnfiltered = categories; //for vert labels
|
|
|
|
categories = checkUnique(categories);
|
|
|
|
|
|
makeGant(taskArray, w, h);
|
|
|
|
var title = svg.append("text")
|
|
.text(gantt.yy.getTitle())
|
|
.attr("x", w / 2)
|
|
.attr("y", conf.titleTopMargin)
|
|
.attr('class', 'titleText');
|
|
|
|
|
|
function makeGant(tasks, pageWidth, pageHeight) {
|
|
|
|
var barHeight = conf.barHeight;
|
|
var gap = barHeight + conf.barGap;
|
|
var topPadding = conf.topPadding;
|
|
var sidePadding = conf.sidePadding;
|
|
|
|
var colorScale = d3.scale.linear()
|
|
.domain([0, categories.length])
|
|
.range(["#00B9FA", "#F95002"])
|
|
.interpolate(d3.interpolateHcl);
|
|
|
|
makeGrid(sidePadding, topPadding, pageWidth, pageHeight);
|
|
drawRects(tasks, gap, topPadding, sidePadding, barHeight, colorScale, pageWidth, pageHeight);
|
|
vertLabels(gap, topPadding, sidePadding, barHeight, colorScale);
|
|
drawToday(sidePadding, topPadding, pageWidth, pageHeight);
|
|
|
|
}
|
|
|
|
|
|
function drawRects(theArray, theGap, theTopPad, theSidePad, theBarHeight, theColorScale, w, h) {
|
|
|
|
var bigRects = svg.append("g")
|
|
.selectAll("rect")
|
|
.data(theArray)
|
|
.enter()
|
|
.append("rect")
|
|
.attr("x", 0)
|
|
.attr("y", function (d, i) {
|
|
return i * theGap + theTopPad - 2;
|
|
})
|
|
.attr("width", function (d) {
|
|
return w - theSidePad / 2;
|
|
})
|
|
.attr("height", theGap)
|
|
.attr('class', function (d) {
|
|
for (var i = 0; i < categories.length; i++) {
|
|
if (d.type === categories[i]) {
|
|
return 'section section' + (i % conf.numberSectionStyles);
|
|
}
|
|
}
|
|
return 'section section0';
|
|
});
|
|
|
|
|
|
var rectangles = svg.append('g')
|
|
.selectAll("rect")
|
|
.data(theArray)
|
|
.enter();
|
|
|
|
|
|
var innerRects = rectangles.append("rect")
|
|
.attr("rx", 3)
|
|
.attr("ry", 3)
|
|
.attr("x", function (d) {
|
|
return timeScale(d.startTime) + theSidePad;
|
|
})
|
|
.attr("y", function (d, i) {
|
|
return i * theGap + theTopPad;
|
|
})
|
|
.attr("width", function (d) {
|
|
return (timeScale(d.endTime) - timeScale(d.startTime));
|
|
})
|
|
.attr("height", theBarHeight)
|
|
.attr('class', function (d) {
|
|
var res = 'task ';
|
|
|
|
|
|
var secNum = 0;
|
|
for (var i = 0; i < categories.length; i++) {
|
|
if (d.type === categories[i]) {
|
|
secNum = (i % conf.numberSectionStyles);
|
|
}
|
|
}
|
|
|
|
if(d.active){
|
|
if (d.crit) {
|
|
return res + ' activeCrit'+secNum;
|
|
}else{
|
|
return res + ' active'+secNum;
|
|
}
|
|
}
|
|
|
|
if (d.done) {
|
|
if (d.crit) {
|
|
return res + ' doneCrit'+secNum;
|
|
}else{
|
|
return res + ' done'+secNum;
|
|
}
|
|
}
|
|
|
|
if (d.crit) {
|
|
return res + ' crit'+secNum;
|
|
}
|
|
|
|
|
|
return res + ' task'+secNum;
|
|
})
|
|
;
|
|
|
|
|
|
var rectText = rectangles.append("text")
|
|
.text(function (d) {
|
|
return d.task;
|
|
})
|
|
.attr("font-size",conf.fontSize)
|
|
//.attr("font-family",conf.fontFamily)
|
|
.attr("x", function (d) {
|
|
var startX = timeScale(d.startTime),
|
|
endX = timeScale(d.endTime),
|
|
textWidth = this.getBBox().width;
|
|
|
|
// Check id text width > width of rectangle
|
|
if (textWidth > (endX - startX)) {
|
|
if (endX + textWidth + 1.5*conf.sidePadding> w) {
|
|
return startX + theSidePad - 5;
|
|
} else {
|
|
return endX + theSidePad + 5;
|
|
}
|
|
} else {
|
|
return (endX - startX) / 2 + startX + theSidePad;
|
|
}
|
|
})
|
|
.attr("y", function (d, i) {
|
|
return i * theGap + (conf.barHeight / 2) + (conf.fontSize / 2 - 2) + theTopPad;
|
|
})
|
|
//.attr("text-anchor", "middle")
|
|
.attr("text-height", theBarHeight)
|
|
.attr("class", function (d) {
|
|
var startX = timeScale(d.startTime),
|
|
endX = timeScale(d.endTime),
|
|
textWidth = this.getBBox().width;
|
|
var secNum = 0;
|
|
for (var i = 0; i < categories.length; i++) {
|
|
if (d.type === categories[i]) {
|
|
secNum = (i % conf.numberSectionStyles);
|
|
}
|
|
}
|
|
|
|
var taskType = '';
|
|
if(d.active){
|
|
if (d.crit) {
|
|
taskType = 'activeCritText'+secNum;
|
|
}else{
|
|
taskType = 'activeText'+secNum;
|
|
}
|
|
}
|
|
|
|
if (d.done) {
|
|
if (d.crit) {
|
|
taskType = taskType + ' doneCritText'+secNum;
|
|
}else{
|
|
taskType = taskType + ' doneText'+secNum;
|
|
}
|
|
}else{
|
|
if (d.crit) {
|
|
taskType = taskType + ' critText'+secNum;
|
|
}
|
|
}
|
|
|
|
// Check id text width > width of rectangle
|
|
if (textWidth > (endX - startX)) {
|
|
if (endX + textWidth + 1.5*conf.sidePadding > w) {
|
|
return 'taskTextOutsideLeft taskTextOutside' + secNum + ' ' + taskType;
|
|
} else {
|
|
return 'taskTextOutsideRight taskTextOutside' + secNum+ ' ' + taskType;
|
|
}
|
|
} else {
|
|
return 'taskText taskText' + secNum+ ' ' + taskType;
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
|
|
function makeGrid(theSidePad, theTopPad, w, h) {
|
|
|
|
var pre = [
|
|
[".%L", function (d) {
|
|
return d.getMilliseconds();
|
|
}],
|
|
[":%S", function (d) {
|
|
return d.getSeconds();
|
|
}],
|
|
// Within a hour
|
|
["h1 %I:%M", function (d) {
|
|
return d.getMinutes();
|
|
}]];
|
|
var post = [
|
|
["%Y", function () {
|
|
return true;
|
|
}]];
|
|
|
|
var mid = [
|
|
// Within a day
|
|
["%I:%M", function (d) {
|
|
return d.getHours();
|
|
}],
|
|
// Day within a week (not monday)
|
|
["%a %d", function (d) {
|
|
//return d.getDay() ==1;
|
|
return d.getDay() && d.getDate() != 1;
|
|
}],
|
|
// within a month
|
|
["%b %d", function (d) {
|
|
return d.getDate() != 1;
|
|
}],
|
|
// Month
|
|
["%B", function (d) {
|
|
return d.getMonth();
|
|
}]
|
|
];
|
|
var formatter;
|
|
if(typeof conf.axisFormatter !== 'undefined'){
|
|
mid = [];
|
|
conf.axisFormatter.forEach(function(item){
|
|
var n = [];
|
|
n[0] = item[0];
|
|
n[1] = item[1];
|
|
mid.push(n);
|
|
});
|
|
}
|
|
formatter = pre.concat(mid).concat(post);
|
|
|
|
var xAxis = d3.svg.axis()
|
|
.scale(timeScale)
|
|
.orient('bottom')
|
|
.tickSize(-h + theTopPad + conf.gridLineStartPadding, 0, 0)
|
|
.tickFormat(d3.time.format.multi(formatter))
|
|
;
|
|
|
|
if(daysInChart >7 && daysInChart<230){
|
|
xAxis = xAxis.ticks(d3.time.monday.range);
|
|
}
|
|
|
|
var grid = svg.append('g')
|
|
.attr('class', 'grid')
|
|
.attr('transform', 'translate(' + theSidePad + ', ' + (h - 50) + ')')
|
|
.call(xAxis)
|
|
.selectAll("text")
|
|
.style("text-anchor", "middle")
|
|
.attr("fill", "#000")
|
|
.attr("stroke", "none")
|
|
.attr("font-size", 10)
|
|
.attr("dy", "1em");
|
|
}
|
|
|
|
function vertLabels(theGap, theTopPad, theSidePad, theBarHeight, theColorScale) {
|
|
var numOccurances = [];
|
|
var prevGap = 0;
|
|
|
|
for (var i = 0; i < categories.length; i++) {
|
|
numOccurances[i] = [categories[i], getCount(categories[i], catsUnfiltered)];
|
|
}
|
|
|
|
var axisText = svg.append("g") //without doing this, impossible to put grid lines behind text
|
|
.selectAll("text")
|
|
.data(numOccurances)
|
|
.enter()
|
|
.append("text")
|
|
.text(function (d) {
|
|
return d[0];
|
|
})
|
|
.attr("x", 10)
|
|
.attr("y", function (d, i) {
|
|
if (i > 0) {
|
|
for (var j = 0; j < i; j++) {
|
|
prevGap += numOccurances[i - 1][1];
|
|
// console.log(prevGap);
|
|
return d[1] * theGap / 2 + prevGap * theGap + theTopPad;
|
|
}
|
|
} else {
|
|
return d[1] * theGap / 2 + theTopPad;
|
|
}
|
|
})
|
|
.attr('class', function (d) {
|
|
for (var i = 0; i < categories.length; i++) {
|
|
if (d[0] === categories[i]) {
|
|
return 'sectionTitle sectionTitle' + (i % conf.numberSectionStyles);
|
|
}
|
|
}
|
|
return 'sectionTitle';
|
|
});
|
|
|
|
}
|
|
|
|
function drawToday(theSidePad, theTopPad, w, h) {
|
|
var todayG = svg.append('g')
|
|
.attr('class', 'today');
|
|
|
|
var today = new Date();
|
|
|
|
var todayLine = todayG.append("line")
|
|
.attr("x1", timeScale(today) + theSidePad)
|
|
.attr("x2", timeScale(today) + theSidePad)
|
|
.attr("y1", conf.titleTopMargin)
|
|
.attr("y2", h-conf.titleTopMargin)
|
|
.attr('class', 'today')
|
|
;
|
|
}
|
|
|
|
//from this stackexchange question: http://stackoverflow.com/questions/1890203/unique-for-arrays-in-javascript
|
|
function checkUnique(arr) {
|
|
var hash = {}, result = [];
|
|
for (var i = 0, l = arr.length; i < l; ++i) {
|
|
if (!hash.hasOwnProperty(arr[i])) { //it works with objects! in FF, at least
|
|
hash[arr[i]] = true;
|
|
result.push(arr[i]);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
//from this stackexchange question: http://stackoverflow.com/questions/14227981/count-how-many-strings-in-an-array-have-duplicates-in-the-same-array
|
|
function getCounts(arr) {
|
|
var i = arr.length, // var to loop over
|
|
obj = {}; // obj to store results
|
|
while (i) {
|
|
obj[arr[--i]] = (obj[arr[i]] || 0) + 1; // count occurrences
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
// get specific from everything
|
|
function getCount(word, arr) {
|
|
return getCounts(arr)[word] || 0;
|
|
}
|
|
};
|
|
},{"../../d3":85,"./ganttDb":94,"./parser/gantt":96,"moment":83}],96:[function(require,module,exports){
|
|
(function (process){
|
|
/* parser generated by jison 0.4.15 */
|
|
/*
|
|
Returns a Parser object of the following structure:
|
|
|
|
Parser: {
|
|
yy: {}
|
|
}
|
|
|
|
Parser.prototype: {
|
|
yy: {},
|
|
trace: function(),
|
|
symbols_: {associative list: name ==> number},
|
|
terminals_: {associative list: number ==> name},
|
|
productions_: [...],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
table: [...],
|
|
defaultActions: {...},
|
|
parseError: function(str, hash),
|
|
parse: function(input),
|
|
|
|
lexer: {
|
|
EOF: 1,
|
|
parseError: function(str, hash),
|
|
setInput: function(input),
|
|
input: function(),
|
|
unput: function(str),
|
|
more: function(),
|
|
less: function(n),
|
|
pastInput: function(),
|
|
upcomingInput: function(),
|
|
showPosition: function(),
|
|
test_match: function(regex_match_array, rule_index),
|
|
next: function(),
|
|
lex: function(),
|
|
begin: function(condition),
|
|
popState: function(),
|
|
_currentRules: function(),
|
|
topState: function(),
|
|
pushState: function(condition),
|
|
|
|
options: {
|
|
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
},
|
|
|
|
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
rules: [...],
|
|
conditions: {associative list: name ==> set},
|
|
}
|
|
}
|
|
|
|
|
|
token location info (@$, _$, etc.): {
|
|
first_line: n,
|
|
last_line: n,
|
|
first_column: n,
|
|
last_column: n,
|
|
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
}
|
|
|
|
|
|
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
text: (matched text)
|
|
token: (the produced terminal token, if any)
|
|
line: (yylineno)
|
|
}
|
|
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
loc: (yylloc)
|
|
expected: (string describing the set of expected tokens)
|
|
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
}
|
|
*/
|
|
var parser = (function(){
|
|
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[6,8,10,11,12,13,14],$V1=[1,9],$V2=[1,10],$V3=[1,11],$V4=[1,12];
|
|
var parser = {trace: function trace() { },
|
|
yy: {},
|
|
symbols_: {"error":2,"start":3,"gantt":4,"document":5,"EOF":6,"line":7,"SPACE":8,"statement":9,"NL":10,"dateFormat":11,"title":12,"section":13,"taskTxt":14,"taskData":15,"$accept":0,"$end":1},
|
|
terminals_: {2:"error",4:"gantt",6:"EOF",8:"SPACE",10:"NL",11:"dateFormat",12:"title",13:"section",14:"taskTxt",15:"taskData"},
|
|
productions_: [0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,1],[9,1],[9,2]],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
|
/* this == yyval */
|
|
|
|
var $0 = $$.length - 1;
|
|
switch (yystate) {
|
|
case 1:
|
|
return $$[$0-1];
|
|
break;
|
|
case 2:
|
|
this.$ = []
|
|
break;
|
|
case 3:
|
|
$$[$0-1].push($$[$0]);this.$ = $$[$0-1]
|
|
break;
|
|
case 4: case 5:
|
|
this.$ = $$[$0]
|
|
break;
|
|
case 6: case 7:
|
|
this.$=[];
|
|
break;
|
|
case 8:
|
|
yy.setDateFormat($$[$0].substr(11));this.$=$$[$0].substr(11);
|
|
break;
|
|
case 9:
|
|
yy.setTitle($$[$0].substr(6));this.$=$$[$0].substr(6);
|
|
break;
|
|
case 10:
|
|
yy.addSection($$[$0].substr(8));this.$=$$[$0].substr(8);
|
|
break;
|
|
case 11:
|
|
yy.addTask($$[$0-1],$$[$0]);this.$='task';
|
|
break;
|
|
}
|
|
},
|
|
table: [{3:1,4:[1,2]},{1:[3]},o($V0,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:$V1,12:$V2,13:$V3,14:$V4},o($V0,[2,7],{1:[2,1]}),o($V0,[2,3]),{9:13,11:$V1,12:$V2,13:$V3,14:$V4},o($V0,[2,5]),o($V0,[2,6]),o($V0,[2,8]),o($V0,[2,9]),o($V0,[2,10]),{15:[1,14]},o($V0,[2,4]),o($V0,[2,11])],
|
|
defaultActions: {},
|
|
parseError: function parseError(str, hash) {
|
|
if (hash.recoverable) {
|
|
this.trace(str);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
parse: function parse(input) {
|
|
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
|
var args = lstack.slice.call(arguments, 1);
|
|
var lexer = Object.create(this.lexer);
|
|
var sharedState = { yy: {} };
|
|
for (var k in this.yy) {
|
|
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
sharedState.yy[k] = this.yy[k];
|
|
}
|
|
}
|
|
lexer.setInput(input, sharedState.yy);
|
|
sharedState.yy.lexer = lexer;
|
|
sharedState.yy.parser = this;
|
|
if (typeof lexer.yylloc == 'undefined') {
|
|
lexer.yylloc = {};
|
|
}
|
|
var yyloc = lexer.yylloc;
|
|
lstack.push(yyloc);
|
|
var ranges = lexer.options && lexer.options.ranges;
|
|
if (typeof sharedState.yy.parseError === 'function') {
|
|
this.parseError = sharedState.yy.parseError;
|
|
} else {
|
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
}
|
|
function popStack(n) {
|
|
stack.length = stack.length - 2 * n;
|
|
vstack.length = vstack.length - n;
|
|
lstack.length = lstack.length - n;
|
|
}
|
|
_token_stack:
|
|
function lex() {
|
|
var token;
|
|
token = lexer.lex() || EOF;
|
|
if (typeof token !== 'number') {
|
|
token = self.symbols_[token] || token;
|
|
}
|
|
return token;
|
|
}
|
|
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
|
while (true) {
|
|
state = stack[stack.length - 1];
|
|
if (this.defaultActions[state]) {
|
|
action = this.defaultActions[state];
|
|
} else {
|
|
if (symbol === null || typeof symbol == 'undefined') {
|
|
symbol = lex();
|
|
}
|
|
action = table[state] && table[state][symbol];
|
|
}
|
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
|
var errStr = '';
|
|
expected = [];
|
|
for (p in table[state]) {
|
|
if (this.terminals_[p] && p > TERROR) {
|
|
expected.push('\'' + this.terminals_[p] + '\'');
|
|
}
|
|
}
|
|
if (lexer.showPosition) {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
|
} else {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
|
}
|
|
this.parseError(errStr, {
|
|
text: lexer.match,
|
|
token: this.terminals_[symbol] || symbol,
|
|
line: lexer.yylineno,
|
|
loc: yyloc,
|
|
expected: expected
|
|
});
|
|
}
|
|
if (action[0] instanceof Array && action.length > 1) {
|
|
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
|
}
|
|
switch (action[0]) {
|
|
case 1:
|
|
stack.push(symbol);
|
|
vstack.push(lexer.yytext);
|
|
lstack.push(lexer.yylloc);
|
|
stack.push(action[1]);
|
|
symbol = null;
|
|
if (!preErrorSymbol) {
|
|
yyleng = lexer.yyleng;
|
|
yytext = lexer.yytext;
|
|
yylineno = lexer.yylineno;
|
|
yyloc = lexer.yylloc;
|
|
if (recovering > 0) {
|
|
recovering--;
|
|
}
|
|
} else {
|
|
symbol = preErrorSymbol;
|
|
preErrorSymbol = null;
|
|
}
|
|
break;
|
|
case 2:
|
|
len = this.productions_[action[1]][1];
|
|
yyval.$ = vstack[vstack.length - len];
|
|
yyval._$ = {
|
|
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
last_line: lstack[lstack.length - 1].last_line,
|
|
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
last_column: lstack[lstack.length - 1].last_column
|
|
};
|
|
if (ranges) {
|
|
yyval._$.range = [
|
|
lstack[lstack.length - (len || 1)].range[0],
|
|
lstack[lstack.length - 1].range[1]
|
|
];
|
|
}
|
|
r = this.performAction.apply(yyval, [
|
|
yytext,
|
|
yyleng,
|
|
yylineno,
|
|
sharedState.yy,
|
|
action[1],
|
|
vstack,
|
|
lstack
|
|
].concat(args));
|
|
if (typeof r !== 'undefined') {
|
|
return r;
|
|
}
|
|
if (len) {
|
|
stack = stack.slice(0, -1 * len * 2);
|
|
vstack = vstack.slice(0, -1 * len);
|
|
lstack = lstack.slice(0, -1 * len);
|
|
}
|
|
stack.push(this.productions_[action[1]][0]);
|
|
vstack.push(yyval.$);
|
|
lstack.push(yyval._$);
|
|
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
stack.push(newState);
|
|
break;
|
|
case 3:
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}};
|
|
/* generated by jison-lex 0.3.4 */
|
|
var lexer = (function(){
|
|
var lexer = ({
|
|
|
|
EOF:1,
|
|
|
|
parseError:function parseError(str, hash) {
|
|
if (this.yy.parser) {
|
|
this.yy.parser.parseError(str, hash);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
|
|
// resets the lexer, sets new input
|
|
setInput:function (input, yy) {
|
|
this.yy = yy || this.yy || {};
|
|
this._input = input;
|
|
this._more = this._backtrack = this.done = false;
|
|
this.yylineno = this.yyleng = 0;
|
|
this.yytext = this.matched = this.match = '';
|
|
this.conditionStack = ['INITIAL'];
|
|
this.yylloc = {
|
|
first_line: 1,
|
|
first_column: 0,
|
|
last_line: 1,
|
|
last_column: 0
|
|
};
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [0,0];
|
|
}
|
|
this.offset = 0;
|
|
return this;
|
|
},
|
|
|
|
// consumes and returns one char from the input
|
|
input:function () {
|
|
var ch = this._input[0];
|
|
this.yytext += ch;
|
|
this.yyleng++;
|
|
this.offset++;
|
|
this.match += ch;
|
|
this.matched += ch;
|
|
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno++;
|
|
this.yylloc.last_line++;
|
|
} else {
|
|
this.yylloc.last_column++;
|
|
}
|
|
if (this.options.ranges) {
|
|
this.yylloc.range[1]++;
|
|
}
|
|
|
|
this._input = this._input.slice(1);
|
|
return ch;
|
|
},
|
|
|
|
// unshifts one char (or a string) into the input
|
|
unput:function (ch) {
|
|
var len = ch.length;
|
|
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
|
|
this._input = ch + this._input;
|
|
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
//this.yyleng -= len;
|
|
this.offset -= len;
|
|
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
this.match = this.match.substr(0, this.match.length - 1);
|
|
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
|
|
if (lines.length - 1) {
|
|
this.yylineno -= lines.length - 1;
|
|
}
|
|
var r = this.yylloc.range;
|
|
|
|
this.yylloc = {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: lines ?
|
|
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
|
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
|
this.yylloc.first_column - len
|
|
};
|
|
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
}
|
|
this.yyleng = this.yytext.length;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, caches matched text and appends it on next action
|
|
more:function () {
|
|
this._more = true;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
|
reject:function () {
|
|
if (this.options.backtrack_lexer) {
|
|
this._backtrack = true;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// retain first n characters of the match
|
|
less:function (n) {
|
|
this.unput(this.match.slice(n));
|
|
},
|
|
|
|
// displays already matched input, i.e. for error messages
|
|
pastInput:function () {
|
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays upcoming input, i.e. for error messages
|
|
upcomingInput:function () {
|
|
var next = this.match;
|
|
if (next.length < 20) {
|
|
next += this._input.substr(0, 20-next.length);
|
|
}
|
|
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
showPosition:function () {
|
|
var pre = this.pastInput();
|
|
var c = new Array(pre.length + 1).join("-");
|
|
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
},
|
|
|
|
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
test_match:function (match, indexed_rule) {
|
|
var token,
|
|
lines,
|
|
backup;
|
|
|
|
if (this.options.backtrack_lexer) {
|
|
// save context
|
|
backup = {
|
|
yylineno: this.yylineno,
|
|
yylloc: {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.last_line,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: this.yylloc.last_column
|
|
},
|
|
yytext: this.yytext,
|
|
match: this.match,
|
|
matches: this.matches,
|
|
matched: this.matched,
|
|
yyleng: this.yyleng,
|
|
offset: this.offset,
|
|
_more: this._more,
|
|
_input: this._input,
|
|
yy: this.yy,
|
|
conditionStack: this.conditionStack.slice(0),
|
|
done: this.done
|
|
};
|
|
if (this.options.ranges) {
|
|
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
}
|
|
}
|
|
|
|
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno += lines.length;
|
|
}
|
|
this.yylloc = {
|
|
first_line: this.yylloc.last_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.last_column,
|
|
last_column: lines ?
|
|
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
|
this.yylloc.last_column + match[0].length
|
|
};
|
|
this.yytext += match[0];
|
|
this.match += match[0];
|
|
this.matches = match;
|
|
this.yyleng = this.yytext.length;
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
}
|
|
this._more = false;
|
|
this._backtrack = false;
|
|
this._input = this._input.slice(match[0].length);
|
|
this.matched += match[0];
|
|
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
if (this.done && this._input) {
|
|
this.done = false;
|
|
}
|
|
if (token) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
// recover context
|
|
for (var k in backup) {
|
|
this[k] = backup[k];
|
|
}
|
|
return false; // rule action called reject() implying the next rule should be tested instead.
|
|
}
|
|
return false;
|
|
},
|
|
|
|
// return next match in input
|
|
next:function () {
|
|
if (this.done) {
|
|
return this.EOF;
|
|
}
|
|
if (!this._input) {
|
|
this.done = true;
|
|
}
|
|
|
|
var token,
|
|
match,
|
|
tempMatch,
|
|
index;
|
|
if (!this._more) {
|
|
this.yytext = '';
|
|
this.match = '';
|
|
}
|
|
var rules = this._currentRules();
|
|
for (var i = 0; i < rules.length; i++) {
|
|
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
match = tempMatch;
|
|
index = i;
|
|
if (this.options.backtrack_lexer) {
|
|
token = this.test_match(tempMatch, rules[i]);
|
|
if (token !== false) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
match = false;
|
|
continue; // rule action called reject() implying a rule MISmatch.
|
|
} else {
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
} else if (!this.options.flex) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (match) {
|
|
token = this.test_match(match, rules[index]);
|
|
if (token !== false) {
|
|
return token;
|
|
}
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
if (this._input === "") {
|
|
return this.EOF;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
}
|
|
},
|
|
|
|
// return next match that has a token
|
|
lex:function lex() {
|
|
var r = this.next();
|
|
if (r) {
|
|
return r;
|
|
} else {
|
|
return this.lex();
|
|
}
|
|
},
|
|
|
|
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
begin:function begin(condition) {
|
|
this.conditionStack.push(condition);
|
|
},
|
|
|
|
// pop the previously active lexer condition state off the condition stack
|
|
popState:function popState() {
|
|
var n = this.conditionStack.length - 1;
|
|
if (n > 0) {
|
|
return this.conditionStack.pop();
|
|
} else {
|
|
return this.conditionStack[0];
|
|
}
|
|
},
|
|
|
|
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
_currentRules:function _currentRules() {
|
|
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
} else {
|
|
return this.conditions["INITIAL"].rules;
|
|
}
|
|
},
|
|
|
|
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
topState:function topState(n) {
|
|
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
if (n >= 0) {
|
|
return this.conditionStack[n];
|
|
} else {
|
|
return "INITIAL";
|
|
}
|
|
},
|
|
|
|
// alias for begin(condition)
|
|
pushState:function pushState(condition) {
|
|
this.begin(condition);
|
|
},
|
|
|
|
// return the number of states currently on the stack
|
|
stateStackSize:function stateStackSize() {
|
|
return this.conditionStack.length;
|
|
},
|
|
options: {"case-insensitive":true},
|
|
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
|
// Pre-lexer code can go here
|
|
|
|
var YYSTATE=YY_START;
|
|
switch($avoiding_name_collisions) {
|
|
case 0:return 10;
|
|
break;
|
|
case 1:/* skip whitespace */
|
|
break;
|
|
case 2:/* skip comments */
|
|
break;
|
|
case 3:/* skip comments */
|
|
break;
|
|
case 4:return 4;
|
|
break;
|
|
case 5:return 11;
|
|
break;
|
|
case 6:return 'date';
|
|
break;
|
|
case 7:return 12;
|
|
break;
|
|
case 8:return 13;
|
|
break;
|
|
case 9:return 14;
|
|
break;
|
|
case 10:return 15;
|
|
break;
|
|
case 11:return ':';
|
|
break;
|
|
case 12:return 6;
|
|
break;
|
|
case 13:return 'INVALID';
|
|
break;
|
|
}
|
|
},
|
|
rules: [/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:gantt\b)/i,/^(?:dateFormat\s[^#\n;]+)/i,/^(?:\d\d\d\d-\d\d-\d\d\b)/i,/^(?:title\s[^#\n;]+)/i,/^(?:section\s[^#:\n;]+)/i,/^(?:[^#:\n;]+)/i,/^(?::[^#\n;]+)/i,/^(?::)/i,/^(?:$)/i,/^(?:.)/i],
|
|
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13],"inclusive":true}}
|
|
});
|
|
return lexer;
|
|
})();
|
|
parser.lexer = lexer;
|
|
function Parser () {
|
|
this.yy = {};
|
|
}
|
|
Parser.prototype = parser;parser.Parser = Parser;
|
|
return new Parser;
|
|
})();
|
|
|
|
|
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
|
exports.parser = parser;
|
|
exports.Parser = parser.Parser;
|
|
exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
|
exports.main = function commonjsMain(args) {
|
|
if (!args[1]) {
|
|
console.log('Usage: '+args[0]+' FILE');
|
|
process.exit(1);
|
|
}
|
|
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
|
return exports.parser.parse(source);
|
|
};
|
|
if (typeof module !== 'undefined' && require.main === module) {
|
|
exports.main(process.argv.slice(1));
|
|
}
|
|
}
|
|
}).call(this,require("1YiZ5S"))
|
|
},{"1YiZ5S":81,"fs":79,"path":80}],97:[function(require,module,exports){
|
|
(function (process){
|
|
/* parser generated by jison 0.4.15 */
|
|
/*
|
|
Returns a Parser object of the following structure:
|
|
|
|
Parser: {
|
|
yy: {}
|
|
}
|
|
|
|
Parser.prototype: {
|
|
yy: {},
|
|
trace: function(),
|
|
symbols_: {associative list: name ==> number},
|
|
terminals_: {associative list: number ==> name},
|
|
productions_: [...],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),
|
|
table: [...],
|
|
defaultActions: {...},
|
|
parseError: function(str, hash),
|
|
parse: function(input),
|
|
|
|
lexer: {
|
|
EOF: 1,
|
|
parseError: function(str, hash),
|
|
setInput: function(input),
|
|
input: function(),
|
|
unput: function(str),
|
|
more: function(),
|
|
less: function(n),
|
|
pastInput: function(),
|
|
upcomingInput: function(),
|
|
showPosition: function(),
|
|
test_match: function(regex_match_array, rule_index),
|
|
next: function(),
|
|
lex: function(),
|
|
begin: function(condition),
|
|
popState: function(),
|
|
_currentRules: function(),
|
|
topState: function(),
|
|
pushState: function(condition),
|
|
|
|
options: {
|
|
ranges: boolean (optional: true ==> token location info will include a .range[] member)
|
|
flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)
|
|
backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)
|
|
},
|
|
|
|
performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),
|
|
rules: [...],
|
|
conditions: {associative list: name ==> set},
|
|
}
|
|
}
|
|
|
|
|
|
token location info (@$, _$, etc.): {
|
|
first_line: n,
|
|
last_line: n,
|
|
first_column: n,
|
|
last_column: n,
|
|
range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)
|
|
}
|
|
|
|
|
|
the parseError function receives a 'hash' object with these members for lexer and parser errors: {
|
|
text: (matched text)
|
|
token: (the produced terminal token, if any)
|
|
line: (yylineno)
|
|
}
|
|
while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {
|
|
loc: (yylloc)
|
|
expected: (string describing the set of expected tokens)
|
|
recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)
|
|
}
|
|
*/
|
|
var parser = (function(){
|
|
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[6,8,10,11,15,17,19,20,22,33],$V1=[2,2],$V2=[1,6],$V3=[1,8],$V4=[1,9],$V5=[1,12],$V6=[1,13],$V7=[1,14],$V8=[1,15],$V9=[1,17],$Va=[1,18],$Vb=[2,7],$Vc=[6,8,10,11,15,17,18,19,20,21,22,33],$Vd=[6,8,10,11,15,17,18,19,20,22,33],$Ve=[1,46],$Vf=[1,49],$Vg=[1,53];
|
|
var parser = {trace: function trace() { },
|
|
yy: {},
|
|
symbols_: {"error":2,"start":3,"SD":4,"document":5,"EOF":6,"line":7,"SPACE":8,"statement":9,"NL":10,"participant":11,"actor":12,"signal":13,"note_statement":14,"title":15,"text":16,"loop":17,"end":18,"opt":19,"alt":20,"else":21,"note":22,"placement":23,"text2":24,"over":25,"spaceList":26,"actor_pair":27,",":28,"left_of":29,"right_of":30,"signaltype":31,"actors":32,"ACTOR":33,"SOLID_OPEN_ARROW":34,"DOTTED_OPEN_ARROW":35,"SOLID_ARROW":36,"DOTTED_ARROW":37,"SOLID_CROSS":38,"DOTTED_CROSS":39,"TXT":40,"$accept":0,"$end":1},
|
|
terminals_: {2:"error",4:"SD",6:"EOF",8:"SPACE",10:"NL",11:"participant",15:"title",16:"text",17:"loop",18:"end",19:"opt",20:"alt",21:"else",22:"note",25:"over",28:",",29:"left_of",30:"right_of",33:"ACTOR",34:"SOLID_OPEN_ARROW",35:"DOTTED_OPEN_ARROW",36:"SOLID_ARROW",37:"DOTTED_ARROW",38:"SOLID_CROSS",39:"DOTTED_CROSS",40:"TXT"},
|
|
productions_: [0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,3],[9,2],[9,2],[9,4],[9,4],[9,4],[9,7],[14,4],[14,5],[26,2],[26,1],[27,1],[27,3],[23,1],[23,1],[13,4],[32,2],[32,1],[12,1],[31,1],[31,1],[31,1],[31,1],[31,1],[31,1],[24,1]],
|
|
performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {
|
|
/* this == yyval */
|
|
|
|
var $0 = $$.length - 1;
|
|
switch (yystate) {
|
|
case 1:
|
|
yy.apply($$[$0-1]);return $$[$0-1];
|
|
break;
|
|
case 2:
|
|
this.$ = []
|
|
break;
|
|
case 3:
|
|
$$[$0-1].push($$[$0]);this.$ = $$[$0-1]
|
|
break;
|
|
case 4: case 5:
|
|
this.$ = $$[$0]
|
|
break;
|
|
case 6: case 7:
|
|
this.$=[];
|
|
break;
|
|
case 8:
|
|
this.$=$$[$0-1];
|
|
break;
|
|
case 12:
|
|
|
|
$$[$0-1].unshift({type: 'loopStart', loopText:$$[$0-2].actor, signalType: yy.LINETYPE.LOOP_START});
|
|
$$[$0-1].push({type: 'loopEnd', loopText:$$[$0-2], signalType: yy.LINETYPE.LOOP_END});
|
|
this.$=$$[$0-1];
|
|
break;
|
|
case 13:
|
|
|
|
$$[$0-1].unshift({type: 'optStart', optText:$$[$0-2].actor, signalType: yy.LINETYPE.OPT_START});
|
|
$$[$0-1].push({type: 'optEnd', optText:$$[$0-2].actor, signalType: yy.LINETYPE.OPT_END});
|
|
this.$=$$[$0-1];
|
|
break;
|
|
case 14:
|
|
|
|
// Alt start
|
|
$$[$0-4].unshift({type: 'altStart', altText:$$[$0-5].actor, signalType: yy.LINETYPE.ALT_START});
|
|
// Content in alt is already in $$[$0-4]
|
|
// Else
|
|
$$[$0-4].push({type: 'else', altText:$$[$0-2].actor, signalType: yy.LINETYPE.ALT_ELSE});
|
|
// Content in other alt
|
|
$$[$0-4] = $$[$0-4].concat($$[$0-1]);
|
|
// End
|
|
$$[$0-4].push({type: 'altEnd', signalType: yy.LINETYPE.ALT_END});
|
|
|
|
this.$=$$[$0-4];
|
|
break;
|
|
case 15:
|
|
this.$=[$$[$0-1],{type:'addNote', placement:$$[$0-2], actor:$$[$0-1].actor, text:$$[$0]}];
|
|
break;
|
|
case 19:
|
|
this.$ = $$[$0];
|
|
break;
|
|
case 20:
|
|
this.$ = [$$[$0-2], $$[$0]];
|
|
break;
|
|
case 21:
|
|
this.$ = yy.PLACEMENT.LEFTOF;
|
|
break;
|
|
case 22:
|
|
this.$ = yy.PLACEMENT.RIGHTOF;
|
|
break;
|
|
case 23:
|
|
this.$ = [$$[$0-3],$$[$0-1],{type: 'addMessage', from:$$[$0-3].actor, to:$$[$0-1].actor, signalType:$$[$0-2], msg:$$[$0]}]
|
|
break;
|
|
case 26:
|
|
this.$={type: 'addActor', actor:$$[$0]}
|
|
break;
|
|
case 27:
|
|
this.$ = yy.LINETYPE.SOLID_OPEN;
|
|
break;
|
|
case 28:
|
|
this.$ = yy.LINETYPE.DOTTED_OPEN;
|
|
break;
|
|
case 29:
|
|
this.$ = yy.LINETYPE.SOLID;
|
|
break;
|
|
case 30:
|
|
this.$ = yy.LINETYPE.DOTTED;
|
|
break;
|
|
case 31:
|
|
this.$ = yy.LINETYPE.SOLID_CROSS;
|
|
break;
|
|
case 32:
|
|
this.$ = yy.LINETYPE.DOTTED_CROSS;
|
|
break;
|
|
case 33:
|
|
this.$ = $$[$0].substring(1).trim().replace(/\\n/gm, "\n");
|
|
break;
|
|
}
|
|
},
|
|
table: [{3:1,4:[1,2]},{1:[3]},o($V0,$V1,{5:3}),{6:[1,4],7:5,8:$V2,9:7,10:$V3,11:$V4,12:16,13:10,14:11,15:$V5,17:$V6,19:$V7,20:$V8,22:$V9,33:$Va},o($V0,$Vb,{1:[2,1]}),o($Vc,[2,3]),{9:19,11:$V4,12:16,13:10,14:11,15:$V5,17:$V6,19:$V7,20:$V8,22:$V9,33:$Va},o($Vc,[2,5]),o($Vc,[2,6]),{12:20,33:$Va},{10:[1,21]},{10:[1,22]},{8:[1,23]},{12:24,33:$Va},{12:25,33:$Va},{12:26,33:$Va},{31:27,34:[1,28],35:[1,29],36:[1,30],37:[1,31],38:[1,32],39:[1,33]},{23:34,25:[1,35],29:[1,36],30:[1,37]},o([6,8,10,11,15,17,18,19,20,21,22,28,33,34,35,36,37,38,39,40],[2,26]),o($Vc,[2,4]),{10:[1,38]},o($Vc,[2,9]),o($Vc,[2,10]),{16:[1,39]},o($Vd,$V1,{5:40}),o($Vd,$V1,{5:41}),o([6,8,10,11,15,17,19,20,21,22,33],$V1,{5:42}),{12:43,33:$Va},{33:[2,27]},{33:[2,28]},{33:[2,29]},{33:[2,30]},{33:[2,31]},{33:[2,32]},{12:44,33:$Va},{8:$Ve,26:45},{33:[2,21]},{33:[2,22]},o($Vc,[2,8]),{10:[1,47]},{6:$Vf,7:5,8:$V2,9:7,10:$V3,11:$V4,12:16,13:10,14:11,15:$V5,17:$V6,18:[1,48],19:$V7,20:$V8,22:$V9,33:$Va},{6:$Vf,7:5,8:$V2,9:7,10:$V3,11:$V4,12:16,13:10,14:11,15:$V5,17:$V6,18:[1,50],19:$V7,20:$V8,22:$V9,33:$Va},{6:$Vf,7:5,8:$V2,9:7,10:$V3,11:$V4,12:16,13:10,14:11,15:$V5,17:$V6,19:$V7,20:$V8,21:[1,51],22:$V9,33:$Va},{24:52,40:$Vg},{24:54,40:$Vg},{12:56,27:55,33:$Va},{8:$Ve,26:57,33:[2,18]},o($Vc,[2,11]),o($Vc,[2,12]),o($Vc,$Vb),o($Vc,[2,13]),{12:58,33:$Va},{10:[2,23]},{10:[2,33]},{10:[2,15]},{12:59,33:$Va},{28:[1,60],33:[2,19]},{33:[2,17]},o($Vd,$V1,{5:61}),{10:[2,16]},{12:62,33:$Va},{6:$Vf,7:5,8:$V2,9:7,10:$V3,11:$V4,12:16,13:10,14:11,15:$V5,17:$V6,18:[1,63],19:$V7,20:$V8,22:$V9,33:$Va},{33:[2,20]},o($Vc,[2,14])],
|
|
defaultActions: {28:[2,27],29:[2,28],30:[2,29],31:[2,30],32:[2,31],33:[2,32],36:[2,21],37:[2,22],52:[2,23],53:[2,33],54:[2,15],57:[2,17],59:[2,16],62:[2,20]},
|
|
parseError: function parseError(str, hash) {
|
|
if (hash.recoverable) {
|
|
this.trace(str);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
parse: function parse(input) {
|
|
var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1;
|
|
var args = lstack.slice.call(arguments, 1);
|
|
var lexer = Object.create(this.lexer);
|
|
var sharedState = { yy: {} };
|
|
for (var k in this.yy) {
|
|
if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
|
sharedState.yy[k] = this.yy[k];
|
|
}
|
|
}
|
|
lexer.setInput(input, sharedState.yy);
|
|
sharedState.yy.lexer = lexer;
|
|
sharedState.yy.parser = this;
|
|
if (typeof lexer.yylloc == 'undefined') {
|
|
lexer.yylloc = {};
|
|
}
|
|
var yyloc = lexer.yylloc;
|
|
lstack.push(yyloc);
|
|
var ranges = lexer.options && lexer.options.ranges;
|
|
if (typeof sharedState.yy.parseError === 'function') {
|
|
this.parseError = sharedState.yy.parseError;
|
|
} else {
|
|
this.parseError = Object.getPrototypeOf(this).parseError;
|
|
}
|
|
function popStack(n) {
|
|
stack.length = stack.length - 2 * n;
|
|
vstack.length = vstack.length - n;
|
|
lstack.length = lstack.length - n;
|
|
}
|
|
_token_stack:
|
|
function lex() {
|
|
var token;
|
|
token = lexer.lex() || EOF;
|
|
if (typeof token !== 'number') {
|
|
token = self.symbols_[token] || token;
|
|
}
|
|
return token;
|
|
}
|
|
var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected;
|
|
while (true) {
|
|
state = stack[stack.length - 1];
|
|
if (this.defaultActions[state]) {
|
|
action = this.defaultActions[state];
|
|
} else {
|
|
if (symbol === null || typeof symbol == 'undefined') {
|
|
symbol = lex();
|
|
}
|
|
action = table[state] && table[state][symbol];
|
|
}
|
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
|
var errStr = '';
|
|
expected = [];
|
|
for (p in table[state]) {
|
|
if (this.terminals_[p] && p > TERROR) {
|
|
expected.push('\'' + this.terminals_[p] + '\'');
|
|
}
|
|
}
|
|
if (lexer.showPosition) {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ':\n' + lexer.showPosition() + '\nExpecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\'';
|
|
} else {
|
|
errStr = 'Parse error on line ' + (yylineno + 1) + ': Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\'');
|
|
}
|
|
this.parseError(errStr, {
|
|
text: lexer.match,
|
|
token: this.terminals_[symbol] || symbol,
|
|
line: lexer.yylineno,
|
|
loc: yyloc,
|
|
expected: expected
|
|
});
|
|
}
|
|
if (action[0] instanceof Array && action.length > 1) {
|
|
throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol);
|
|
}
|
|
switch (action[0]) {
|
|
case 1:
|
|
stack.push(symbol);
|
|
vstack.push(lexer.yytext);
|
|
lstack.push(lexer.yylloc);
|
|
stack.push(action[1]);
|
|
symbol = null;
|
|
if (!preErrorSymbol) {
|
|
yyleng = lexer.yyleng;
|
|
yytext = lexer.yytext;
|
|
yylineno = lexer.yylineno;
|
|
yyloc = lexer.yylloc;
|
|
if (recovering > 0) {
|
|
recovering--;
|
|
}
|
|
} else {
|
|
symbol = preErrorSymbol;
|
|
preErrorSymbol = null;
|
|
}
|
|
break;
|
|
case 2:
|
|
len = this.productions_[action[1]][1];
|
|
yyval.$ = vstack[vstack.length - len];
|
|
yyval._$ = {
|
|
first_line: lstack[lstack.length - (len || 1)].first_line,
|
|
last_line: lstack[lstack.length - 1].last_line,
|
|
first_column: lstack[lstack.length - (len || 1)].first_column,
|
|
last_column: lstack[lstack.length - 1].last_column
|
|
};
|
|
if (ranges) {
|
|
yyval._$.range = [
|
|
lstack[lstack.length - (len || 1)].range[0],
|
|
lstack[lstack.length - 1].range[1]
|
|
];
|
|
}
|
|
r = this.performAction.apply(yyval, [
|
|
yytext,
|
|
yyleng,
|
|
yylineno,
|
|
sharedState.yy,
|
|
action[1],
|
|
vstack,
|
|
lstack
|
|
].concat(args));
|
|
if (typeof r !== 'undefined') {
|
|
return r;
|
|
}
|
|
if (len) {
|
|
stack = stack.slice(0, -1 * len * 2);
|
|
vstack = vstack.slice(0, -1 * len);
|
|
lstack = lstack.slice(0, -1 * len);
|
|
}
|
|
stack.push(this.productions_[action[1]][0]);
|
|
vstack.push(yyval.$);
|
|
lstack.push(yyval._$);
|
|
newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
|
stack.push(newState);
|
|
break;
|
|
case 3:
|
|
return true;
|
|
}
|
|
}
|
|
return true;
|
|
}};
|
|
/* generated by jison-lex 0.3.4 */
|
|
var lexer = (function(){
|
|
var lexer = ({
|
|
|
|
EOF:1,
|
|
|
|
parseError:function parseError(str, hash) {
|
|
if (this.yy.parser) {
|
|
this.yy.parser.parseError(str, hash);
|
|
} else {
|
|
throw new Error(str);
|
|
}
|
|
},
|
|
|
|
// resets the lexer, sets new input
|
|
setInput:function (input, yy) {
|
|
this.yy = yy || this.yy || {};
|
|
this._input = input;
|
|
this._more = this._backtrack = this.done = false;
|
|
this.yylineno = this.yyleng = 0;
|
|
this.yytext = this.matched = this.match = '';
|
|
this.conditionStack = ['INITIAL'];
|
|
this.yylloc = {
|
|
first_line: 1,
|
|
first_column: 0,
|
|
last_line: 1,
|
|
last_column: 0
|
|
};
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [0,0];
|
|
}
|
|
this.offset = 0;
|
|
return this;
|
|
},
|
|
|
|
// consumes and returns one char from the input
|
|
input:function () {
|
|
var ch = this._input[0];
|
|
this.yytext += ch;
|
|
this.yyleng++;
|
|
this.offset++;
|
|
this.match += ch;
|
|
this.matched += ch;
|
|
var lines = ch.match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno++;
|
|
this.yylloc.last_line++;
|
|
} else {
|
|
this.yylloc.last_column++;
|
|
}
|
|
if (this.options.ranges) {
|
|
this.yylloc.range[1]++;
|
|
}
|
|
|
|
this._input = this._input.slice(1);
|
|
return ch;
|
|
},
|
|
|
|
// unshifts one char (or a string) into the input
|
|
unput:function (ch) {
|
|
var len = ch.length;
|
|
var lines = ch.split(/(?:\r\n?|\n)/g);
|
|
|
|
this._input = ch + this._input;
|
|
this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
|
//this.yyleng -= len;
|
|
this.offset -= len;
|
|
var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
|
this.match = this.match.substr(0, this.match.length - 1);
|
|
this.matched = this.matched.substr(0, this.matched.length - 1);
|
|
|
|
if (lines.length - 1) {
|
|
this.yylineno -= lines.length - 1;
|
|
}
|
|
var r = this.yylloc.range;
|
|
|
|
this.yylloc = {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: lines ?
|
|
(lines.length === oldLines.length ? this.yylloc.first_column : 0)
|
|
+ oldLines[oldLines.length - lines.length].length - lines[0].length :
|
|
this.yylloc.first_column - len
|
|
};
|
|
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
|
}
|
|
this.yyleng = this.yytext.length;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, caches matched text and appends it on next action
|
|
more:function () {
|
|
this._more = true;
|
|
return this;
|
|
},
|
|
|
|
// When called from action, signals the lexer that this rule fails to match the input, so the next matching rule (regex) should be tested instead.
|
|
reject:function () {
|
|
if (this.options.backtrack_lexer) {
|
|
this._backtrack = true;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
|
|
}
|
|
return this;
|
|
},
|
|
|
|
// retain first n characters of the match
|
|
less:function (n) {
|
|
this.unput(this.match.slice(n));
|
|
},
|
|
|
|
// displays already matched input, i.e. for error messages
|
|
pastInput:function () {
|
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays upcoming input, i.e. for error messages
|
|
upcomingInput:function () {
|
|
var next = this.match;
|
|
if (next.length < 20) {
|
|
next += this._input.substr(0, 20-next.length);
|
|
}
|
|
return (next.substr(0,20) + (next.length > 20 ? '...' : '')).replace(/\n/g, "");
|
|
},
|
|
|
|
// displays the character position where the lexing error occurred, i.e. for error messages
|
|
showPosition:function () {
|
|
var pre = this.pastInput();
|
|
var c = new Array(pre.length + 1).join("-");
|
|
return pre + this.upcomingInput() + "\n" + c + "^";
|
|
},
|
|
|
|
// test the lexed token: return FALSE when not a match, otherwise return token
|
|
test_match:function (match, indexed_rule) {
|
|
var token,
|
|
lines,
|
|
backup;
|
|
|
|
if (this.options.backtrack_lexer) {
|
|
// save context
|
|
backup = {
|
|
yylineno: this.yylineno,
|
|
yylloc: {
|
|
first_line: this.yylloc.first_line,
|
|
last_line: this.last_line,
|
|
first_column: this.yylloc.first_column,
|
|
last_column: this.yylloc.last_column
|
|
},
|
|
yytext: this.yytext,
|
|
match: this.match,
|
|
matches: this.matches,
|
|
matched: this.matched,
|
|
yyleng: this.yyleng,
|
|
offset: this.offset,
|
|
_more: this._more,
|
|
_input: this._input,
|
|
yy: this.yy,
|
|
conditionStack: this.conditionStack.slice(0),
|
|
done: this.done
|
|
};
|
|
if (this.options.ranges) {
|
|
backup.yylloc.range = this.yylloc.range.slice(0);
|
|
}
|
|
}
|
|
|
|
lines = match[0].match(/(?:\r\n?|\n).*/g);
|
|
if (lines) {
|
|
this.yylineno += lines.length;
|
|
}
|
|
this.yylloc = {
|
|
first_line: this.yylloc.last_line,
|
|
last_line: this.yylineno + 1,
|
|
first_column: this.yylloc.last_column,
|
|
last_column: lines ?
|
|
lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length :
|
|
this.yylloc.last_column + match[0].length
|
|
};
|
|
this.yytext += match[0];
|
|
this.match += match[0];
|
|
this.matches = match;
|
|
this.yyleng = this.yytext.length;
|
|
if (this.options.ranges) {
|
|
this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
|
}
|
|
this._more = false;
|
|
this._backtrack = false;
|
|
this._input = this._input.slice(match[0].length);
|
|
this.matched += match[0];
|
|
token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
|
if (this.done && this._input) {
|
|
this.done = false;
|
|
}
|
|
if (token) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
// recover context
|
|
for (var k in backup) {
|
|
this[k] = backup[k];
|
|
}
|
|
return false; // rule action called reject() implying the next rule should be tested instead.
|
|
}
|
|
return false;
|
|
},
|
|
|
|
// return next match in input
|
|
next:function () {
|
|
if (this.done) {
|
|
return this.EOF;
|
|
}
|
|
if (!this._input) {
|
|
this.done = true;
|
|
}
|
|
|
|
var token,
|
|
match,
|
|
tempMatch,
|
|
index;
|
|
if (!this._more) {
|
|
this.yytext = '';
|
|
this.match = '';
|
|
}
|
|
var rules = this._currentRules();
|
|
for (var i = 0; i < rules.length; i++) {
|
|
tempMatch = this._input.match(this.rules[rules[i]]);
|
|
if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
|
match = tempMatch;
|
|
index = i;
|
|
if (this.options.backtrack_lexer) {
|
|
token = this.test_match(tempMatch, rules[i]);
|
|
if (token !== false) {
|
|
return token;
|
|
} else if (this._backtrack) {
|
|
match = false;
|
|
continue; // rule action called reject() implying a rule MISmatch.
|
|
} else {
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
} else if (!this.options.flex) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (match) {
|
|
token = this.test_match(match, rules[index]);
|
|
if (token !== false) {
|
|
return token;
|
|
}
|
|
// else: this is a lexer rule which consumes input without producing a token (e.g. whitespace)
|
|
return false;
|
|
}
|
|
if (this._input === "") {
|
|
return this.EOF;
|
|
} else {
|
|
return this.parseError('Lexical error on line ' + (this.yylineno + 1) + '. Unrecognized text.\n' + this.showPosition(), {
|
|
text: "",
|
|
token: null,
|
|
line: this.yylineno
|
|
});
|
|
}
|
|
},
|
|
|
|
// return next match that has a token
|
|
lex:function lex() {
|
|
var r = this.next();
|
|
if (r) {
|
|
return r;
|
|
} else {
|
|
return this.lex();
|
|
}
|
|
},
|
|
|
|
// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
|
|
begin:function begin(condition) {
|
|
this.conditionStack.push(condition);
|
|
},
|
|
|
|
// pop the previously active lexer condition state off the condition stack
|
|
popState:function popState() {
|
|
var n = this.conditionStack.length - 1;
|
|
if (n > 0) {
|
|
return this.conditionStack.pop();
|
|
} else {
|
|
return this.conditionStack[0];
|
|
}
|
|
},
|
|
|
|
// produce the lexer rule set which is active for the currently active lexer condition state
|
|
_currentRules:function _currentRules() {
|
|
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
|
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
|
} else {
|
|
return this.conditions["INITIAL"].rules;
|
|
}
|
|
},
|
|
|
|
// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
|
|
topState:function topState(n) {
|
|
n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
|
if (n >= 0) {
|
|
return this.conditionStack[n];
|
|
} else {
|
|
return "INITIAL";
|
|
}
|
|
},
|
|
|
|
// alias for begin(condition)
|
|
pushState:function pushState(condition) {
|
|
this.begin(condition);
|
|
},
|
|
|
|
// return the number of states currently on the stack
|
|
stateStackSize:function stateStackSize() {
|
|
return this.conditionStack.length;
|
|
},
|
|
options: {"case-insensitive":true},
|
|
performAction: function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
|
// Pre-lexer code can go here
|
|
|
|
var YYSTATE=YY_START;
|
|
switch($avoiding_name_collisions) {
|
|
case 0:return 10;
|
|
break;
|
|
case 1: return 38;
|
|
break;
|
|
case 2: return 39;
|
|
break;
|
|
case 3: return 36;
|
|
break;
|
|
case 4: return 37;
|
|
break;
|
|
case 5:/* skip whitespace */
|
|
break;
|
|
case 6:/* skip comments */
|
|
break;
|
|
case 7:/* skip comments */
|
|
break;
|
|
case 8:return 11;
|
|
break;
|
|
case 9:return 19;
|
|
break;
|
|
case 10:return 17;
|
|
break;
|
|
case 11:return 20;
|
|
break;
|
|
case 12:return 21;
|
|
break;
|
|
case 13:return 18;
|
|
break;
|
|
case 14:return 29;
|
|
break;
|
|
case 15:return 30;
|
|
break;
|
|
case 16:return 25;
|
|
break;
|
|
case 17:return 22;
|
|
break;
|
|
case 18:return 15;
|
|
break;
|
|
case 19:return 4;
|
|
break;
|
|
case 20:return 28;
|
|
break;
|
|
case 21:return 10;
|
|
break;
|
|
case 22:return 33;
|
|
break;
|
|
case 23:return 34;
|
|
break;
|
|
case 24:return 35;
|
|
break;
|
|
case 25:return 36;
|
|
break;
|
|
case 26:return 37;
|
|
break;
|
|
case 27:return 40;
|
|
break;
|
|
case 28:return 6;
|
|
break;
|
|
case 29:return 'INVALID';
|
|
break;
|
|
}
|
|
},
|
|
rules: [/^(?:[\n]+)/i,/^(?:[\-][x])/i,/^(?:[\-][\-][x])/i,/^(?:[\-][>][>])/i,/^(?:[\-][\-][>][>])/i,/^(?:\s+)/i,/^(?:#[^\n]*)/i,/^(?:%[^\n]*)/i,/^(?:participant\b)/i,/^(?:opt\b)/i,/^(?:loop\b)/i,/^(?:alt\b)/i,/^(?:else\b)/i,/^(?:end\b)/i,/^(?:left of\b)/i,/^(?:right of\b)/i,/^(?:over\b)/i,/^(?:note\b)/i,/^(?:title\b)/i,/^(?:sequenceDiagram\b)/i,/^(?:,)/i,/^(?:;)/i,/^(?:[^\->:\n,;]+)/i,/^(?:->)/i,/^(?:-->)/i,/^(?:->>)/i,/^(?:-->>)/i,/^(?::[^#\n;]+)/i,/^(?:$)/i,/^(?:.)/i],
|
|
conditions: {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29],"inclusive":true}}
|
|
});
|
|
return lexer;
|
|
})();
|
|
parser.lexer = lexer;
|
|
function Parser () {
|
|
this.yy = {};
|
|
}
|
|
Parser.prototype = parser;parser.Parser = Parser;
|
|
return new Parser;
|
|
})();
|
|
|
|
|
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
|
exports.parser = parser;
|
|
exports.Parser = parser.Parser;
|
|
exports.parse = function () { return parser.parse.apply(parser, arguments); };
|
|
exports.main = function commonjsMain(args) {
|
|
if (!args[1]) {
|
|
console.log('Usage: '+args[0]+' FILE');
|
|
process.exit(1);
|
|
}
|
|
var source = require('fs').readFileSync(require('path').normalize(args[1]), "utf8");
|
|
return exports.parser.parse(source);
|
|
};
|
|
if (typeof module !== 'undefined' && require.main === module) {
|
|
exports.main(process.argv.slice(1));
|
|
}
|
|
}
|
|
}).call(this,require("1YiZ5S"))
|
|
},{"1YiZ5S":81,"fs":79,"path":80}],98:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 14-11-19.
|
|
*/
|
|
var actors = {};
|
|
var actorKeys = [];
|
|
var messages = [];
|
|
var notes = [];
|
|
|
|
exports.addActor = function(id,name,description){
|
|
//console.log('Adding actor: '+id);
|
|
actors[id] = {name:name, description:description};
|
|
actorKeys.push(id);
|
|
};
|
|
|
|
exports.addMessage = function(idFrom, idTo, message, answer){
|
|
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
|
messages.push({from:idFrom, to:idTo, message:message, answer:answer});
|
|
};
|
|
|
|
/**
|
|
*
|
|
*/
|
|
exports.addSignal = function(idFrom, idTo, message, messageType){
|
|
//console.log('Adding message from='+idFrom+' to='+idTo+' message='+message+' answer='+answer);
|
|
messages.push({from:idFrom, to:idTo, message:message, type:messageType});
|
|
};
|
|
|
|
exports.getMessages = function(){
|
|
return messages;
|
|
};
|
|
|
|
exports.getActors = function(){
|
|
return actors;
|
|
};
|
|
exports.getActor = function(id){
|
|
return actors[id];
|
|
};
|
|
exports.getActorKeys = function(){
|
|
return Object.keys(actors);
|
|
};
|
|
|
|
exports.clear = function(){
|
|
actors = {};
|
|
messages = [];
|
|
};
|
|
|
|
exports.LINETYPE = {
|
|
SOLID : 0 ,
|
|
DOTTED : 1 ,
|
|
NOTE : 2 ,
|
|
SOLID_CROSS : 3 ,
|
|
DOTTED_CROSS : 4 ,
|
|
SOLID_OPEN : 5 ,
|
|
DOTTED_OPEN : 6 ,
|
|
LOOP_START : 10 ,
|
|
LOOP_END : 11 ,
|
|
ALT_START : 12 ,
|
|
ALT_ELSE : 13 ,
|
|
ALT_END : 14 ,
|
|
OPT_START : 15 ,
|
|
OPT_END : 16
|
|
};
|
|
|
|
exports.ARROWTYPE = {
|
|
FILLED : 0,
|
|
OPEN : 1
|
|
};
|
|
|
|
exports.PLACEMENT = {
|
|
LEFTOF : 0,
|
|
RIGHTOF : 1,
|
|
OVER : 2
|
|
};
|
|
|
|
exports.addNote = function (actor, placement, message){
|
|
var note = {actor:actor, placement: placement, message:message};
|
|
|
|
notes.push(note);
|
|
messages.push({from:actor, to:actor, message:message, type:exports.LINETYPE.NOTE, placement: placement});
|
|
};
|
|
|
|
|
|
exports.parseError = function(err,hash){
|
|
mermaid.parseError(err,hash);
|
|
};
|
|
|
|
exports.apply = function(param){
|
|
if(param instanceof Array ){
|
|
param.forEach(function(item){
|
|
exports.apply(item);
|
|
});
|
|
} else {
|
|
// console.log(param);
|
|
switch(param.type){
|
|
case 'addActor':
|
|
exports.addActor(param.actor, param.actor, param.actor);
|
|
break;
|
|
case 'addNote':
|
|
exports.addNote(param.actor,param.placement, param.text);
|
|
break;
|
|
case 'addMessage':
|
|
exports.addSignal(param.from, param.to, param.msg, param.signalType);
|
|
break;
|
|
case 'loopStart':
|
|
//console.log('Loop text: ',param.loopText);
|
|
exports.addSignal(undefined, undefined, param.loopText, param.signalType);
|
|
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START);
|
|
break;
|
|
case 'loopEnd':
|
|
exports.addSignal(undefined, undefined, undefined, param.signalType);
|
|
break;
|
|
case 'optStart':
|
|
//console.log('Loop text: ',param.loopText);
|
|
exports.addSignal(undefined, undefined, param.optText, param.signalType);
|
|
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START);
|
|
break;
|
|
case 'optEnd':
|
|
exports.addSignal(undefined, undefined, undefined, param.signalType);
|
|
break;
|
|
case 'altStart':
|
|
//console.log('Loop text: ',param.loopText);
|
|
exports.addSignal(undefined, undefined, param.altText, param.signalType);
|
|
//yy.addSignal(undefined, undefined, $2, yy.LINETYPE.LOOP_START);
|
|
break;
|
|
case 'else':
|
|
exports.addSignal(undefined, undefined, param.altText, param.signalType);
|
|
break;
|
|
case 'altEnd':
|
|
exports.addSignal(undefined, undefined, undefined, param.signalType);
|
|
break;
|
|
}
|
|
|
|
// console.log('xxx',param);
|
|
}
|
|
};
|
|
},{}],99:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 14-11-23.
|
|
*/
|
|
|
|
var sq = require('./parser/sequenceDiagram').parser;
|
|
sq.yy = require('./sequenceDb');
|
|
var svgDraw = require('./svgDraw');
|
|
var d3 = require('../../d3');
|
|
var conf = {
|
|
|
|
diagramMarginX:50,
|
|
diagramMarginY:10,
|
|
// Margin between actors
|
|
actorMargin:50,
|
|
// Width of actor moxes
|
|
width:150,
|
|
// Height of actor boxes
|
|
height:65,
|
|
// Margin around loop boxes
|
|
boxMargin:10,
|
|
boxTextMargin:5,
|
|
|
|
noteMargin:10,
|
|
// Space between messages
|
|
messageMargin:35,
|
|
//mirror actors under diagram
|
|
mirrorActors:false,
|
|
// Depending on css styling this might need adjustment
|
|
// Prolongs the edge of the diagram downwards
|
|
bottomMarginAdj:1
|
|
};
|
|
|
|
//var bb = getBBox("path");
|
|
exports.bounds = {
|
|
data:{
|
|
startx:undefined,
|
|
stopx :undefined,
|
|
starty:undefined,
|
|
stopy :undefined,
|
|
},
|
|
verticalPos:0,
|
|
|
|
list: [],
|
|
init : function(){
|
|
this.list = [];
|
|
this.data = {
|
|
startx:undefined,
|
|
stopx :undefined,
|
|
starty:undefined,
|
|
stopy :undefined,
|
|
};
|
|
this.verticalPos =0;
|
|
},
|
|
updateVal : function (obj,key,val,fun){
|
|
if(typeof obj[key] === 'undefined'){
|
|
obj[key] = val;
|
|
}else{
|
|
obj[key] = fun(val,obj[key]);
|
|
}
|
|
},
|
|
updateLoops:function(startx,starty,stopx,stopy){
|
|
var _self = this;
|
|
var cnt = 0;
|
|
this.list.forEach(function(loop){
|
|
cnt++;
|
|
// The loop list is a stack so the biggest margins in the beginning of the list
|
|
var n = _self.list.length-cnt+1;
|
|
|
|
_self.updateVal(loop, 'startx',startx - n*conf.boxMargin, Math.min);
|
|
_self.updateVal(loop, 'starty',starty - n*conf.boxMargin, Math.min);
|
|
_self.updateVal(loop, 'stopx' ,stopx + n*conf.boxMargin, Math.max);
|
|
_self.updateVal(loop, 'stopy' ,stopy + n*conf.boxMargin, Math.max);
|
|
|
|
_self.updateVal(exports.bounds.data,'startx',startx - n*conf.boxMargin ,Math.min);
|
|
_self.updateVal(exports.bounds.data,'starty',starty - n*conf.boxMargin ,Math.min);
|
|
_self.updateVal(exports.bounds.data,'stopx' ,stopx + n*conf.boxMargin ,Math.max);
|
|
_self.updateVal(exports.bounds.data,'stopy' ,stopy + n*conf.boxMargin ,Math.max);
|
|
});
|
|
},
|
|
insert:function(startx,starty,stopx,stopy){
|
|
|
|
var _startx, _starty, _stopx, _stopy;
|
|
|
|
_startx = Math.min(startx,stopx);
|
|
_stopx = Math.max(startx,stopx);
|
|
_starty = Math.min(starty,stopy);
|
|
_stopy = Math.max(starty,stopy);
|
|
|
|
this.updateVal(exports.bounds.data,'startx',_startx,Math.min);
|
|
this.updateVal(exports.bounds.data,'starty',_starty,Math.min);
|
|
this.updateVal(exports.bounds.data,'stopx' ,_stopx ,Math.max);
|
|
this.updateVal(exports.bounds.data,'stopy' ,_stopy ,Math.max);
|
|
|
|
this.updateLoops(_startx,_starty,_stopx,_stopy);
|
|
|
|
},
|
|
newLoop:function(title){
|
|
this.list.push({startx:undefined,starty:this.verticalPos,stopx:undefined,stopy:undefined, title:title});
|
|
},
|
|
endLoop:function(){
|
|
var loop = this.list.pop();
|
|
//loop.stopy = exports.bounds.getVerticalPos();
|
|
return loop;
|
|
},
|
|
addElseToLoop:function(message){
|
|
var loop = this.list.pop();
|
|
loop.elsey = exports.bounds.getVerticalPos();
|
|
loop.elseText = message;
|
|
this.list.push(loop);
|
|
},
|
|
bumpVerticalPos:function(bump){
|
|
this.verticalPos = this.verticalPos + bump;
|
|
this.data.stopy = this.verticalPos;
|
|
},
|
|
getVerticalPos:function(){
|
|
return this.verticalPos;
|
|
},
|
|
getBounds:function(){
|
|
return this.data;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Draws an actor in the diagram with the attaced line
|
|
* @param center - The center of the the actor
|
|
* @param pos The position if the actor in the liost of actors
|
|
* @param description The text in the box
|
|
*/
|
|
var drawNote = function(elem, startx, verticalPos, msg){
|
|
var rect = svgDraw.getNoteRect();
|
|
rect.x = startx;
|
|
rect.y = verticalPos;
|
|
rect.width = conf.width;
|
|
rect.class = 'note';
|
|
|
|
var g = elem.append("g");
|
|
var rectElem = svgDraw.drawRect(g, rect);
|
|
|
|
var textObj = svgDraw.getTextObj();
|
|
textObj.x = startx;
|
|
textObj.y = verticalPos+conf.noteMargin;
|
|
textObj.textMargin = conf.noteMargin;
|
|
textObj.dy = '1em';
|
|
textObj.text = msg.message;
|
|
textObj.class = 'noteText';
|
|
|
|
var textElem = svgDraw.drawText(g,textObj);
|
|
|
|
var textHeight = textElem[0][0].getBBox().height;
|
|
exports.bounds.insert(startx, verticalPos, startx + conf.width, verticalPos + 2*conf.noteMargin + textHeight);
|
|
|
|
rectElem.attr('height',textHeight+ 2*conf.noteMargin);
|
|
exports.bounds.bumpVerticalPos(textHeight+ 2*conf.noteMargin);
|
|
};
|
|
|
|
|
|
/**
|
|
* Draws a message
|
|
* @param elem
|
|
* @param startx
|
|
* @param stopx
|
|
* @param verticalPos
|
|
* @param txtCenter
|
|
* @param msg
|
|
*/
|
|
var drawMessage = function(elem, startx, stopx, verticalPos, msg){
|
|
var g = elem.append("g");
|
|
var txtCenter = startx + (stopx-startx)/2;
|
|
|
|
var textElem = g.append("text") // text label for the x axis
|
|
.attr("x", txtCenter)
|
|
.attr("y", verticalPos - 7)
|
|
.style("text-anchor", "middle")
|
|
.attr("class", "messageText")
|
|
.text(msg.message);
|
|
|
|
var textWidth;
|
|
|
|
if(typeof textElem[0][0].getBBox !== 'undefined'){
|
|
textWidth = textElem[0][0].getBBox().width;
|
|
}
|
|
else{
|
|
console.log(textElem[0][0].getBoundingClientRect());
|
|
//textWidth = getBBox(textElem).width; //.getComputedTextLength()
|
|
textWidth = textElem[0][0].getBoundingClientRect();
|
|
//textWidth = textElem[0][0].getComputedTextLength();
|
|
}
|
|
|
|
var line;
|
|
|
|
if(startx===stopx){
|
|
line = g.append("path")
|
|
.attr('d', 'M ' +startx+ ','+verticalPos+' C ' +(startx+60)+ ','+(verticalPos-10)+' ' +(startx+60)+ ',' +
|
|
(verticalPos+30)+' ' +startx+ ','+(verticalPos+20));
|
|
|
|
exports.bounds.bumpVerticalPos(30);
|
|
var dx = Math.max(textWidth/2,100);
|
|
exports.bounds.insert(startx-dx, exports.bounds.getVerticalPos() -10, stopx+dx, exports.bounds.getVerticalPos());
|
|
}else{
|
|
line = g.append("line");
|
|
line.attr("x1", startx);
|
|
line.attr("y1", verticalPos);
|
|
line.attr("x2", stopx);
|
|
line.attr("y2", verticalPos);
|
|
exports.bounds.insert(startx, exports.bounds.getVerticalPos() -10, stopx, exports.bounds.getVerticalPos());
|
|
}
|
|
//Make an SVG Container
|
|
//Draw the line
|
|
if (msg.type === sq.yy.LINETYPE.DOTTED || msg.type === sq.yy.LINETYPE.DOTTED_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_OPEN) {
|
|
line.style("stroke-dasharray", ("3, 3"));
|
|
line.attr("class", "messageLine1");
|
|
}
|
|
else {
|
|
line.attr("class", "messageLine0");
|
|
}
|
|
|
|
line.attr("stroke-width", 2);
|
|
line.attr("stroke", "black");
|
|
line.style("fill", "none"); // remove any fill colour
|
|
if (msg.type === sq.yy.LINETYPE.SOLID || msg.type === sq.yy.LINETYPE.DOTTED){
|
|
line.attr("marker-end", "url(#arrowhead)");
|
|
}
|
|
|
|
if (msg.type === sq.yy.LINETYPE.SOLID_CROSS || msg.type === sq.yy.LINETYPE.DOTTED_CROSS){
|
|
line.attr("marker-end", "url(#crosshead)");
|
|
}
|
|
|
|
};
|
|
|
|
module.exports.drawActors = function(diagram, actors, actorKeys,verticalPos){
|
|
var i;
|
|
// Draw the actors
|
|
for(i=0;i<actorKeys.length;i++){
|
|
var key = actorKeys[i];
|
|
|
|
// Add some rendering data to the object
|
|
actors[key].x = i*conf.actorMargin +i*conf.width;
|
|
actors[key].y = verticalPos;
|
|
actors[key].width = conf.diagramMarginY;
|
|
actors[key].height = conf.diagramMarginY;
|
|
|
|
// Draw the box with the attached line
|
|
svgDraw.drawActor(diagram, actors[key].x, verticalPos, actors[key].description, conf);
|
|
exports.bounds.insert(actors[key].x, verticalPos, actors[key].x + conf.width, conf.height);
|
|
|
|
}
|
|
|
|
// Add a margin between the actor boxes and the first arrow
|
|
//exports.bounds.bumpVerticalPos(conf.height+conf.messageMargin);
|
|
exports.bounds.bumpVerticalPos(conf.height);
|
|
};
|
|
|
|
|
|
module.exports.setConf = function(cnf){
|
|
var keys = Object.keys(cnf);
|
|
|
|
keys.forEach(function(key){
|
|
conf[key] = cnf[key];
|
|
});
|
|
};
|
|
/**
|
|
* Draws a flowchart in the tag with id: id based on the graph definition in text.
|
|
* @param text
|
|
* @param id
|
|
*/
|
|
module.exports.draw = function (text, id) {
|
|
sq.yy.clear();
|
|
sq.parse(text+'\n');
|
|
|
|
exports.bounds.init();
|
|
var diagram = d3.select('#'+id);
|
|
|
|
var startx;
|
|
var stopx;
|
|
|
|
// Fetch data from the parsing
|
|
var actors = sq.yy.getActors();
|
|
var actorKeys = sq.yy.getActorKeys();
|
|
var messages = sq.yy.getMessages();
|
|
|
|
module.exports.drawActors(diagram, actors, actorKeys, 0);
|
|
|
|
// The arrow head definition is attached to the svg once
|
|
svgDraw.insertArrowHead(diagram);
|
|
svgDraw.insertArrowCrossHead(diagram);
|
|
|
|
// Draw the messages/signals
|
|
messages.forEach(function(msg){
|
|
var loopData;
|
|
|
|
switch(msg.type){
|
|
case sq.yy.LINETYPE.NOTE:
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
|
|
startx = actors[msg.from].x;
|
|
stopx = actors[msg.to].x;
|
|
|
|
if(msg.placement !== 0){
|
|
// Right of
|
|
drawNote(diagram, startx + (conf.width + conf.actorMargin)/2, exports.bounds.getVerticalPos(), msg);
|
|
|
|
}else{
|
|
// Left of
|
|
drawNote(diagram, startx - (conf.width + conf.actorMargin)/2, exports.bounds.getVerticalPos(), msg);
|
|
}
|
|
break;
|
|
case sq.yy.LINETYPE.LOOP_START:
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
exports.bounds.newLoop(msg.message);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin);
|
|
break;
|
|
case sq.yy.LINETYPE.LOOP_END:
|
|
loopData = exports.bounds.endLoop();
|
|
|
|
svgDraw.drawLoop(diagram, loopData,'loop', conf);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
break;
|
|
case sq.yy.LINETYPE.OPT_START:
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
exports.bounds.newLoop(msg.message);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin);
|
|
break;
|
|
case sq.yy.LINETYPE.OPT_END:
|
|
loopData = exports.bounds.endLoop();
|
|
|
|
svgDraw.drawLoop(diagram, loopData, 'opt', conf);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
break;
|
|
case sq.yy.LINETYPE.ALT_START:
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
exports.bounds.newLoop(msg.message);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin + conf.boxTextMargin);
|
|
break;
|
|
case sq.yy.LINETYPE.ALT_ELSE:
|
|
|
|
//exports.drawLoop(diagram, loopData);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
loopData = exports.bounds.addElseToLoop(msg.message);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
break;
|
|
case sq.yy.LINETYPE.ALT_END:
|
|
loopData = exports.bounds.endLoop();
|
|
|
|
svgDraw.drawLoop(diagram, loopData,'alt', conf);
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin);
|
|
break;
|
|
default:
|
|
exports.bounds.bumpVerticalPos(conf.messageMargin);
|
|
startx = actors[msg.from].x + conf.width/2;
|
|
stopx = actors[msg.to].x + conf.width/2;
|
|
|
|
drawMessage(diagram, startx, stopx, exports.bounds.getVerticalPos(), msg);
|
|
|
|
}
|
|
});
|
|
|
|
if(conf.mirrorActors){
|
|
// Draw actors below diagram
|
|
exports.bounds.bumpVerticalPos(conf.boxMargin*2);
|
|
module.exports.drawActors(diagram, actors, actorKeys, exports.bounds.getVerticalPos());
|
|
}
|
|
|
|
var box = exports.bounds.getBounds();
|
|
|
|
var height = box.stopy - box.starty + 2*conf.diagramMarginY;
|
|
|
|
if(conf.mirrorActors){
|
|
height = height - conf.boxMargin + conf.bottomMarginAdj;
|
|
}
|
|
|
|
var width = box.stopx-box.startx+2*conf.diagramMarginX;
|
|
|
|
diagram.attr("height",height);
|
|
diagram.attr("width", width );
|
|
diagram.attr("viewBox", (box.startx-conf.diagramMarginX) + ' -' +conf.diagramMarginY + ' ' + width + ' ' + height);
|
|
};
|
|
|
|
},{"../../d3":85,"./parser/sequenceDiagram":97,"./sequenceDb":98,"./svgDraw":100}],100:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 14-12-20.
|
|
*/
|
|
exports.drawRect = function(elem , rectData){
|
|
var rectElem = elem.append("rect");
|
|
rectElem.attr("x", rectData.x);
|
|
rectElem.attr("y", rectData.y);
|
|
rectElem.attr("fill", rectData.fill);
|
|
rectElem.attr("stroke", rectData.stroke);
|
|
rectElem.attr("width", rectData.width);
|
|
rectElem.attr("height", rectData.height);
|
|
rectElem.attr("rx", rectData.rx);
|
|
rectElem.attr("ry", rectData.ry);
|
|
|
|
if(typeof rectData.class !== 'undefined'){
|
|
rectElem.attr("class", rectData.class);
|
|
}
|
|
|
|
return rectElem;
|
|
};
|
|
|
|
exports.drawText = function(elem , textData){
|
|
var textElem = elem.append('text');
|
|
textElem.attr('x', textData.x);
|
|
textElem.attr('y', textData.y);
|
|
textElem.style('text-anchor', textData.anchor);
|
|
textElem.attr('fill', textData.fill);
|
|
|
|
textData.text.split(/<br\/?>/ig).forEach(function(rowText){
|
|
var span = textElem.append('tspan');
|
|
span.attr('x', textData.x +textData.textMargin);
|
|
span.attr('dy', textData.dy);
|
|
span.text(rowText);
|
|
});
|
|
|
|
if(typeof textData.class !== 'undefined'){
|
|
textElem.attr("class", textData.class);
|
|
}
|
|
|
|
return textElem;
|
|
};
|
|
|
|
exports.drawLabel = function(elem , txtObject){
|
|
var rectData = exports.getNoteRect();
|
|
rectData.x = txtObject.x;
|
|
rectData.y = txtObject.y;
|
|
rectData.width = 50;
|
|
rectData.height = 20;
|
|
rectData.fill = '#526e52';
|
|
rectData.stroke = 'none';
|
|
rectData.class = 'labelBox';
|
|
//rectData.color = 'white';
|
|
|
|
exports.drawRect(elem, rectData);
|
|
|
|
txtObject.y = txtObject.y + txtObject.labelMargin;
|
|
txtObject.x = txtObject.x + 0.5*txtObject.labelMargin;
|
|
txtObject.fill = 'white';
|
|
exports.drawText(elem, txtObject);
|
|
|
|
//return textElem;
|
|
};
|
|
|
|
/**
|
|
* Draws an actor in the diagram with the attaced line
|
|
* @param center - The center of the the actor
|
|
* @param pos The position if the actor in the liost of actors
|
|
* @param description The text in the box
|
|
*/
|
|
exports.drawActor = function(elem, left, verticalPos, description,conf){
|
|
var center = left + (conf.width/2);
|
|
var g = elem.append("g");
|
|
if(verticalPos === 0) {
|
|
g.append("line")
|
|
.attr("x1", center)
|
|
.attr("y1", 5)
|
|
.attr("x2", center)
|
|
.attr("y2", 2000)
|
|
.attr("class", 'actor-line')
|
|
.attr("stroke-width", '0.5px')
|
|
.attr("stroke", '#999');
|
|
}
|
|
|
|
var rect = exports.getNoteRect();
|
|
rect.x = left;
|
|
rect.y = verticalPos;
|
|
rect.fill = '#eaeaea';
|
|
rect.width = conf.width;
|
|
rect.height = conf.height;
|
|
rect.class = 'actor';
|
|
rect.rx = 3;
|
|
rect.ry = 3;
|
|
exports.drawRect(g, rect);
|
|
|
|
g.append("text") // text label for the x axis
|
|
.attr("x", center)
|
|
.attr("y", verticalPos + (conf.height/2)+5)
|
|
.attr('class','actor')
|
|
.style("text-anchor", "middle")
|
|
.text(description)
|
|
;
|
|
};
|
|
|
|
/**
|
|
* Draws an actor in the diagram with the attaced line
|
|
* @param center - The center of the the actor
|
|
* @param pos The position if the actor in the list of actors
|
|
* @param description The text in the box
|
|
*/
|
|
exports.drawLoop = function(elem,bounds,labelText, conf){
|
|
var g = elem.append("g");
|
|
var drawLoopLine = function(startx,starty,stopx,stopy){
|
|
g.append("line")
|
|
.attr("x1", startx)
|
|
.attr("y1", starty)
|
|
.attr("x2", stopx )
|
|
.attr("y2", stopy )
|
|
.attr("stroke-width", 2)
|
|
.attr("stroke", "#526e52")
|
|
.attr('class','loopLine');
|
|
};
|
|
drawLoopLine(bounds.startx, bounds.starty, bounds.stopx , bounds.starty);
|
|
drawLoopLine(bounds.stopx , bounds.starty, bounds.stopx , bounds.stopy );
|
|
drawLoopLine(bounds.startx, bounds.stopy , bounds.stopx , bounds.stopy );
|
|
drawLoopLine(bounds.startx, bounds.starty, bounds.startx, bounds.stopy );
|
|
if(typeof bounds.elsey !== 'undefined'){
|
|
drawLoopLine(bounds.startx, bounds.elsey, bounds.stopx, bounds.elsey );
|
|
}
|
|
|
|
var txt = exports.getTextObj();
|
|
txt.text = labelText;
|
|
txt.x = bounds.startx;
|
|
txt.y = bounds.starty;
|
|
txt.labelMargin = 1.5 * conf.boxMargin;
|
|
txt.class = 'labelText';
|
|
txt.fill = 'white';
|
|
|
|
exports.drawLabel(g,txt);
|
|
|
|
txt = exports.getTextObj();
|
|
txt.text = '[ ' + bounds.title + ' ]';
|
|
txt.x = bounds.startx + (bounds.stopx - bounds.startx)/2;
|
|
txt.y = bounds.starty + 1.5 * conf.boxMargin;
|
|
txt.anchor = 'middle';
|
|
txt.class = 'loopText';
|
|
|
|
exports.drawText(g,txt);
|
|
|
|
if(typeof bounds.elseText !== 'undefined') {
|
|
txt.text = '[ ' + bounds.elseText + ' ]';
|
|
txt.y = bounds.elsey + 1.5 * conf.boxMargin;
|
|
exports.drawText(g, txt);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Setup arrow head and define the marker. The result is appended to the svg.
|
|
*/
|
|
exports.insertArrowHead = function(elem){
|
|
elem.append("defs").append("marker")
|
|
.attr("id", "arrowhead")
|
|
.attr("refX", 5)
|
|
.attr("refY", 2)
|
|
.attr("markerWidth", 6)
|
|
.attr("markerHeight", 4)
|
|
.attr("orient", "auto")
|
|
.append("path")
|
|
.attr("d", "M 0,0 V 4 L6,2 Z"); //this is actual shape for arrowhead
|
|
};
|
|
/**
|
|
* Setup arrow head and define the marker. The result is appended to the svg.
|
|
*/
|
|
exports.insertArrowCrossHead = function(elem){
|
|
var defs = elem.append("defs");
|
|
var marker = defs.append("marker")
|
|
.attr("id", "crosshead")
|
|
.attr("markerWidth", 15)
|
|
.attr("markerHeight", 8)
|
|
.attr("orient", "auto")
|
|
.attr("refX", 16)
|
|
.attr("refY", 4);
|
|
|
|
// The arrow
|
|
marker.append("path")
|
|
.attr("fill",'black')
|
|
.attr("stroke",'#000000')
|
|
.style("stroke-dasharray", ("0, 0"))
|
|
.attr("stroke-width",'1px')
|
|
.attr("d", "M 9,2 V 6 L16,4 Z");
|
|
|
|
// The cross
|
|
marker.append("path")
|
|
.attr("fill",'none')
|
|
.attr("stroke",'#000000')
|
|
.style("stroke-dasharray", ("0, 0"))
|
|
.attr("stroke-width",'1px')
|
|
.attr("d", "M 0,1 L 6,7 M 6,1 L 0,7")
|
|
; //this is actual shape for arrowhead
|
|
|
|
};
|
|
|
|
exports.getTextObj = function(){
|
|
var txt = {
|
|
x: 0,
|
|
y: 0,
|
|
'fill':'black',
|
|
'text-anchor': 'start',
|
|
style: '#666',
|
|
width: 100,
|
|
height: 100,
|
|
textMargin:0,
|
|
rx: 0,
|
|
ry: 0
|
|
};
|
|
return txt;
|
|
};
|
|
|
|
exports.getNoteRect = function(){
|
|
var rect = {
|
|
x : 0,
|
|
y : 0,
|
|
fill : '#EDF2AE',
|
|
stroke : '#666',
|
|
width : 100,
|
|
anchor : 'start',
|
|
height : 100,
|
|
rx : 0,
|
|
ry : 0
|
|
};
|
|
return rect;
|
|
};
|
|
|
|
},{}],101:[function(require,module,exports){
|
|
(function (global){
|
|
var graph = require('./diagrams/flowchart/graphDb');
|
|
var flow = require('./diagrams/flowchart/parser/flow');
|
|
var utils = require('./utils');
|
|
var flowRenderer = require('./diagrams/flowchart/flowRenderer');
|
|
var seq = require('./diagrams/sequenceDiagram/sequenceRenderer');
|
|
var info = require('./diagrams/example/exampleRenderer');
|
|
var infoParser = require('./diagrams/example/parser/example');
|
|
var flowParser = require('./diagrams/flowchart/parser/flow');
|
|
var dotParser = require('./diagrams/flowchart/parser/dot');
|
|
var sequenceParser = require('./diagrams/sequenceDiagram/parser/sequenceDiagram');
|
|
var sequenceDb = require('./diagrams/sequenceDiagram/sequenceDb');
|
|
var infoDb = require('./diagrams/example/exampleDb');
|
|
var gantt = require('./diagrams/gantt/ganttRenderer');
|
|
var ganttParser = require('./diagrams/gantt/parser/gantt');
|
|
var ganttDb = require('./diagrams/gantt/ganttDb');
|
|
var d3 = require('./d3');
|
|
var nextId = 0;
|
|
|
|
// Default options, can be overridden at initialization time
|
|
var config = {
|
|
mermaid:{
|
|
cloneCssStyles: true
|
|
},
|
|
flowchart:{
|
|
// Default is to not set width
|
|
// width: 1200
|
|
},
|
|
sequenceDiagram:{
|
|
diagramMarginX:50,
|
|
diagramMarginY:10,
|
|
// Margin between actors
|
|
actorMargin:50,
|
|
// Width of actor moxes
|
|
width:150,
|
|
// Height of actor boxes
|
|
height:65,
|
|
// Margin around loop boxes
|
|
boxMargin:10,
|
|
boxTextMargin:5,
|
|
|
|
noteMargin:10,
|
|
// Space between messages
|
|
messageMargin:35,
|
|
//mirror actors under diagram
|
|
mirrorActors:true,
|
|
// Depending on css styling this might need adjustment
|
|
// Prolongs the edge of the diagram downwards
|
|
bottomMarginAdj:1
|
|
},
|
|
gantt:{
|
|
titleTopMargin: 25,
|
|
barHeight: 20,
|
|
barGap: 4,
|
|
topPadding: 50,
|
|
sidePadding: 75,
|
|
gridLineStartPadding: 35,
|
|
fontSize: 11,
|
|
fontFamily: '"Open-Sans", "sans-serif"',
|
|
numberSectionStyles:3,
|
|
axisFormatter: [
|
|
// Within a day
|
|
["%I:%M", function (d) {
|
|
return d.getHours();
|
|
}],
|
|
// Monday a week
|
|
["w. %U", function (d) {
|
|
return d.getDay() == 1;
|
|
}],
|
|
// Day within a week (not monday)
|
|
["%a %d", function (d) {
|
|
return d.getDay() && d.getDate() != 1;
|
|
}],
|
|
// within a month
|
|
["%b %d", function (d) {
|
|
return d.getDate() != 1;
|
|
}],
|
|
// Month
|
|
["%m-%y", function (d) {
|
|
return d.getMonth();
|
|
}]
|
|
] }
|
|
}
|
|
|
|
/**
|
|
* Function that parses a mermaid diagram defintion. If parsing fails the parseError callback is called and an error is
|
|
* thrown and
|
|
* @param text
|
|
*/
|
|
var parse = function(text){
|
|
var graphType = utils.detectType(text);
|
|
var parser;
|
|
|
|
switch(graphType){
|
|
case 'graph':
|
|
parser = flowParser;
|
|
parser.parser.yy = graph;
|
|
break;
|
|
case 'dotGraph':
|
|
parser = dotParser;
|
|
parser.parser.yy = graph;
|
|
break;
|
|
case 'sequenceDiagram':
|
|
parser = sequenceParser;
|
|
parser.parser.yy = sequenceDb;
|
|
break;
|
|
case 'info':
|
|
parser = infoParser;
|
|
parser.parser.yy = infoDb;
|
|
break;
|
|
case 'gantt':
|
|
parser = ganttParser;
|
|
parser.parser.yy = ganttDb;
|
|
break;
|
|
}
|
|
|
|
try{
|
|
parser.parse(text);
|
|
return true;
|
|
}
|
|
catch(err){
|
|
return false;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Function returning version information
|
|
* @returns {string} A string containing the version info
|
|
*/
|
|
exports.version = function(){
|
|
return require('../package.json').version;
|
|
};
|
|
|
|
var render = function(id, txt,cb){
|
|
|
|
d3.select('body').append('div')
|
|
.attr('id', 'd'+id)
|
|
.append('svg')
|
|
.attr('id', id)
|
|
.attr('width','100%')
|
|
.attr('xmlns','http://www.w3.org/2000/svg')
|
|
.append('g');
|
|
|
|
|
|
|
|
//console.log(d3.select('#d'+id).node().innerHTML);
|
|
var element = d3.select('#d'+id).node();
|
|
var graphType = utils.detectType(txt);
|
|
var classes = {};
|
|
switch(graphType){
|
|
case 'graph':
|
|
flowRenderer.setConf(config.flowchart);
|
|
flowRenderer.draw(txt, id, false);
|
|
if(config.mermaid.cloneCssStyles){
|
|
classes = flowRenderer.getClasses(txt, false);
|
|
utils.cloneCssStyles(element.firstChild, classes);
|
|
}
|
|
graph.bindFunctions();
|
|
break;
|
|
case 'dotGraph':
|
|
flowRenderer.setConf(config.flowchart);
|
|
flowRenderer.draw(txt, id, true);
|
|
if(config.mermaid.cloneCssStyles) {
|
|
classes = flowRenderer.getClasses(txt, true);
|
|
utils.cloneCssStyles(element.firstChild, classes);
|
|
}
|
|
break;
|
|
case 'sequenceDiagram':
|
|
//if(typeof mermaid.sequenceConfig === 'object'){
|
|
seq.setConf(config.sequenceDiagram);
|
|
//}
|
|
seq.draw(txt,id);
|
|
if(config.mermaid.cloneCssStyles) {
|
|
utils.cloneCssStyles(element.firstChild, []);
|
|
}
|
|
break;
|
|
case 'gantt':
|
|
gantt.setConf(config.gantt);
|
|
gantt.draw(txt,id);
|
|
if(config.mermaid.cloneCssStyles) {
|
|
utils.cloneCssStyles(element.firstChild, []);
|
|
}
|
|
break;
|
|
case 'info':
|
|
info.draw(txt,id,exports.version());
|
|
if(config.mermaid.cloneCssStyles) {
|
|
utils.cloneCssStyles(element.firstChild, []);
|
|
}
|
|
break;
|
|
}
|
|
//console.log(document.body.innerHTML);
|
|
cb(d3.select('#d'+id).node().innerHTML);
|
|
|
|
if(typeof d3.select('#d'+id).node().remove === 'function'){
|
|
d3.select('#d'+id).node().remove();
|
|
}
|
|
};
|
|
|
|
exports.render = function(id, text,cb){
|
|
if(typeof document === 'undefined'){
|
|
//jsdom = require('jsdom').jsdom;
|
|
//console.log(jsdom);
|
|
|
|
//htmlStub = '<html><head></head><body><div class="mermaid">'+text+'</div><script src="dist/mermaid.full.js"></script><script>var mermaid_config = {startOnLoad:true}</script></body></html>';
|
|
htmlStub = '<html><head></head><body></body></html>';
|
|
// // html file skull with a container div for the d3 dataviz
|
|
//
|
|
// pass the html stub to jsDom
|
|
/* jsdom.env({
|
|
features : { QuerySelectorAll : true },
|
|
html : htmlStub,
|
|
done : function(errors, win) {
|
|
// process the html document, like if we were at client side
|
|
// code to generate the dataviz and process the resulting html file to be added here
|
|
//var d3 = require('d3');
|
|
//console.log('Here we go: '+JSON.stringify(d3));
|
|
|
|
global.document = win.document;
|
|
global.window = win;
|
|
|
|
var element = win.document.createElement('div');
|
|
element.setAttribute('id','did');
|
|
//document.
|
|
console.log(document.body.innerHTML);
|
|
//console.log('Element:',element);
|
|
//console.log(win);
|
|
//mermaid.init();
|
|
//render(win.document, 'myId', text, callback);
|
|
|
|
}
|
|
});*/
|
|
//var jsdom = require('jsdom').jsdom;
|
|
//global.document = jsdom(htmlStub);
|
|
//global.window = document.parentWindow;
|
|
//
|
|
//render(id, text, cb);
|
|
//var element = win.document.createElement('div');
|
|
//element.setAttribute('id','did');
|
|
//document.
|
|
}
|
|
else{
|
|
// In browser
|
|
render( id, text, cb);
|
|
}
|
|
};
|
|
|
|
|
|
var setConf = function(cnf){
|
|
// Top level initially mermaid, gflow, sequenceDiagram and gantt
|
|
var lvl1Keys = Object.keys(cnf);
|
|
var i;
|
|
for(i=0;i<lvl1Keys.length;i++){
|
|
var lvl2Keys = Object.keys(cnf[lvl1Keys[i]]);
|
|
|
|
var j;
|
|
for(j=0;j<lvl2Keys.length;j++) {
|
|
console.log('Setting conf ',lvl1Keys[i],'-',lvl2Keys[j])
|
|
config[lvl1Keys[i]][lvl2Keys[j]] = cnf[lvl1Keys[i]][lvl2Keys[j]];
|
|
}
|
|
}
|
|
};
|
|
exports.initialize = function(options){
|
|
// Update default config with options supplied at initialization
|
|
console.log('In init:'+typeof options,JSON.stringify(options))
|
|
if(typeof options === 'object'){
|
|
setConf(options);
|
|
}
|
|
console.log('Done init:'+typeof options,JSON.stringify(config))
|
|
|
|
};
|
|
|
|
global.mermaidAPI = {
|
|
render : exports.render,
|
|
initialize : exports.initialize,
|
|
detectType: utils.detectType
|
|
};
|
|
|
|
//var getBBox = function(selector){
|
|
// var xmin, xmax, ymin, ymax,p;
|
|
// // clean up path
|
|
// var t = d3.select(selector).attr("d"); // get svg line's code
|
|
// console.log(t)
|
|
// t = t.replace(/[a-z].*/g," ") // remove relative coords, could rather tag it for later processing to absolute!
|
|
// .replace(/[\sA-Z]+/gi," ").trim().split(" "); // remove letters and simplify spaces.
|
|
// console.log(t)
|
|
//
|
|
// for(var i in t){ // set valid initial values
|
|
// if(t[i].length>1){
|
|
// p = t[i].split(",");
|
|
// xmin = xmax = p[0]; ymin = ymax = p[1]; }
|
|
// }
|
|
// for(var i in t){ // update xmin,xmax,ymin,ymax
|
|
// p = t[i].split(",");
|
|
// if(!p[1]){ p[0]=xmin; p[1] = ymin;} // ignore relative jumps such h20 v-10
|
|
// xmin = Math.min(xmin, p[0]);
|
|
// xmax = Math.max(xmax, p[0]);
|
|
// ymin = Math.min(ymin, p[1]);
|
|
// ymax = Math.max(ymax, p[1]);
|
|
// } return [[xmin,ymax],[xmax,ymin]]; // [[left, bottom], [right, top]] as for https://github.com/mbostock/d3/wiki/Geo-Paths#bounds
|
|
//}
|
|
//var bb = getBBox("path");
|
|
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
|
},{"../package.json":84,"./d3":85,"./diagrams/example/exampleDb":86,"./diagrams/example/exampleRenderer":87,"./diagrams/example/parser/example":88,"./diagrams/flowchart/flowRenderer":90,"./diagrams/flowchart/graphDb":91,"./diagrams/flowchart/parser/dot":92,"./diagrams/flowchart/parser/flow":93,"./diagrams/gantt/ganttDb":94,"./diagrams/gantt/ganttRenderer":95,"./diagrams/gantt/parser/gantt":96,"./diagrams/sequenceDiagram/parser/sequenceDiagram":97,"./diagrams/sequenceDiagram/sequenceDb":98,"./diagrams/sequenceDiagram/sequenceRenderer":99,"./utils":102}],102:[function(require,module,exports){
|
|
/**
|
|
* Created by knut on 14-11-23.
|
|
*/
|
|
/**
|
|
* Detects the type of the graph text.
|
|
* @param {string} text The text defining the graph
|
|
* @param {string} text The second text defining the graph
|
|
* @returns {string} A graph definition key
|
|
*/
|
|
module.exports.detectType = function(text,a){
|
|
if(text.match(/^\s*sequenceDiagram/)){
|
|
return "sequenceDiagram";
|
|
}
|
|
|
|
if(text.match(/^\s*sequence/)){
|
|
//console.log('Detected sequence syntax');
|
|
return "sequence";
|
|
}
|
|
|
|
if(text.match(/^\s*digraph/)) {
|
|
//console.log('Detected dot syntax');
|
|
return "dotGraph";
|
|
}
|
|
|
|
if(text.match(/^\s*info/)) {
|
|
//console.log('Detected info syntax');
|
|
return "info";
|
|
}
|
|
|
|
if(text.match(/^\s*gantt/)) {
|
|
//console.log('Detected info syntax');
|
|
return "gantt";
|
|
}
|
|
|
|
return "graph";
|
|
};
|
|
|
|
/**
|
|
* Copies all relevant CSS content into the graph SVG.
|
|
* This allows the SVG to be copied as is while keeping class based styling
|
|
* @param {element} svg The root element of the SVG
|
|
* @param {object} Hash table of class definitions from the graph definition
|
|
*/
|
|
module.exports.cloneCssStyles = function(svg, classes){
|
|
var usedStyles = "";
|
|
var sheets = document.styleSheets;
|
|
for (var i = 0; i < sheets.length; i++) {
|
|
// Avoid multiple inclusion on pages with multiple graphs
|
|
if (sheets[i].title !== 'mermaid-svg-internal-css') {
|
|
try {
|
|
|
|
var rules = sheets[i].cssRules;
|
|
if (rules !== null) {
|
|
for (var j = 0; j < rules.length; j++) {
|
|
var rule = rules[j];
|
|
if (typeof(rule.style) !== 'undefined') {
|
|
var elems;
|
|
elems = svg.querySelectorAll(rule.selectorText);
|
|
if (elems.length > 0) {
|
|
usedStyles += rule.selectorText + " { " + rule.style.cssText + " }\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch(err) {
|
|
if(typeof console !== 'undefined'){
|
|
if(console.warn !== 'undefined'){
|
|
if(rule !== 'undefined'){
|
|
console.warn('Invalid CSS selector "' + rule.selectorText + '"', err);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
var defaultStyles = "";
|
|
var embeddedStyles = "";
|
|
|
|
for (var className in classes) {
|
|
if (classes.hasOwnProperty(className) && typeof(className) != "undefined") {
|
|
if (className === 'default') {
|
|
if (classes.default.styles instanceof Array) {
|
|
defaultStyles += "#" + svg.id.trim() + ' .node' + ' { ' + classes[className].styles.join("; ") + '; }\n';
|
|
}
|
|
if (classes.default.nodeLabelStyles instanceof Array) {
|
|
defaultStyles += "#" + svg.id.trim() + ' .node text ' + ' { ' + classes[className].nodeLabelStyles.join("; ") + '; }\n';
|
|
}
|
|
if (classes.default.edgeLabelStyles instanceof Array) {
|
|
defaultStyles += "#" + svg.id.trim() + ' .edgeLabel text ' + ' { ' + classes[className].edgeLabelStyles.join("; ") + '; }\n';
|
|
}
|
|
} else {
|
|
if (classes[className].styles instanceof Array) {
|
|
embeddedStyles += "#" + svg.id.trim() + ' .' + className + ' { ' + classes[className].styles.join("; ") + '; }\n';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (usedStyles !== "" || defaultStyles !== "" || embeddedStyles !== "") {
|
|
var s = document.createElement('style');
|
|
s.setAttribute('type', 'text/css');
|
|
s.setAttribute('title', 'mermaid-svg-internal-css');
|
|
s.innerHTML = "/* <![CDATA[ */\n";
|
|
// Make this CSS local to this SVG
|
|
if (defaultStyles !== "") {
|
|
s.innerHTML += defaultStyles;
|
|
}
|
|
if (usedStyles !== "") {
|
|
s.innerHTML += usedStyles;
|
|
}
|
|
if (embeddedStyles !== "") {
|
|
s.innerHTML += embeddedStyles;
|
|
}
|
|
s.innerHTML += "/* ]]> */\n";
|
|
svg.insertBefore(s, svg.firstChild);
|
|
}
|
|
};
|
|
|
|
},{}]},{},[101])
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi9Vc2Vycy9rbnV0L0RvY3VtZW50cy9zb3VyY2UvbWVybWFpZC1kZXYtMC41LjAvbm9kZV9tb2R1bGVzL2d1bHAtYnJvd3NlcmlmeS9ub2RlX21vZHVsZXMvYnJvd3NlcmlmeS9ub2RlX21vZHVsZXMvYnJvd3Nlci1wYWNrL19wcmVsdWRlLmpzIiwiL1VzZXJzL2tudXQvRG9jdW1lbnRzL3NvdXJjZS9tZXJtYWlkLWRldi0wLjUuMC9ub2RlX21vZHVsZXMvZGFncmUtZDMvaW5kZXguanMiLCIvVXNlcnMva251dC9Eb2N1bWVudHMvc291cmNlL21lcm1haWQtZGV2LTAuNS4wL25vZGVfbW9kdWxlcy9kYWdyZS1kMy9saWIvYXJyb3dzLmpzIiwiL1VzZXJzL2tudXQvRG9jdW1lbnRzL3NvdXJjZS9tZXJtYWlkLWRldi0wLjUuMC9ub2RlX21vZHVsZXMvZGFncmUtZDMvbGliL2NyZWF0ZS1jbHVzdGVycy5qcyIsIi9Vc2Vycy9rbnV0L0RvY3VtZW50cy9zb3VyY2UvbWVybWFpZC1kZXYtMC41LjAvbm9kZV9tb2R1bGVzL2RhZ3JlLWQzL2xpYi9jcmVhdGUtZWRnZS1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ICAgICAgICBwYXRoRGF0YSA9IGZpbmRQYXRoKGcsIHBvc3RvcmRlck51bXMsIGVkZ2VPYmoudiwgZWRnZU9iai53KSxcbiAgICAgICAgcGF0aCA9IHBhdGhEYXRhLnBhdGgsXG4gICAgICAgIGxjYSA9IHBhdGhEYXRhLmxjYSxcbiAgICAgICAgcGF0aElkeCA9IDAsXG4gICAgICAgIHBhdGhWID0gcGF0aFtwYXRoSWR4XSxcbiAgICAgICAgYXNjZW5kaW5nID0gdHJ1ZTtcblxuICAgIHdoaWxlICh2ICE9PSBlZGdlT2JqLncpIHtcbiAgICAgIG5vZGUgPSBnLm5vZGUodik7XG5cbiAgICAgIGlmIChhc2NlbmRpbmcpIHtcbiAgICAgICAgd2hpbGUgKChwYXRoViA9IHBhdGhbcGF0aElkeF0pICE9PSBsY2EgJiZcbiAgICAgICAgICAgICAgIGcubm9kZShwYXRoVikubWF4UmFuayA8IG5vZGUucmFuaykge1xuICAgICAgICAgIHBhdGhJZHgrKztcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChwYXRoViA9PT0gbGNhKSB7XG4gICAgICAgICAgYXNjZW5kaW5nID0gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgaWYgKCFhc2NlbmRpbmcpIHtcbiAgICAgICAgd2hpbGUgKHBhdGhJZHggPCBwYXRoLmxlbmd0aCAtIDEgJiZcbiAgICAgICAgICAgICAgIGcubm9kZShwYXRoViA9IHBhdGhbcGF0aElkeCArIDFdKS5taW5SYW5rIDw9IG5vZGUucmFuaykge1xuICAgICAgICAgIHBhdGhJZHgrKztcbiAgICAgICAgfVxuICAgICAgICBwYXRoViA9IHBhdGhbcGF0aElkeF07XG4gICAgICB9XG5cbiAgICAgIGcuc2V0UGFyZW50KHYsIHBhdGhWKTtcbiAgICAgIHYgPSBnLnN1Y2Nlc3NvcnModilbMF07XG4gICAgfVxuICB9KTtcbn1cblxuLy8gRmluZCBhIHBhdGggZnJvbSB2IHRvIHcgdGhyb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XNoXCIpO1xuXG5tb2R1bGUuZXhwb3J0cyA9IHRhcmphbjtcblxuZnVuY3Rpb24gdGFyamFuKGcpIHtcbiAgdmFyIGluZGV4ID0gMCxcbiAgICAgIHN0YWNrID0gW10sXG4gICAgICB2aXNpdGVkID0ge30sIC8vIG5vZGUgaWQgLT4geyBvblN0YWNrLCBsb3dsaW5rLCBpbmRleCB9XG4gICAgICByZXN1bHRzID0gW107XG5cbiAgZnVuY3Rpb24gZGZzKHYpIHtcbiAgICB2YXIgZW50cnkgPSB2aXNpdGVkW3ZdID0ge1xuICAgICAgb25TdGFjazogdHJ1ZSxcbiAgICAgIGxvd2xpbms6IGluZGV4LFxuICAgICAgaW5kZXg6IGluZGV4KytcbiAgICB9O1xuICAgIHN0YWNrLnB1c2godik7XG5cbiAgICBnLnN1Y2Nlc3NvcnModikuZm9yRWFjaChmdW5jdGlvbih3KSB7XG4gICAgICBpZiAoIV8uaGFzKHZpc2l0ZWQsIHcpKSB7XG4gICAgICAgIGRmcyh3KTtcbiAgICAgICAgZW50cnkubG93bGluayA9IE1hdGgubWluKGVudHJ5Lmxvd2xpbmssIHZpc2l0ZWRbd10ubG93bGluayk7XG4gICAgICB9IGVsc2UgaWYgKHZpc2l0ZWRbd10ub25TdGFjaykge1xuICAgICAgICBlbnRyeS5sb3dsaW5rID0gTWF0aC5taW4oZW50cnkubG93bGluaywgdmlzaXRlZFt3XS5pbmRleCk7XG4gICAgICB9XG4gICAgfSk7XG5cbiAgICBpZiAoZW50cnkubG93bGluayA9PT0gZW50cnkuaW5kZXgpIHtcbiAgICAgIHZhciBjbXB0ID0gW10sXG4gICAgICAgICAgdztcbiAgICAgIGRvIHtcbiAgICAgICAgdyA9IHN0YWNrLnBvcCgpO1xuICAgICAgICB2aXNpdGVkW3ddLm9uU3RhY2sgPSBmYWxzZTtcbiAgICAgICAgY21wdC5wdXNoKHcpO1xuICAgICAgfSB3aGlsZSAodiAhPT0gdyk7XG4gICAgICByZXN1bHRzLnB1c2goY21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ICAgIHJldHVybiBmdW5jdGlvbiAoZikgeyByZXR1cm4gd2luZG93LnNldEltbWVkaWF0ZShmKSB9O1xuICAgIH1cblxuICAgIGlmIChjYW5Qb3N0KSB7XG4gICAgICAgIHZhciBxdWV1ZSA9IFtdO1xuICAgICAgICB3aW5kb3cuYWRkRXZlbnRMaXN0ZW5lcignbWVzc2FnZScsIGZ1bmN0aW9uIChldikge1xuICAgICAgICAgICAgdmFyIHNvdXJjZSA9IGV2LnNvdXJjZTtcbiAgICAgICAgICAgIGlmICgoc291cmNlID09PSB3aW5kb3cgfHwgc291cmNlID09PSBudWxsKSAmJiBldi5kYXRhID09PSAncHJvY2Vzcy10aWNrJykge1xuICAgICAgICAgICAgICAgIGV2LnN0b3BQcm9wYWdhdGlvbigpO1xuICAgICAgICAgICAgICAgIGlmIChxdWV1ZS5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBmbiA9IHF1ZXVlLnNoaWZ0KCk7XG4gICAgICAgICAgICAgICAgICAgIGZuKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9LCB0cnVlKTtcblxuICAgICAgICByZXR1cm4gZnVuY3Rpb24gbmV4dFRpY2soZm4pIHtcbiAgICAgICAgICAgIHF1ZXVlLnB1c2goZm4pO1xuICAgICAgICAgICAgd2luZG93LnBvc3RNZXNzYWdlKCdwcm9jZXNzLXRpY2snLCAnKicpO1xuICAgICAgICB9O1xuICAgIH1cblxuICAgIHJldHVybiBmdW5jdGlvbiBuZXh0VGljayhmbikge1xuICAgICAgICBzZXRUaW1lb3V0KGZuLCAwKTtcbiAgICB9O1xufSkoKTtcblxucHJvY2Vzcy50aXRsZSA9ICdicm93c2VyJztcbnByb2Nlc3MuYnJvd3NlciA9IHRydWU7XG5wcm9jZXNzLmVudiA9IHt9O1xucHJvY2Vzcy5hcmd2ID0gW107XG5cbmZ1bmN0aW9uIG5vb3AoKSB7fVxuXG5wcm9jZXNzLm9uID0g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5gIGFzIG5vdCBlcXVhbFxuICAgICAgICAgIHJldHVybiArYSA9PSArYjtcblxuICAgICAgICBjYXNlIG51bWJlckNsYXNzOlxuICAgICAgICAgIC8vIHRyZWF0IGBOYU5gIHZzLiBgTmFOYCBhcyBlcXVhbFxuICAgICAgICAgIHJldHVybiAoYSAhPSArYSlcbiAgICAgICAgICAgID8gYiAhPSArYlxuICAgICAgICAgICAgLy8gYnV0IHRyZWF0IGArMGAgdnMuIGAtMGAgYXMgbm90IGVxdWFsXG4gICAgICAgICAgICA6IChhID09IDAgPyAoMSAvIGEgPT0gMSAvIGIpIDogYSA9PSArYik7XG5cbiAgICAgICAgY2FzZSByZWdleHBDbGFzczpcbiAgICAgICAgY2FzZSBzdHJpbmdDbGFzczpcbiAgICAgICAgICAvLyBjb2VyY2UgcmVnZXhlcyB0byBzdHJpbmdzIChodHRwOi8vZXM1LmdpdGh1Yi5pby8jeDE1LjEwLjYuNClcbiAgICAgICAgICAvLyB0cmVhdCBzdHJpbmcgcHJpbWl0aXZlcyBhbmQgdGhlaXIgY29ycmVzcG9uZGluZyBvYmplY3QgaW5zdGFuY2VzIGFzIGVxdWFsXG4gICAgICAgICAgcmV0dXJuIGEgPT0gU3RyaW5nKGIpO1xuICAgICAgfVxuICAgICAgdmFyIGlzQXJyID0gY2xhc3NOYW1lID09IGFycmF5Q2xhc3M7XG4gICAgICBpZiAoIWlzQXJyKSB7XG4gICAgICAgIC8vIHVud3JhcCBhbnkgYGxvZGFzaGAgd3JhcHBlZCB2YWx1ZXNcbiAgICAgICAgdmFyIGFXcmFwcGVkID0gaGFzT3duUHJvcGVydHkuY2FsbChhLCAnX193cmFwcGVkX18nKSxcbiAgICAgICAgICAgIGJXcmFwcGVkID0gaGFzT3duUHJvcGVydHkuY2FsbChiLCAnX193cmFwcGVkX18nKTtcblxuICAgICAgICBpZiAoYVdyYXBwZWQgfHwgYldyYXBwZWQpIHtcbiAgICAgICAgICByZXR1cm4gYmFzZUlzRXF1YWwoYVdy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8fCBpc1doZXJlKSB7XG4gICAgICAgICAgLy8gZGVlcCBjb21wYXJlIHRoZSBjb250ZW50cywgaWdub3Jpbmcgbm9uLW51bWVyaWMgcHJvcGVydGllc1xuICAgICAgICAgIHdoaWxlIChzaXplLS0pIHtcbiAgICAgICAgICAgIHZhciBpbmRleCA9IGxlbmd0aCxcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IGJbc2l6ZV07XG5cbiAgICAgICAgICAgIGlmIChpc1doZXJlKSB7XG4gICAgICAgICAgICAgIHdoaWxlIChpbmRleC0tKSB7XG4gICAgICAgICAgICAgICAgaWYgKChyZXN1bHQgPSBiYXNlSXNFcXVhbChhW2luZGV4XSwgdmFsdWUsIGNhbGxiYWNrLCBpc1doZXJlLCBzdGFja0EsIHN0YWNrQikpKSB7XG4gICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSBpZiAoIShyZXN1bHQgPSBiYXNlSXNFcXVhbChhW3NpemVdLCB2YWx1ZSwgY2FsbGJhY2ssIGlzV2hlcmUsIHN0YWNrQSwgc3RhY2tCKSkpIHtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgICBlbHNlIHtcbiAgICAgICAgLy8gZGVlcCBjb21wYXJlIG9iamVjdHMgdXNpbmcgYGZvckluYCwgaW5zdGVhZCBvZiBgZm9yT3duYCwgdG8gYXZvaWQgYE9iamVjdC5rZXlzYFxuICAgICAgICAvLyB3aGljaCwgaW4gdGhpcyBjYXNlLCBpcyBtb3JlIGNvc3RseVxuICAgICAgICBmb3JJbihiLCBmdW5jdGlvbih2YWx1ZSwga2V5LCBiKSB7XG4gICAgICAgICAgaWYgKGhhc093blByb3BlcnR5LmNhbGwoYiwga2V5KSkge1xuICAgICAgICAgICAgLy8gY291bnQgdGhlIG51bWJlciBvZiBwc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c3RhY2tMZW5ndGggPSBzdGFja0EubGVuZ3RoO1xuICAgICAgICAgIHdoaWxlIChzdGFja0xlbmd0aC0tKSB7XG4gICAgICAgICAgICBpZiAoKGZvdW5kID0gc3RhY2tBW3N0YWNrTGVuZ3RoXSA9PSBzb3VyY2UpKSB7XG4gICAgICAgICAgICAgIHZhbHVlID0gc3RhY2tCW3N0YWNrTGVuZ3RoXTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICghZm91bmQpIHtcbiAgICAgICAgICAgIHZhciBpc1NoYWxsb3c7XG4gICAgICAgICAgICBpZiAoY2FsbGJhY2spIHtcbiAgICAgICAgICAgICAgcmVzdWx0ID0gY2FsbGJhY2sodmFsdWUsIHNvdXJjZSk7XG4gICAgICAgICAgICAgIGlmICgoaXNTaGFsbG93ID0gdHlwZW9mIHJlc3VsdCAhPSAndW5kZWZpbmVkJykpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSA9IHJlc3VsdDtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCFpc1NoYWxsb3cpIHtcbiAgICAgICAgICAgICAgdmFsdWUgPSBpc0FyclxuICAgICAgICAgICAgICAgID8gKGlzQXJyYXkodmFsdWUpID8gdmFsdWUgOiBbXSlcbiAgICAgICAgICAgICAgICA6IChpc1BsYWluT2JqZWN0KHZhbHVlKSA/IHZhbHVlIDoge30pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gYWRkIGBzb3VyY2VgIGFuZCBhc3NvY2lhdGVkIGB2YWx1ZWAgdG8gdGhlIHN0YWNrIG9mIHRyYXZlcnNlZCBvYmplY3RzXG4gICAgICAgICAgICBzdGFja0EucHVzaChzb3VyY2UpO1xuICAgICAgICAgICAgc3RhY2tCLnB1c2godmFsdWUpO1xuXG4gICAgICAgICAgICAvLyByZWN1cnNpdmVseSBtZXJnZSBvYmplY3RzIGFuZCBhcnJheXMgKHN1c2NlcHRpYmxlIHRvIGNhbGwgc3RhY2sgbGltaXRzKVxuICAgICAgICAgICAgaWYgKCFpc1NoYWxsb3cpIHtcbiAgICAgICAgICAgICAgYmFzZU1lcmdlKHZhbHVlLCBzb3VyY2UsIGNhbGxiYWNrLCBzdGFja0EsIHN0YWNrQik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgIGlmIChjYWxsYmFjaykge1xuICAgICAgICAgICAgcmVzdWx0ID0gY2FsbGJhY2sodmFsdWUsIHNvdXJjZSk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHJlc3VsdCA9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICByZXN1bHQgPSBzb3VyY2U7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmICh0eXBlb2YgcmVzdWx0ICE9ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICB2YWx1ZSA9IHJlc3VsdDtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgb2JqZWN0W2tleV0gPSB2YWx1ZTtcbiAgICAgIH0pO1xuICAgIH1cblxuICAgIC8qKlxuICAgICAqIFRoZSBiYXNlIGltcGxlbWVudGF0aW9uIG9mIGBfLnJhbmRvbWAgd2l0aG91dCBhcmd1bWVudCBqdWdnbGluZyBvciBzdXBwb3J0XG4gICAgICogZm9yIHJldHVybmluZyBmbG9hdGluZy1wb2ludCBudW1iZXJzLlxuICAgICAqXG4gICAgICogQHByaXZhdGVcbiAgICAgKiBAcGFyYW0ge251bWJlcn0gbWluIFRoZSBtaW5pbXVtIHBvc3NpYmxlIHZhbHVlLlxuICAgICAqIEBwYXJhbSB7bnVtYmVyfSBtYXggVGhlIG1heGltdW0gcG9zc2libGUgdmFsdWUuXG4gICAgICogQHJldHVybnMge251bWJlcn0gUmV0dXJucyBhIHJhbmRvbSBudW1iZXIuXG4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bGxiYWNrLCB0aGlzQXJnKSB7XG4gICAgICB2YXIgcmVzdWx0ID0ge307XG4gICAgICBpZiAodHlwZW9mIGNhbGxiYWNrICE9ICdmdW5jdGlvbicpIHtcbiAgICAgICAgdmFyIHByb3BzID0gW107XG4gICAgICAgIGZvckluKG9iamVjdCwgZnVuY3Rpb24odmFsdWUsIGtleSkge1xuICAgICAgICAgIHByb3BzLnB1c2goa2V5KTtcbiAgICAgICAgfSk7XG4gICAgICAgIHByb3BzID0gYmFzZURpZmZlcmVuY2UocHJvcHMsIGJhc2VGbGF0dGVuKGFyZ3VtZW50cywgdHJ1ZSwgZmFsc2UsIDEpKTtcblxuICAgICAgICB2YXIgaW5kZXggPSAtMSxcbiAgICAgICAgICAgIGxlbmd0aCA9IHByb3BzLmxlbmd0aDtcblxuICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgIHZhciBrZXkgPSBwcm9wc1tpbmRleF07XG4gICAgICAgICAgcmVzdWx0W2tleV0gPSBvYmplY3Rba2V5XTtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgY2FsbGJhY2sgPSBsb2Rhc2guY3JlYXRlQ2FsbGJhY2soY2FsbGJhY2ssIHRoaXNBcmcsIDMpO1xuICAgICAgICBmb3JJbihvYmplY3QsIGZ1bmN0aW9uKHZhbHVlLCBrZXksIG9iamVjdCkge1xuICAgICAgICAgIGlmICghY2FsbGJhY2sodmFsdWUsIGtleSwgb2JqZWN0KSkge1xuICAgICAgICAgICAgcmVzdWx0W2tleV0gPSB2YWx1ZTtcbiAgICAgICAgICB9XG4gICAgICAgIH0pO1xuICAgICAgfVxuICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBDcmVhdGVzIGEgdHdvIGRpbWVuc2lvbmFsIGFycmF5IG9mIGFuIG9iamVjdCdzIGtleS12YWx1ZSBwYWlycyxcbiAgICAgKiBpLmUuIGBbW2tleT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ZmZlcmVuY2UuXG4gICAgICpcbiAgICAgKiBAc3RhdGljXG4gICAgICogQG1lbWJlck9mIF9cbiAgICAgKiBAY2F0ZWdvcnkgQXJyYXlzXG4gICAgICogQHBhcmFtIHsuLi5BcnJheX0gW2FycmF5XSBUaGUgYXJyYXlzIHRvIGluc3BlY3QuXG4gICAgICogQHJldHVybnMge0FycmF5fSBSZXR1cm5zIGFuIGFycmF5IG9mIHZhbHVlcy5cbiAgICAgKiBAZXhhbXBsZVxuICAgICAqXG4gICAgICogXy54b3IoWzEsIDIsIDNdLCBbNSwgMiwgMSwgNF0pO1xuICAgICAqIC8vID0+IFszLCA1LCA0XVxuICAgICAqXG4gICAgICogXy54b3IoWzEsIDIsIDVdLCBbMiwgMywgNV0sIFszLCA0LCA1XSk7XG4gICAgICogLy8gPT4gWzEsIDQsIDVdXG4gICAgICovXG4gICAgZnVuY3Rpb24geG9yKCkge1xuICAgICAgdmFyIGluZGV4ID0gLTEsXG4gICAgICAgICAgbGVuZ3RoID0gYXJndW1lbnRzLmxlbmd0aDtcblxuICAgICAgd2hpbGUgKCsraW5kZXggPCBsZW5ndGgpIHtcbiAgICAgICAgdmFyIGFycmF5ID0gYXJndW1lbnRzW2luZGV4XTtcbiAgICAgICAgaWYgKGlzQXJyYXkoYXJyYXkpIHx8IGlzQXJndW1lbnRzKGFycmF5KSkge1xuICAgICAgICAgIHZhciByZXN1bHQgPSByZXN1bHRcbiAgICAgICAgICAgID8gYmFzZVVuaXEoYmFzZURpZmZlcmVuY2UocmVzdWx0LCBhcnJheSkuY29uY2F0KGJhc2VEaWZmZXJlbmNlKGFycmF5LCByZXN1bHQpKSlcbiAgICAgICAgICAgIDogYXJyYXk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICAgIHJldHVybiByZXN1bHQgfHwgW107XG4gICAgfVxuXG4gICAgLyoqXG4gICAgICogQ3JlYXRlcyBhbiBhcnJheSBvZiBncm91cGVkIGVsZW1lbnRzLCB0aGUgZmlyc3Qgb2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bXAsXG4gICAgICAgICAgdGhpc0FyZyxcbiAgICAgICAgICB0aW1lb3V0SWQsXG4gICAgICAgICAgdHJhaWxpbmdDYWxsLFxuICAgICAgICAgIGxhc3RDYWxsZWQgPSAwLFxuICAgICAgICAgIG1heFdhaXQgPSBmYWxzZSxcbiAgICAgICAgICB0cmFpbGluZyA9IHRydWU7XG5cbiAgICAgIGlmICghaXNGdW5jdGlvbihmdW5jKSkge1xuICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yO1xuICAgICAgfVxuICAgICAgd2FpdCA9IG5hdGl2ZU1heCgwLCB3YWl0KSB8fCAwO1xuICAgICAgaWYgKG9wdGlvbnMgPT09IHRydWUpIHtcbiAgICAgICAgdmFyIGxlYWRpbmcgPSB0cnVlO1xuICAgICAgICB0cmFpbGluZyA9IGZhbHNlO1xuICAgICAgfSBlbHNlIGlmIChpc09iamVjdChvcHRpb25zKSkge1xuICAgICAgICBsZWFkaW5nID0gb3B0aW9ucy5sZWFkaW5nO1xuICAgICAgICBtYXhXYWl0ID0gJ21heFdhaXQnIGluIG9wdGlvbnMgJiYgKG5hdGl2ZU1heCh3YWl0LCBvcHRpb25zLm1heFdhaXQpIHx8IDApO1xuICAgICAgICB0cmFpbGluZyA9ICd0cmFpbGluZycgaW4gb3B0aW9ucyA/IG9wdGlvbnMudHJhaWxpbmcgOiB0cmFpbGluZztcbiAgICAgIH1cbiAgICAgIHZhciBkZWxheWVkID0gZnVuY3Rpb24oKSB7XG4gICAgICAgIHZhciByZW1haW5pbmcgPSB3YWl0IC0gKG5vdygpIC0gc3RhbXApO1xuICAgICAgICBpZiAocmVtYWluaW5nIDw9IDApIHtcbiAgICAgICAgICBpZiAobWF4VGltZW91dElkKSB7XG4gICAgICAgICAgICBjbGVhclRpbWVvdXQobWF4VGltZW91dElkKTtcbiAgICAgICAgICB9XG4gICAgICAgICAgdmFyIGlzQ2FsbGVkID0gdHJhaWxpbmdDYWxsO1xuICAgICAgICAgIG1heFRpbWVvdXRJZCA9IHRpbWVvdXRJZCA9IHRyYWlsaW5nQ2FsbCA9IHVuZGVmaW5lZDtcbiAgICAgICAgICBpZiAoaXNDYWxsZWQpIHtcbiAgICAgICAgICAgIGxhc3RDYWxsZWQgPSBub3coKTtcbiAgICAgICAgICAgIHJlc3VsdCA9IGZ1bmMuYXBwbHkodGhpc0FyZywgYXJncyk7XG4gICAgICAgICAgICBpZiAoIXRpbWVvdXRJZCAmJiAhbWF4VGltZW91dElkKSB7XG4gICAgICAgICAgICAgIGFyZ3MgPSB0aGlzQXJnID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgdGltZW91dElkID0gc2V0VGltZW91dChkZWxheWVkLCByZW1haW5pbmcpO1xuICAgICAgICB9XG4gICAgICB9O1xuXG4gICAgICB2YXIgbWF4RGVsYXllZCA9IGZ1bmN0aW9uKCkge1xuICAgICAgICBpZiAodGltZW91dElkKSB7XG4gICAgICAgICAgY2xlYXJUaW1lb3V0KHRpbWVvdXRJZCk7XG4gICAgICAgIH1cbiAgICAgICAgbWF4VGltZW91dElkID0gdGltZW91dElkID0gdHJhaWxpbmdDYWxsID0gdW5kZWZpbmVkO1xuICAgICAgICBpZiAodHJhaWxpbmcgfHwgKG1heFdhaXQgIT09IHdhaXQpKSB7XG4gICAgICAgICAgbGFzdENhbGxlZCA9IG5vdygpO1xuICAgICAgICAgIHJlc3VsdCA9IGZ1bmMuYXBwbHkodGhpc0FyZywgYXJncyk7XG4gICAgICAgICAgaWYgKCF0aW1lb3V0SWQgJiYgIW1heFRpbWVvdXRJZCkge1xuICAgICAgICAgICAgYXJncyA9IHRoaXNBcmcgPSBudWxsO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfTtcblxuICAgICAgcmV0dXJuIGZ1bmN0aW9uKCkge1xuICAgICAgICBhcmdzID0gYXJndW1lbnRzO1xuICAgICAgICBzdGFtcCA9IG5vdygpO1xuICAgICAgICB0aGlzQXJnID0gdGhpcztcbiAgICAgICAgdHJhaWxpbmdDYWxsID0gdHJhaWxpbmcgJiYgKHRpbWVvdXRJZCB8fCAhbGVhZGluZyk7XG5cbiAgICAgICAgaWYgKG1heFdhaXQgPT09IGZhbHNlKSB7XG4gICAgICAgICAgdmFyIGxlYWRpbmdDYWxsID0gbGVhZGluZyAmJiAhdGltZW91dElkO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmICghbWF4VGltZW91dElkICYmICFsZWFkaW5nKSB7XG4gICAgICAgICAgICBsYXN0Q2FsbGVkID0gc3RhbXA7XG4gICAgICAgICAgfVxuICAgICAgICAgIHZhciByZW1haW5pbmcgPSBtYXhXYWl0IC0gKHN0YW1wIC0gbGFzdENhbGxlZCksXG4gICAgICAgICAgICAgIGlzQ2FsbGVkID0gcmVtYWluaW5nIDw9IDA7XG5cbiAgICAgICAgICBpZiAoaXNDYWxsZWQpIHtcbiAgICAgICAgICAgIGlmIChtYXhUaW1lb3V0SWQpIHtcbiAgICAgICAgICAgICAgbWF4VGltZW91dElkID0gY2xlYXJUaW1lb3V0KG1heFRpbWVvdXRJZCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsYXN0Q2FsbGVkID0gc3RhbXA7XG4gICAgICAgICAgICByZXN1bHQgPSBmdW5jLmFwcGx5KHRoaXNBcmcsIGFyZ3MpO1xuICAgICAgICAgIH1cbiAgICAgICAgICBlbHNlIGlmICghbWF4VGltZW91dElkKSB7XG4gICAgICAgICAgICBtYXhUaW1lb3V0SWQgPSBzZXRUaW1lb3V0KG1heERlbGF5ZWQsIHJlbWFpbmluZyk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChpc0NhbGxlZCAmJiB0aW1lb3V0SWQpIHtcbiAgICAgICAgICB0aW1lb3V0SWQgPSBjbGVhclRpbWVvdXQodGltZW91dElkKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmICghdGltZW91dElkICYmIHdha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bWV0aG9kTmFtZV0gPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgIHZhciBjaGFpbkFsbCA9IHRoaXMuX19jaGFpbl9fLFxuICAgICAgICAgICAgICAgIHZhbHVlID0gdGhpcy5fX3dyYXBwZWRfXyxcbiAgICAgICAgICAgICAgICBhcmdzID0gW3ZhbHVlXTtcblxuICAgICAgICAgICAgcHVzaC5hcHBseShhcmdzLCBhcmd1bWVudHMpO1xuICAgICAgICAgICAgdmFyIHJlc3VsdCA9IGZ1bmMuYXBwbHkob2JqZWN0LCBhcmdzKTtcbiAgICAgICAgICAgIGlmIChjaGFpbiB8fCBjaGFpbkFsbCkge1xuICAgICAgICAgICAgICBpZiAodmFsdWUgPT09IHJlc3VsdCAmJiBpc09iamVjdChyZXN1bHQpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgcmVzdWx0ID0gbmV3IGN0b3IocmVzdWx0KTtcbiAgICAgICAgICAgICAgcmVzdWx0Ll9fY2hhaW5fXyA9IGNoYWluQWxsO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgICB9KTtcbiAgICB9XG5cbiAgICAvKipcbiAgICAgKiBSZXZlcnRzIHRoZSAnXycgdmFyaWFibGUgdG8gaXRzIHByZXZpb3VzIHZhbHVlIGFuZCByZXR1cm5zIGEgcmVmZXJlbmNlIHRvXG4gICAgICogdGhlIGBsb2Rhc2hgIGZ1bmN0aW9uLlxuICAgICAqXG4gICAgICogQHN0YXRpY1xuICAgICAqIEBtZW1iZXJPZiBfXG4gICAgICogQGNhdGVnb3J5IFV0aWxpdGllc1xuICAgICAqIEByZXR1cm5zIHtGdW5jdGlvbn0gUmV0dXJucyB0aGUgYGxvZGFzaGAgZnVuY3Rpb24uXG4gICAgICogQGV4YW1wbGVcbiAgICAgKlxuICAgICAqIHZh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bnB1dCBpbnN0YW5jZW9mIERhdGUgfHwgT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKGlucHV0KSA9PT0gJ1tvYmplY3QgRGF0ZV0nO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIG1hcChhcnIsIGZuKSB7XG4gICAgICAgIHZhciByZXMgPSBbXSwgaTtcbiAgICAgICAgZm9yIChpID0gMDsgaSA8IGFyci5sZW5ndGg7ICsraSkge1xuICAgICAgICAgICAgcmVzLnB1c2goZm4oYXJyW2ldLCBpKSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlcztcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBoYXNPd25Qcm9wKGEsIGIpIHtcbiAgICAgICAgcmV0dXJuIE9iamVjdC5wcm90b3R5cGUuaGFzT3duUHJvcGVydHkuY2FsbChhLCBiKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBleHRlbmQoYSwgYikge1xuICAgICAgICBmb3IgKHZhciBpIGluIGIpIHtcbiAgICAgICAgICAgIGlmIChoYXNPd25Qcm9wKGIsIGkpKSB7XG4gICAgICAgICAgICAgICAgYVtpXSA9IGJbaV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoaGFzT3duUHJvcChiLCAndG9TdHJpbmcnKSkge1xuICAgICAgICAgICAgYS50b1N0cmluZyA9IGIudG9TdHJpbmc7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoaGFzT3duUHJvcChiLCAndmFsdWVPZicpKSB7XG4gICAgICAgICAgICBhLnZhbHVlT2YgPSBiLnZhbHVlT2Y7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gYTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjcmVhdGVfdXRjX19jcmVhdGVVVEMgKGlucHV0LCBmb3JtYXQsIGxvY2FsZSwgc3RyaWN0KSB7XG4gICAgICAgIHJldHVybiBjcmVhdGVMb2NhbE9yVVRDKGlucHV0LCBmb3JtYXQsIGxvY2FsZSwgc3RyaWN0LCB0cnVlKS51dGMoKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBkZWZhdWx0UGFyc2luZ0ZsYWdzKCkge1xuICAgICAgICAvLyBXZSBuZWVkIHRvIGRlZXAgY2xvbmUgdGhpcyBvYmplY3QuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBlbXB0eSAgICAgICAgICAgOiBmYWxzZSxcbiAgICAgICAgICAgIHVudXNlZFRva2VucyAgICA6IFtdLFxuICAgICAgICAgICAgdW51c2VkSW5wdXQgICAgIDogW10sXG4gICAgICAgICAgICBvdmVyZmxvdyAgICAgICAgOiAtMixcbiAgICAgICAgICAgIGNoYXJzTGVmdE92ZXIgICA6IDAsXG4gICAgICAgICAgICBudWxsSW5wdXQgICAgICAgOiBmYWxzZSxcbiAgICAgICAgICAgIGludmFsaWRNb250aCAgICA6IG51bGwsXG4gICAgICAgICAgICBpbnZhbGlkRm9ybWF0ICAgOiBmYWxzZSxcbiAgICAgICAgICAgIHVzZXJJbnZhbGlkYXRlZCA6IGZhbHNlLFxuICAgICAgICAgICAgaXNvICAgICAgICAgICAgIDogZmFsc2VcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBnZXRQYXJzaW5nRmxhZ3MobSkge1xuICAgICAgICBpZiAobS5fcGYgPT0gbnVsbCkge1xuICAgICAgICAgICAgbS5fcGYgPSBkZWZhdWx0UGFyc2luZ0ZsYWdzKCk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG0uX3BmO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHZhbGlkX19pc1ZhbGlkKG0pIHtcbiAgICAgICAgaWYgKG0uX2lzVmFsaWQgPT0gbnVsbCkge1xuICAgICAgICAgICAgdmFyIGZsYWdzID0gZ2V0UGFyc2luZ0ZsYWdzKG0pO1xuICAgICAgICAgICAgbS5faXNWYWxpZCA9ICFpc05hTihtLl9kLmdldFRpbWUoKSkgJiZcbiAgICAgICAgICAgICAgICBmbGFncy5vdmVyZmxvdyA8IDAgJiZcbiAgICAgICAgICAgICAgICAhZmxhZ3MuZW1wdHkgJiZcbiAgICAgICAgICAgICAgICAhZmxhZ3MuaW52YWxpZE1vbnRoICYmXG4gICAgICAgICAgICAgICAgIWZsYWdzLm51bGxJbnB1dCAmJlxuICAgICAgICAgICAgICAgICFmbGFncy5pbnZhbGlkRm9ybWF0ICYmXG4gICAgICAgICAgICAgICAgIWZsYWdzLnVzZXJJbnZhbGlkYXRlZDtcblxuICAgICAgICAgICAgaWYgKG0uX3N0cmljdCkge1xuICAgICAgICAgICAgICAgIG0uX2lzVmFsaWQgPSBtLl9pc1ZhbGlkICYmXG4gICAgICAgICAgICAgICAgICAgIGZsYWdzLmNoYXJzTGVmdE92ZXIgPT09IDAgJiZcbiAgICAgICAgICAgICAgICAgICAgZmxhZ3MudW51c2VkVG9rZW5zLmxlbmd0aCA9PT0gMCAmJlxuICAgICAgICAgICAgICAgICAgICBmbGFncy5iaWdIb3VyID09PSB1bmRlZmluZWQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG0uX2lzVmFsaWQ7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gdmFsaWRfX2NyZWF0ZUludmFsaWQgKGZsYWdzKSB7XG4gICAgICAgIHZhciBtID0gY3JlYXRlX3V0Y19fY3JlYXRlVVRDKE5hTik7XG4gICAgICAgIGlmIChmbGFncyAhPSBudWxsKSB7XG4gICAgICAgICAgICBleHRlbmQoZ2V0UGFyc2luZ0ZsYWdzKG0pLCBmbGFncyk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBnZXRQYXJzaW5nRmxhZ3MobSkudXNlckludmFsaWRhdGVkID0gdHJ1ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBtO1xuICAgIH1cblxuICAgIHZhciBtb21lbnRQcm9wZXJ0aWVzID0gdXRpbHNfaG9va3NfX2hvb2tzLm1vbWVudFByb3BlcnRpZXMgPSBbXTtcblxuICAgIGZ1bmN0aW9uIGNvcHlDb25maWcodG8sIGZyb20pIHtcbiAgICAgICAgdmFyIGksIHByb3AsIHZhbDtcblxuICAgICAgICBpZiAodHlwZW9mIGZyb20uX2lzQU1vbWVudE9iamVjdCAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgIHRvLl9pc0FNb21lbnRPYmplY3QgPSBmcm9tLl9pc0FNb21lbnRPYmplY3Q7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHR5cGVvZiBmcm9tLl9pICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgdG8uX2kgPSBmcm9tLl9pO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0eXBlb2YgZnJvbS5fZiAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgIHRvLl9mID0gZnJvbS5fZjtcbiAgICAgICAgfVxuICAgICAgICBpZiAodHlwZW9mIGZyb20uX2wgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICB0by5fbCA9IGZyb20uX2w7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHR5cGVvZiBmcm9tLl9zdHJpY3QgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICB0by5fc3RyaWN0ID0gZnJvbS5fc3RyaWN0O1xuICAgICAgICB9XG4gICAgICAgIGlmICh0eXBlb2YgZnJvbS5fdHptICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgdG8uX3R6bSA9IGZyb20uX3R6bTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodHlwZW9mIGZyb20uX2lzVVRDICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgdG8uX2lzVVRDID0gZnJvbS5faXNVVEM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHR5cGVvZiBmcm9tLl9vZmZzZXQgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICB0by5fb2Zmc2V0ID0gZnJvbS5fb2Zmc2V0O1xuICAgICAgICB9XG4gICAgICAgIGlmICh0eXBlb2YgZnJvbS5fcGYgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICB0by5fcGYgPSBnZXRQYXJzaW5nRmxhZ3MoZnJvbSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHR5cGVvZiBmcm9tLl9sb2NhbGUgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICB0by5fbG9jYWxlID0gZnJvbS5fbG9jYWxlO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKG1vbWVudFByb3BlcnRpZXMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgZm9yIChpIGluIG1vbWVudFByb3BlcnRpZXMpIHtcbiAgICAgICAgICAgICAgICBwcm9wID0gbW9tZW50UHJvcGVydGllc1tpXTtcbiAgICAgICAgICAgICAgICB2YWwgPSBmcm9tW3Byb3BdO1xuICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICB0b1twcm9wXSA9IHZhbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdG87XG4gICAgfVxuXG4gICAgdmFyIHVwZGF0ZUluUHJvZ3Jlc3MgPSBmYWxzZTtcblxuICAgIC8vIE1vbWVudCBwcm90b3R5cGUgb2JqZWN0XG4gICAgZnVuY3Rpb24gTW9tZW50KGNvbmZpZykge1xuICAgICAgICBjb3B5Q29uZmlnKHRoaXMsIGNvbmZpZyk7XG4gICAgICAgIHRoaXMuX2QgPSBuZXcgRGF0ZSgrY29uZmlnLl9kKTtcbiAgICAgICAgLy8gUHJldmVudCBpbmZpbml0ZSBsb29wIGluIGNhc2UgdXBkYXRlT2Zmc2V0IGNyZWF0ZXMgbmV3IG1vbWVudFxuICAgICAgICAvLyBvYmplY3RzLl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4gdGhlIGN1cnJlbnQgcm9vdFxuICAgIGZ1bmN0aW9uIGNob29zZUxvY2FsZShuYW1lcykge1xuICAgICAgICB2YXIgaSA9IDAsIGosIG5leHQsIGxvY2FsZSwgc3BsaXQ7XG5cbiAgICAgICAgd2hpbGUgKGkgPCBuYW1lcy5sZW5ndGgpIHtcbiAgICAgICAgICAgIHNwbGl0ID0gbm9ybWFsaXplTG9jYWxlKG5hbWVzW2ldKS5zcGxpdCgnLScpO1xuICAgICAgICAgICAgaiA9IHNwbGl0Lmxlbmd0aDtcbiAgICAgICAgICAgIG5leHQgPSBub3JtYWxpemVMb2NhbGUobmFtZXNbaSArIDFdKTtcbiAgICAgICAgICAgIG5leHQgPSBuZXh0ID8gbmV4dC5zcGxpdCgnLScpIDogbnVsbDtcbiAgICAgICAgICAgIHdoaWxlIChqID4gMCkge1xuICAgICAgICAgICAgICAgIGxvY2FsZSA9IGxvYWRMb2NhbGUoc3BsaXQuc2xpY2UoMCwgaikuam9pbignLScpKTtcbiAgICAgICAgICAgICAgICBpZiAobG9jYWxlKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBsb2NhbGU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChuZXh0ICYmIG5leHQubGVuZ3RoID49IGogJiYgY29tcGFyZUFycmF5cyhzcGxpdCwgbmV4dCwgdHJ1ZSkgPj0gaiAtIDEpIHtcbiAgICAgICAgICAgICAgICAgICAgLy90aGUgbmV4dCBhcnJheSBpdGVtIGlzIGJldHRlciB0aGFuIGEgc2hhbGxvd2VyIHN1YnN0cmluZyBvZiB0aGlzIG9uZVxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgai0tO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaSsrO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGxvYWRMb2Nhb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lc19fZ2V0U2V0R2xvYmFsTG9jYWxlIChrZXksIHZhbHVlcykge1xuICAgICAgICB2YXIgZGF0YTtcbiAgICAgICAgaWYgKGtleSkge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiB2YWx1ZXMgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgZGF0YSA9IGxvY2FsZV9sb2NhbGVzX19nZXRMb2NhbGUoa2V5KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGRhdGEgPSBkZWZpbmVMb2NhbGUoa2V5LCB2YWx1ZXMpO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpZiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIC8vIG1vbWVudC5kdXJhdGlvbi5fbG9jYWxlID0gbW9tZW50Ll9sb2NhbGUgPSBkYXRhO1xuICAgICAgICAgICAgICAgIGdsb2JhbExvY2FsZSA9IGRhdGE7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gZ2xvYmFsTG9jYWxlLl9hYmJyO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGRlZmluZUxvY2FsZSAobmFtZSwgdmFsdWVzKSB7XG4gICAgICAgIGlmICh2YWx1ZXMgIT09IG51bGwpIHtcbiAgICAgICAgICAgIHZhbHVlcy5hYmJyID0gbmFtZTtcbiAgICAgICAgICAgIGlmICghbG9jYWxlc1tuYW1lXSkge1xuICAgICAgICAgICAgICAgIGxvY2FsZXNbbmFtZV0gPSBuZXcgTG9jYWxlKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBsb2NhbGVzW25hbWVdLnNldCh2YWx1ZXMpO1xuXG4gICAgICAgICAgICAvLyBiYWNrd2FyZHMgY29tcGF0IGZvciBub3c6IGFsc28gc2V0IHRoZSBsb2NhbGVcbiAgICAgICAgICAgIGxvY2FsZV9sb2NhbGVzX19nZXRTZXRHbG9iYWxMb2NhbGUobmFtZSk7XG5cbiAgICAgICAgICAgIHJldHVybiBsb2NhbGVzW25hbWVdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gdXNlZnVsIGZvciB0ZXN0aW5nXG4gICAgICAgICAgICBkZWxldGUgbG9jYWxlc1tuYW1lXTtcbiAgICAgICAgICAgIHJldHVybiBudWxsO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgLy8gcmV0dXJucyBsb2NhbGUgZGF0YVxuICAgIGZ1bmN0aW9uIGxvY2FsZV9sb2NhbGVzX19nZXRMb2NhbGUgKGtleSkge1xuICAgICAgICB2YXIgbG9jYWxlO1xuXG4gICAgICAgIGlmIChrZXkgJiYga2V5Ll9sb2NhbGUgJiYga2V5Ll9sb2NhbGUuX2FiYnIpIHtcbiAgICAgICAgICAgIGtleSA9IGtleS5fbG9jYWxlLl9hYmJyO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCFrZXkpIHtcbiAgICAgICAgICAgIHJldHVybiBnbG9iYWxMb2NhbGU7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoIWlzQXJyYXkoa2V5KSkge1xuICAgICAgICAgICAgLy9zaG9ydC1jaXJjdWl0IGV2ZXJ5dGhpbmcgZWxzZVxuICAgICAgICAgICAgbG9jYWxlID0gbG9hZExvY2FsZShrZXkpO1xuICAgICAgICAgICAgaWYgKGxvY2FsZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBsb2NhbGU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBrZXkgPSBba2V5XTtcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBjaG9vc2VMb2NhbGUoa2V5KTtcbiAgICB9XG5cbiAgICB2YXIgYWxpYXNlcyA9IHt9O1xuXG4gICAgZnVuY3Rpb24gYWRkVW5pdEFsaWFzICh1bml0LCBzaG9ydGhhbmQpIHtcbiAgICAgICAgdmFyIGxvd2VyQ2FzZSA9IHVuaXQudG9Mb3dlckNhc2UoKTtcbiAgICAgICAgYWxpYXNlc1tsb3dlckNhc2VdID0gYWxpYXNlc1tsb3dlckNhc2UgKyAncyddID0gYWxpYXNlc1tzaG9ydGhhbmRdID0gdW5pdDtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBub3JtYWxpemVVbml0cyh1bml0cykge1xuICAgICAgICByZXR1cm4gdHlwZW9mIHVuaXRzID09PSAnc3RyaW5nJyA/IGFsaWFzZXNbdW5pdHNdIHx8IGFsaWFzZXNbdW5pdHMudG9Mb3dlckNhc2UoKV0gOiB1bmRlZmluZWQ7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbm9ybWFsaXplT2JqZWN0VW5pdHMoaW5wdXRPYmplY3QpIHtcbiAgICAgICAgdmFyIG5vcm1hbGl6ZWRJbnB1dCA9IHt9LFxuICAgICAgICAgICAgbm9ybWFsaXplZFByb3AsXG4gICAgICAgICAgICBwcm9wO1xuXG4gICAgICAgIGZvciAocHJvcCBpbiBpbnB1dE9iamVjdCkge1xuICAgICAgICAgICAgaWYgKGhhc093blByb3AoaW5wdXRPYmplY3QsIHByb3ApKSB7XG4gICAgICAgICAgICAgICAgbm9ybWFsaXplZFByb3AgPSBub3JtYWxpemVVbml0cyhwcm9wKTtcbiAgICAgICAgICAgICAgICBpZiAobm9ybWFsaXplZFByb3ApIHtcbiAgICAgICAgICAgICAgICAgICAgbm9ybWFsaXplZElucHV0W25vcm1hbGl6ZWRQcm9wXSA9IGlucHV0T2JqZWN0W3Byb3BdO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiBub3JtYWxpemVkSW5wdXQ7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbWFrZUdldFNldCAodW5pdCwga2VlcFRpbWUpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICh2YWx1ZSkge1xuICAgICAgICAgICAgaWYgKHZhbHVlICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICBnZXRfc2V0X19zZXQodGhpcywgdW5pdCwgdmFsdWUpO1xuICAgICAgICAgICAgICAgIHV0aWxzX2hvb2tzX19ob29rcy51cGRhdGVPZmZzZXQodGhpcywga2VlcFRpbWUpO1xuICAgICAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZ2V0X3NldF9fZ2V0KHRoaXMsIHVuaXQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9O1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGdldF9zZXRfX2dldCAobW9tLCB1bml0KSB7XG4gICAgICAgIHJldHVybiBtb20uX2RbJ2dldCcgKyAobW9tLl9pc1VUQyA/ICdVVEMnIDogJycpICsgdW5pdF0oKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBnZXRfc2V0X19zZXQgKG1vbSwgdW5pdCwgdmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIG1vbS5fZFsnc2V0JyArIChtb20uX2lzVVRDID8gJ1VUQycgOiAnJykgKyB1bml0XSh2YWx1ZSk7XG4gICAgfVxuXG4gICAgLy8gTU9NRU5UU1xuXG4gICAgZnVuY3Rpb24gZ2V0U2V0ICh1bml0cywgdmFsdWUpIHtcbiAgICAgICAgdmFyIHVuaXQ7XG4gICAgICAgIGlmICh0eXBlb2YgdW5pdHMgPT09ICdvYmplY3QnKSB7XG4gICAgICAgICAgICBmb3IgKHVuaXQgaW4gdW5pdHMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnNldCh1bml0LCB1bml0c1t1bml0XSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB1bml0cyA9IG5vcm1hbGl6ZVVuaXRzKHVuaXRzKTtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgdGhpc1t1bml0c10gPT09ICdmdW5jdGlvbicpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gdGhpc1t1bml0c10odmFsdWUpO1xuIC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gZm9yIChpID0gMDsgaSA8IDEyOyBpKyspIHtcbiAgICAgICAgICAgIC8vIG1ha2UgdGhlIHJlZ2V4IGlmIHdlIGRvbid0IGhhdmUgaXQgYWxyZWFkeVxuICAgICAgICAgICAgbW9tID0gY3JlYXRlX3V0Y19fY3JlYXRlVVRDKFsyMDAwLCBpXSk7XG4gICAgICAgICAgICBpZiAoc3RyaWN0ICYmICF0aGlzLl9sb25nTW9udGhzUGFyc2VbaV0pIHtcbiAgICAgICAgICAgICAgICB0aGlzLl9sb25nTW9udGhzUGFyc2VbaV0gPSBuZXcgUmVnRXhwKCdeJyArIHRoaXMubW9udGhzKG1vbSwgJycpLnJlcGxhY2UoJy4nLCAnJykgKyAnJCcsICdpJyk7XG4gICAgICAgICAgICAgICAgdGhpcy5fc2hvcnRNb250aHNQYXJzZVtpXSA9IG5ldyBSZWdFeHAoJ14nICsgdGhpcy5tb250aHNTaG9ydChtb20sICcnKS5yZXBsYWNlKCcuJywgJycpICsgJyQnLCAnaScpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCFzdHJpY3QgJiYgIXRoaXMuX21vbnRoc1BhcnNlW2ldKSB7XG4gICAgICAgICAgICAgICAgcmVnZXggPSAnXicgKyB0aGlzLm1vbnRocyhtb20sICcnKSArICd8XicgKyB0aGlzLm1vbnRoc1Nob3J0KG1vbSwgJycpO1xuICAgICAgICAgICAgICAgIHRoaXMuX21vbnRoc1BhcnNlW2ldID0gbmV3IFJlZ0V4cChyZWdleC5yZXBsYWNlKCcuJywgJycpLCAnaScpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gdGVzdCB0aGUgcmVnZXhcbiAgICAgICAgICAgIGlmIChzdHJpY3QgJiYgZm9ybWF0ID09PSAnTU1NTScgJiYgdGhpcy5fbG9uZ01vbnRoc1BhcnNlW2ldLnRlc3QobW9udGhOYW1lKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChzdHJpY3QgJiYgZm9ybWF0ID09PSAnTU1NJyAmJiB0aGlzLl9zaG9ydE1vbnRoc1BhcnNlW2ldLnRlc3QobW9udGhOYW1lKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBpO1xuICAgICAgICAgICAgfSBlbHNlIGlmICghc3RyaWN0ICYmIHRoaXMuX21vbnRoc1BhcnNlW2ldLnRlc3QobW9udGhOYW1lKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuXG4gICAgLy8gTU9NRU5UU1xuXG4gICAgZnVuY3Rpb24gc2V0TW9udGggKG1vbSwgdmFsdWUpIHtcbiAgICAgICAgdmFyIGRheU9mTW9udGg7XG5cbiAgICAgICAgLy8gVE9ETzogTW92ZSB0aGlzIG91dCBvZiBoZXJlIVxuICAgICAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgdmFsdWUgPSBtb20ubG9jYWxlRGF0YSgpLm1vbnRoc1BhcnNlKHZhbHVlKTtcbiAgICAgICAgICAgIC8vIFRPRE86IEFub3RoZXIgc2lsZW50IGZhaWx1cmU/XG4gICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnbnVtYmVyJykge1xuICAgICAgICAgICAgICAgIHJldHVybiBtb207XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBkYXlPZk1vbnRoID0gTWF0aC5taW4obW9tLmRhdGUoKSwgZGF5c0luTW9udGgobW9tLnllYXIoKSwgdmFsdWUpKTtcbiAgICAgICAgbW9tLl9kWydzZXQnICsgKG1vbS5faXNVVEMgPyAnVVRDJyA6ICcnKSArICdNb250aCddKHZhbHVlLCBkYXlPZk1vbnRoKTtcbiAgICAgICAgcmV0dXJuIG1vbTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBnZXRTZXRNb250aCAodmFsdWUpIHtcbiAgICAgICAgaWYgKHZhbHVlICE9IG51bGwpIHtcbiAgICAgICAgICAgIHNldE1vbnRoKHRoaXMsIHZhbHVlKTtcbiAgICAgICAgICAgIHV0aWxzX2hvb2tzX19ob29rcy51cGRhdGVPZmZzZXQodGhpcywgdHJ1ZSk7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiBnZXRfc2V0X19nZXQodGhpcywgJ01vbnRoJyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBnZXREYXlzSW5Nb250aCAoKSB7XG4gICAgICAgIHJldHVybiBkYXlzSW5Nb250aCh0aGlzLnllYXIoKSwgdGhpcy5tb250aCgpKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjaGVja092ZXJmbG93IChtKSB7XG4gICAgICAgIHZhciBvdmVyZmxvdztcbiAgICAgICAgdmFyIGEgPSBtLl9hO1xuXG4gICAgICAgIGlmIChhICYmIGdldFBhcnNpbmdGbGFncyhtKS5vdmVyZmxvdyA9PT0gLTIpIHtcbiAgICAgICAgICAgIG92ZXJmbG93ID1cbiAgICAgICAgICAgICAgICBhW01PTlRIXSAgICAgICA8IDAgfHwgYVtNT05USF0gICAgICAgPiAxMSAgPyBNT05USCA6XG4gICAgICAgICAgICAgICAgYVtEQVRFXSAgICAgICAgPCAxIHx8IGFbREFURV0gICAgICAgID4gZGF5c0luTW9udGgoYVtZRUFSXSwgYVtNT05USF0pID8gREFURSA6XG4gICAgICAgICAgICAgICAgYVtIT1VSXSAgICAgICAgPCAwIHx8IGFbSE9VUl0gICAgICAgID4gMjQgfHwgKGFbSE9VUl0gPT09IDI0ICYmIChhW01JTlVURV0gIT09IDAgfHwgYVtTRUNPTkRdICE9PSAwIHx8IGFbTUlMTElTRUNPTkRdICE9PSAwKSkgPyBIT1VSIDpcbiAgICAgICAgICAgICAgICBhW01JTlVURV0gICAgICA8IDAgfHwgYVtNSU5VVEVdICAgICAgPiA1OSAgPyBNSU5VVEUgOlxuICAgICAgICAgICAgICAgIGFbU0VDT05EXSAgICAgIDwgMCB8fCBhW1NFQ09ORF0gICAgICA+IDU5ICA/IFNFQ09ORCA6XG4gICAgICAgICAgICAgICAgYVtNSUxMSVNFQ09ORF0gPCAwIHx8IGFbTUlMTElTRUNPTkRdID4gOTk5ID8gTUlMTElTRUNPTkQgOlxuICAgICAgICAgICAgICAgIC0xO1xuXG4gICAgICAgICAgICBpZiAoZ2V0UGFyc2luZ0ZsYWdzKG0pLl9vdmVyZmxvd0RheU9mWWVhciAmJiAob3ZlcmZsb3cgPCBZRUFSIHx8IG92ZXJmbG93ID4gREFURSkpIHtcbiAgICAgICAgICAgICAgICBvdmVyZmxvdyA9IERBVEU7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGdldFBhcnNpbmdGbGFncyhtKS5vdmVyZmxvdyA9IG92ZXJmbG93O1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIG07XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gd2Fybihtc2cpIHtcbiAgICAgICAgaWYgKHV0aWxzX2hvb2tzX19ob29rcy5zdXBwcmVzc0RlcHJlY2F0aW9uV2FybmluZ3MgPT09IGZhbHNlICYmIHR5cGVvZiBjb25zb2xlICE9PSAndW5kZWZpbmVkJyAmJiBjb25zb2xlLndhcm4pIHtcbiAgICAgICAgICAgIGNvbnNvbGUud2FybignRGVwcmVjYXRpb24gd2FybmluZzogJyArIG1zZyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBkZXByZWNhdGUobXNnLCBmbikge1xuICAgICAgICB2YXIgZmlyc3RUaW1lID0gdHJ1ZSxcbiAgICAgICAgICAgIG1zZ1dpdGhTdGFjayA9IG1zZyArICdcXG4nICsgKG5ldyBFcnJvcigpKS5zdGFjaztcblxuICAgICAgICByZXR1cm4gZXh0ZW5kKGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIGlmIChmaXJzdFRpbWUpIHtcbiAgICAgIC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VswXSArIChtYXRjaFs2XSB8fCAnICcpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBmb3IgKGkgPSAwLCBsID0gaXNvVGltZXMubGVuZ3RoOyBpIDwgbDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgaWYgKGlzb1RpbWVzW2ldWzFdLmV4ZWMoc3RyaW5nKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25maWcuX2YgKz0gaXNvVGltZXNbaV1bMF07XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChzdHJpbmcubWF0Y2gobWF0Y2hPZmZzZXQpKSB7XG4gICAgICAgICAgICAgICAgY29uZmlnLl9mICs9ICdaJztcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbmZpZ0Zyb21TdHJpbmdBbmRGb3JtYXQoY29uZmlnKTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGNvbmZpZy5faXNWYWxpZCA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgLy8gZGF0ZSBmcm9tIGlzbyBmb3JtYXQgb3IgZmFsbGJhY2tcbiAgICBmdW5jdGlvbiBjb25maWdGcm9tU3RyaW5nKGNvbmZpZykge1xuICAgICAgICB2YXIgbWF0Y2hlZCA9IGFzcE5ldEpzb25SZWdleC5leGVjKGNvbmZpZy5faSk7XG5cbiAgICAgICAgaWYgKG1hdGNoZWQgIT09IG51bGwpIHtcbiAgICAgICAgICAgIGNvbmZpZy5fZCA9IG5ldyBEYXRlKCttYXRjaGVkWzFdKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGNvbmZpZ0Zyb21JU08oY29uZmlnKTtcbiAgICAgICAgaWYgKGNvbmZpZy5faXNWYWxpZCA9PT0gZmFsc2U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dCBjb250YWlucyB0aGUgZmlyc3RcbiAgICAvLyAgICAgICAgICAgICAgICAgICAgICBvZiB0aGlzIGRheSBvZiB0aGUgd2Vla1xuICAgIC8vICAgICAgICAgICAgICAgICAgICAgIChlZy4gSVNPIHdlZWtzIHVzZSB0aHVyc2RheSAoNCkpXG4gICAgZnVuY3Rpb24gd2Vla09mWWVhcihtb20sIGZpcnN0RGF5T2ZXZWVrLCBmaXJzdERheU9mV2Vla09mWWVhcikge1xuICAgICAgICB2YXIgZW5kID0gZmlyc3REYXlPZldlZWtPZlllYXIgLSBmaXJzdERheU9mV2VlayxcbiAgICAgICAgICAgIGRheXNUb0RheU9mV2VlayA9IGZpcnN0RGF5T2ZXZWVrT2ZZZWFyIC0gbW9tLmRheSgpLFxuICAgICAgICAgICAgYWRqdXN0ZWRNb21lbnQ7XG5cblxuICAgICAgICBpZiAoZGF5c1RvRGF5T2ZXZWVrID4gZW5kKSB7XG4gICAgICAgICAgICBkYXlzVG9EYXlPZldlZWsgLT0gNztcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChkYXlzVG9EYXlPZldlZWsgPCBlbmQgLSA3KSB7XG4gICAgICAgICAgICBkYXlzVG9EYXlPZldlZWsgKz0gNztcbiAgICAgICAgfVxuXG4gICAgICAgIGFkanVzdGVkTW9tZW50ID0gbG9jYWxfX2NyZWF0ZUxvY2FsKG1vbSkuYWRkKGRheXNUb0RheU9mV2VlaywgJ2QnKTtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIHdlZWs6IE1hdGguY2VpbChhZGp1c3RlZE1vbWVudC5kYXlPZlllYXIoKSAvIDcpLFxuICAgICAgICAgICAgeWVhcjogYWRqdXN0ZWRNb21lbnQueWVhcigpXG4gICAgICAgIH07XG4gICAgfVxuXG4gICAgLy8gTE9DQUxFU1xuXG4gICAgZnVuY3Rpb24gbG9jYWxlV2VlayAobW9tKSB7XG4gICAgICAgIHJldHVybiB3ZWVrT2ZZZWFyKG1vbSwgdGhpcy5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pICsgKHdlZWtkYXkgLSBmaXJzdERheU9mV2VlaykgKyBkYXlzVG9BZGQgKyAxO1xuXG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICB5ZWFyICAgICAgOiBkYXlPZlllYXIgPiAwID8geWVhciAgICAgIDogeWVhciAtIDEsXG4gICAgICAgICAgICBkYXlPZlllYXIgOiBkYXlPZlllYXIgPiAwID8gZGF5T2ZZZWFyIDogZGF5c0luWWVhcih5ZWFyIC0gMSkgKyBkYXlPZlllYXJcbiAgICAgICAgfTtcbiAgICB9XG5cbiAgICAvLyBNT01FTlRTXG5cbiAgICBmdW5jdGlvbiBnZXRTZXREYXlPZlllYXIgKGlucHV0KSB7XG4gICAgICAgIHZhciBkYXlPZlllYXIgPSBNYXRoLnJvdW5kKCh0aGlzLmNsb25lKCkuc3RhcnRPZignZGF5JykgLSB0aGlzLmNsb25lKCkuc3RhcnRPZigneWVhcicpKSAvIDg2NGU1KSArIDE7XG4gICAgICAgIHJldHVybiBpbnB1dCA9PSBudWxsID8gZGF5T2ZZZWFyIDogdGhpcy5hZGQoKGlucHV0IC0gZGF5T2ZZZWFyKSwgJ2QnKTtcbiAgICB9XG5cbiAgICAvLyBQaWNrIHRoZSBmaXJzdCBkZWZpbmVkIG9mIHR3byBvciB0aHJlZSBhcmd1bWVudHMuXG4gICAgZnVuY3Rpb24gZGVmYXVsdHMoYSwgYiwgYykge1xuICAgICAgICBpZiAoYSAhPSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gYTtcbiAgICAgICAgfVxuICAgICAgICBpZiAoYiAhPSBudWxsKSB7XG4gICAgICAgICAgICByZXR1cm4gYjtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gYztcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjdXJyZW50RGF0ZUFycmF5KGNvbmZpZykge1xuICAgICAgICB2YXIgbm93ID0gbmV3IERhdGUoKTtcbiAgICAgICAgaWYgKGNvbmZpZy5fdXNlVVRDKSB7XG4gICAgICAg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kge1xuICAgICAgICAgICAgY29uZmlnLl9hW2ldID0gaW5wdXRbaV0gPSBjdXJyZW50RGF0ZVtpXTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIFplcm8gb3V0IHdoYXRldmVyIHdhcyBub3QgZGVmYXVsdGVkLCBpbmNsdWRpbmcgdGltZVxuICAgICAgICBmb3IgKDsgaSA8IDc7IGkrKykge1xuICAgICAgICAgICAgY29uZmlnLl9hW2ldID0gaW5wdXRbaV0gPSAoY29uZmlnLl9hW2ldID09IG51bGwpID8gKGkgPT09IDIgPyAxIDogMCkgOiBjb25maWcuX2FbaV07XG4gICAgICAgIH1cblxuICAgICAgICAvLyBDaGVjayBmb3IgMjQ6MDA6MDAuMDAwXG4gICAgICAgIGlmIChjb25maWcuX2FbSE9VUl0gPT09IDI0ICYmXG4gICAgICAgICAgICAgICAgY29uZmlnLl9hW01JTlVURV0gPT09IDAgJiZcbiAgICAgICAgICAgICAgICBjb25maWcuX2FbU0VDT05EXSA9PT0gMCAmJlxuICAgICAgICAgICAgICAgIGNvbmZpZy5fYVtNSUxMSVNFQ09ORF0gPT09IDApIHtcbiAgICAgICAgICAgIGNvbmZpZy5fbmV4dERheSA9IHRydWU7XG4gICAgICAgICAgICBjb25maWcuX2FbSE9VUl0gPSAwO1xuICAgICAgICB9XG5cbiAgICAgICAgY29uZmlnLl9kID0gKGNvbmZpZy5fdXNlVVRDID8gY3JlYXRlVVRDRGF0ZSA6IGNyZWF0ZURhdGUpLmFwcGx5KG51bGwsIGlucHV0KTtcbiAgICAgICAgLy8gQXBwbHkgdGltZXpvbmUgb2Zmc2V0IGZyb20gaW5wdXQuIFRoZSBhY3R1YWwgdXRjT2Zmc2V0IGNhbiBiZSBjaGFuZ2VkXG4gICAgICAgIC8vIHdpdGggcGFyc2Vab25lLlxuICAgICAgICBpZiAoY29uZmlnLl90em0gIT0gbnVsbCkge1xuICAgICAgICAgICAgY29uZmlnLl9kLnNldFVUQ01pbnV0ZXMoY29uZmlnLl9kL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AgICAgICBkb3cgPSBjb25maWcuX2xvY2FsZS5fd2Vlay5kb3c7XG4gICAgICAgICAgICBkb3kgPSBjb25maWcuX2xvY2FsZS5fd2Vlay5kb3k7XG5cbiAgICAgICAgICAgIHdlZWtZZWFyID0gZGVmYXVsdHMody5nZywgY29uZmlnLl9hW1lFQVJdLCB3ZWVrT2ZZZWFyKGxvY2FsX19jcmVhdGVMb2NhbCgpLCBkb3csIGRveSkueWVhcik7XG4gICAgICAgICAgICB3ZWVrID0gZGVmYXVsdHMody53LCAxKTtcblxuICAgICAgICAgICAgaWYgKHcuZCAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgLy8gd2Vla2RheSAtLSBsb3cgZGF5IG51bWJlcnMgYXJlIGNvbnNpZGVyZWQgbmV4dCB3ZWVrXG4gICAgICAgICAgICAgICAgd2Vla2RheSA9IHcuZDtcbiAgICAgICAgICAgICAgICBpZiAod2Vla2RheSA8IGRvdykge1xuICAgICAgICAgICAgICAgICAgICArK3dlZWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIGlmICh3LmUgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIC8vIGxvY2FsIHdlZWtkYXkgLS0gY291bnRpbmcgc3RhcnRzIGZyb20gYmVnaW5pbmcgb2Ygd2Vla1xuICAgICAgICAgICAgICAgIHdlZWtkYXkgPSB3LmUgKyBkb3c7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIC8vIGRlZmF1bHQgdG8gYmVnaW5pbmcgb2Ygd2Vla1xuICAgICAgICAgICAgICAgIHdlZWtkYXkgPSBkb3c7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGVtcCA9IGRheU9mWWVhckZyb21XZWVrcyh3ZWVrWWVhciwgd2Vlaywgd2Vla2RheSwgZG95LCBkb3cpO1xuXG4gICAgICAgIGNvbmZpZy5fYVtZRUFSXSA9IHRlbXAueWVhcjtcbiAgICAgICAgY29u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tdO1xuXG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCB0b2tlbnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHRva2VuID0gdG9rZW5zW2ldO1xuICAgICAgICAgICAgcGFyc2VkSW5wdXQgPSAoc3RyaW5nLm1hdGNoKGdldFBhcnNlUmVnZXhGb3JUb2tlbih0b2tlbiwgY29uZmlnKSkgfHwgW10pWzBdO1xuICAgICAgICAgICAgaWYgKHBhcnNlZElucHV0KSB7XG4gICAgICAgICAgICAgICAgc2tpcHBlZCA9IHN0cmluZy5zdWJzdHIoMCwgc3RyaW5nLmluZGV4T2YocGFyc2VkSW5wdXQpKTtcbiAgICAgICAgICAgICAgICBpZiAoc2tpcHBlZC5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGdldFBhcnNpbmdGbGFncyhjb25maWcpLnVudXNlZElucHV0LnB1c2goc2tpcHBlZCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHN0cmluZyA9IHN0cmluZy5zbGljZShzdHJpbmcuaW5kZXhPZihwYXJzZWRJbnB1dCkgKyBwYXJzZWRJbnB1dC5sZW5ndGgpO1xuICAgICAgICAgICAgICAgIHRvdGFsUGFyc2VkSW5wdXRMZW5ndGggKz0gcGFyc2VkSW5wdXQubGVuZ3RoO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gZG9uJ3QgcGFyc2UgaWYgaXQncyBub3QgYSBrbm93biB0b2tlblxuICAgICAgICAgICAgaWYgKGZvcm1hdFRva2VuRnVuY3Rpb25zW3Rva2VuXSkge1xuICAgICAgICAgICAgICAgIGlmIChwYXJzZWRJbnB1dCkge1xuICAgICAgICAgICAgICAgICAgICBnZXRQYXJzaW5nRmxhZ3MoY29uZmlnKS5lbXB0eSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZ2V0UGFyc2luZ0ZsYWdzKGNvbmZpZykudW51c2VkVG9rZW5zLnB1c2godG9rZW4pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBhZGRUaW1lVG9BcnJheUZyb21Ub2tlbih0b2tlbiwgcGFyc2VkSW5wdXQsIGNvbmZpZyk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmIChjb25maWcuX3N0cmljdCAmJiAhcGFyc2VkSW5wdXQpIHtcbiAgICAgICAgICAgICAgICBnZXRQYXJzaW5nRmxhZ3MoY29uZmlnKS51bnVzZWRUb2tlbnMucHVzaCh0b2tlbik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICAvLyBhZGQgcmVtYWluaW5nIHVucGFyc2VkIGlucHV0IGxlbmd0aCB0byB0aGUgc3RyaW5nXG4gICAgICAgIGdldFBhcnNpbmdGbGFncyhjb25maWcpLmNoYXJzTGVmdE92ZXIgPSBzdHJpbmdMZW5ndGggLSB0b3RhbFBhcnNlZElucHV0TGVuZ3RoO1xuICAgICAgICBpZiAoc3RyaW5nLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIGdldFBhcnNpbmdGbGFncyhjb25maWcpLnVudXNlZElucHV0LnB1c2goc3RyaW5nKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIGNsZWFyIF8xMmggZmxhZyBpZiBob3VyIGlzIDw9IDEyXG4gICAgICAgIGlmIChnZXRQYXJzaW5nRmxhZ3MoY29uZmlnKS5iaWdIb3VyID09PSB0cnVlICYmXG4gICAgICAgICAgICAgICAgY29uZmlnLl9hW0hPVVJdIDw9IDEyICYmXG4gICAgICAgICAgICAgICAgY29uZmlnLl9hW0hPVVJdID4gMCkge1xuICAgICAgICAgICAgZ2V0UGFyc2luZ0ZsYWdzKGNvbmZpZykuYmlnSG91ciA9IHVuZGVmaW5lZDtcbiAgICAgICAgfVxuICAgICAgICAvLyBoYW5kbGUgbWVyaWRpZW1cbiAgICAgICAgY29uZmlnLl9hW0hPVVJdID0gbWVyaWRpZW1GaXhXcmFwKGNvbmZpZy5fbG9jYWxlLCBjb25maWcuX2FbSE9VUl0sIGNvbmZpZy5fbWVyaWRpZW0pO1xuXG4gICAgICAgIGNvbmZpZ0Zyb21BcnJheShjb25maWcpO1xuICAgICAgICBjaGVja092ZXJmbG93KGNvbmZpZyk7XG4gICAgfVxuXG5cbiAgICBmdW5jdGlvbiBtZXJpZGllbUZpeFdyYXAgKGxvY2FsZSwgaG91ciwgbWVyaWRpZW0pIHtcbiAgICAgICAgdmFyIGlzUG07XG5cbiAgICAgICAgaWYgKG1lcmlkaWVtID09IG51bGwpIHtcbiAgICAgICAgICAgIC8vIG5vdGhpbmcgdG8gZG9cbiAgICAgICAgICAgIHJldHVybiBob3VyO1xuICAgICAgICB9XG4gICAgICAgIGlmIChsb2NhbGUubWVyaWRpZW1Ib3VyICE9IG51bGwpIHtcbiAgICAgICAgICAgIHJldHVybiBsb2NhbGUubWVyaWRpZW1Ib3VyKGhvdXIsIG1lcmlkaWVtKTtcbiAgICAgICAgfSBlbHNlIGlmIChsb2NhbGUuaXNQTSAhPSBudWxsKSB7XG4gICAgICAgICAgICAvLyBGYWxsYmFja1xuICAgICAgICAgICAgaXNQbSA9IGxvY2FsZS5pc1BNKG1lcmlkaWVtKTtcbiAgICAgICAgICAgIGlmIChpc1BtICYmIGhvdXIgPCAxMikge1xuICAgICAgICAgICAgICAgIGhvdXIgKz0gMTI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoIWlzUG0gJiYgaG91ciA9PT0gMTIpIHtcbiAgICAgICAgICAgICAgICBob3VyID0gMDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiBob3VyO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgLy8gdGhpcyBpcyBub3Qgc3VwcG9zZWQgdG8gaGFwcGVuXG4gICAgICAgICAgICByZXR1cm4gaG91cjtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGNvbmZpZ0Zyb21TdHJpbmdBbmRBcnJheShjb25maWcpIHtcbiAgICAgICAgdmFyIHRlbXBDb25maWcsXG4gICAgICAgICAgICBiZXN0TW9tZW50LFxuXG4gICAgICAgICAgICBzY29yZVRvQmVhdCxcbiAgICAgICAgICAgIGksXG4gICAgICAgICAgICBjdXJyZW50U2NvcmU7XG5cbiAgICAgICAgaWYgKGNvbmZpZy5fZi5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIGdldFBhcnNpbmdGbGFncyhjb25maWcpLmludmFsaWRGb3JtYXQgPSB0cnVlO1xuICAgICAgICAgICAgY29uZmlnLl9kID0gbmV3IERhdGUoTmFOKTtcbiAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgfVxuXG4gICAgICAgIGZvciAoaSA9IDA7IGkgPCBjb25maWcuX2YubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGN1cnJlbnRTY29yZSA9IDA7XG4gICAgICAgICAgICB0ZW1wQ29uZmlnID0gY29weUNvbmZpZyh7fSwgY29uZmlnKTtcbiAgICAgICAgICAgIGlmIChjb25maWcuX3VzZVVUQyAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgdGVtcENvbmZpZy5fdXNlVVRDID0gY29uZmlnLl91c2VVVEM7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0ZW1wQ29uZmlnLl9mID0gY29uZmlnLl9mW2ldO1xuICAgICAgICAgICAgY29uZmlnRnJvbVN0cmluZ0FuZEZvcm1hdCh0ZW1wQ29uZmlnKTtcblxuICAgICAgICAgICAgaWYgKCF2YWxpZF9faXNWYWxpZCh0ZW1wQ29uZmlnKSkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAvLyBpZiB0aGVyZSBpcyBhbnkgaW5wdXQgdGhhdCB3YXMgbm90IHBhcnNlZCBhZGQgYSBwZW5hbHR5IGZvciB0aGF0IGZvcm1hdFxuICAgICAgICAgICAgY3VycmVudFNjb3JlICs9IGdldFBhcnNpbmdGbGFncyh0ZW1wQ29uZmlnKS5jaGFyc0xlZnRPdmVyO1xuXG4gICAgICAgICAgICAvL29yIHRva2Vuc1xuICAgICAgICAgICAgY3VycmVudFNjb3JlICs9IGdldFBhcnNpbmdGbGFncyh0ZW1wQ29uZmlnKS51bnVzZWRUb2tlbnMubGVuZ3RoICogMTA7XG5cbiAgICAgICAgICAgIGdldFBhcnNpbmdGbGFncyh0ZW1wQ29uZmlnKS5zY29yZSA9IGN1cnJlbnRTY29yZTtcblxuICAgICAgICAgICAgaWYgKHNjb3JlVG9CZWF0ID09IG51bGwgfHwgY3VycmVudFNjb3JlIDwgc2NvcmVUb0JlYXQpIHtcbiAgICAgICAgICAgICAgICBzY29yZVRvQmVhdCA9IGN1cnJlbnRTY29yZTtcbiAgICAgICAgICAgICAgICBiZXN0TW9tZW50ID0gdGVtcENvbmZpZztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGV4dGVuZChjb25maWcsIGJlc3RNb21lbnQgfHwgdGVtcENvbmZpZyk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY29uZmlnRnJvbU9iamVjdChjb25maWcpIHtcbiAgICAgICAgaWYgKGNvbmZpZy5fZCkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGkgPSBub3JtYWxpemVPYmplY3RVbml0cyhjb25maWcuX2kpO1xuICAgICAgICBjb25maWcuX2EgPSBbaS55ZWFyLCBpLm1vbnRoLCBpLmRheSB8fCBpLmRhdGUsIGkuaG91ciwgaS5taW51dGUsIGkuc2Vjb25kLCBpLm1pbGxpc2Vjb25kXTtcblxuICAgICAgICBjb25maWdGcm9tQXJyYXkoY29uZmlnKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjcmVhdGVGcm9tQ29uZmlnIChjb25maWcpIHtcbiAgICAgICAgdmFyIGlucHV0ID0gY29uZmlnLl9pLFxuICAgICAgICAgICAgZm9ybWF0ID0gY29uZmlnLl9mLFxuICAgICAgICAgICAgcmVzO1xuXG4gICAgICAgIGNvbmZpZy5fbG9jYWxlID0gY29uZmlnLl9sb2NhbGUgfHwgbG9jYWxlX2xvY2FsZXNfX2dldExvY2FsZShjb25maWcuX2wpO1xuXG4gICAgICAgIGlmIChpbnB1dCA9PT0gbnVsbCB8fCAoZm9ybWF0ID09PSB1bmRlZmluZWQgJiYgaW5wdXQgPT09ICcnKSkge1xuICAgICAgICAgICAgcmV0dXJuIHZhbGlkX19jcmVhdGVJbnZhbGlkKHtudWxsSW5wdXQ6IHRydWV9KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmICh0eXBlb2YgaW5wdXQgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICBjb25maWcuX2kgPSBpbnB1dCA9IGNvbmZpZy5fbG9jYWxlLnByZXBhcnNlKGlucHV0KTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChpc01vbWVudChpbnB1dCkpIHtcbiAgICAgICAgICAgIHJldHVybiBuZXcgTW9tZW50KGNoZWNrT3ZlcmZsb3coaW5wdXQpKTtcbiAgICAgICAgfSBlbHNlIGlmIChpc0FycmF5KGZvcm1hdCkpIHtcbiAgICAgICAgICAgIGNvbmZpZ0Zyb21TdHJpbmdBbmRBcnJheShjb25maWcpO1xuICAgICAgICB9IGVsc2UgaWYgKGZvcm1hdCkge1xuICAgICAgICAgICAgY29uZmlnRnJvbVN0cmluZ0FuZEZvcm1hdChjb25maWcpO1xuICAgICAgICB9IGVsc2UgaWYgKGlzRGF0ZShpbnB1dCkpIHtcbiAgICAgICAgICAgIGNvbmZpZy5fZCA9IGlucHV0O1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgY29uZmlnRnJvbUlucHV0KGNvbmZpZyk7XG4gICAgICAgIH1cblxuICAgICAgICByZXMgPSBuZXcgTW9tZW50KGNoZWNrT3ZlcmZsb3coY29uZmlnKSk7XG4gICAgICAgIGlmIChyZXMuX25leHREYXkpIHtcbiAgICAgICAgICAgIC8vIEFkZGluZyBpcyBzbWFydCBlbm91Z2ggYXJvdW5kIERTVFxuICAgICAgICAgICAgcmVzLmFkZCgxLCAnZCcpO1xuICAgICAgICAgICAgcmVzLl9uZXh0RGF5ID0gdW5kZWZpbmVkO1xuICAgICAgICB9XG5cbiAgICAgICAgcmV0dXJuIHJlcztcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBjb25maWdGcm9tSW5wdXQoY29uZmlnKSB7XG4gICAgICAgIHZhciBpbnB1dCA9IGNvbmZpZy5faTtcbiAgICAgICAgaWYgKGlucHV0ID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIGNvbmZpZy5fZCA9IG5ldyBEYXRlKCk7XG4gICAgICAgIH0gZWxzZSBpZiAoaXNEYXRlKGlucHV0KSkge1xuICAgICAgICAgICAgY29uZmlnLl9kID0gbmV3IERhdGUoK2lucHV0KTtcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaW5wdXQgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICBjb25maWdGcm9tU3RyaW5nKGNvbmZpZyk7XG4gICAgICAgIH0gZWxzZSBpZiAoaXNBcnJheShpbnB1dCkpIHtcbiAgICAgICAgICAgIGNvbmZpZy5fYSA9IG1hcChpbnB1dC5zbGljZSgwKSwgZnVuY3Rpb24gKG9iaikge1xuICAgICAgICAgICAgICAgIHJldHVybiBwYXJzZUludChvYmosIDEwKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgY29uZmlnRnJvbUFycmF5KGNvbmZpZyk7XG4gICAgICAgIH0gZWxzZSBpZiAodHlwZW9mKGlucHV0KSA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgICAgIGNvbmZpZ0Zyb21PYmplY3QoY29uZmlnKTtcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YoaW5wdXQpID09PSAnbnVtYmVyJykge1xuICAgICAgICAgICA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JheSBvZiBtb21lbnQgb2JqZWN0cyBvciBhbiBhcnJheSwgd2hvc2VcbiAgICAvLyBmaXJzdCBlbGVtZW50IGlzIGFuIGFycmF5IG9mIG1vbWVudCBvYmplY3RzLlxuICAgIGZ1bmN0aW9uIHBpY2tCeShmbiwgbW9tZW50cykge1xuICAgICAgICB2YXIgcmVzLCBpO1xuICAgICAgICBpZiAobW9tZW50cy5sZW5ndGggPT09IDEgJiYgaXNBcnJheShtb21lbnRzWzBdKSkge1xuICAgICAgICAgICAgbW9tZW50cyA9IG1vbWVudHNbMF07XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFtb21lbnRzLmxlbmd0aCkge1xuICAgICAgICAgICAgcmV0dXJuIGxvY2FsX19jcmVhdGVMb2NhbCgpO1xuICAgICAgICB9XG4gICAgICAgIHJlcyA9IG1vbWVudHNbMF07XG4gICAgICAgIGZvciAoaSA9IDE7IGkgPCBtb21lbnRzLmxlbmd0aDsgKytpKSB7XG4gICAgICAgICAgICBpZiAobW9tZW50c1tpXVtmbl0ocmVzKSkge1xuICAgICAgICAgICAgICAgIHJlcyA9IG1vbWVudHNbaV07XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHJlcztcbiAgICB9XG5cbiAgICAvLyBUT0RPOiBVc2UgW10uc29ydCBpbnN0ZWFkP1xuICAgIGZ1bmN0aW9uIG1pbiAoKSB7XG4gICAgICAgIHZhciBhcmdzID0gW10uc2xpY2UuY2FsbChhcmd1bWVudHMsIDApO1xuXG4gICAgICAgIHJldHVybiBwaWNrQnkoJ2lzQmVmb3JlJywgYXJncyk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gbWF4ICgpIHtcbiAgICAgICAgdmFyIGFyZ3MgPSBbXS5zbGljZS5jYWxsKGFyZ3VtZW50cywgMCk7XG5cbiAgICAgICAgcmV0dXJuIHBpY2tCeSgnaXNBZnRlcicsIGFyZ3MpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIER1cmF0aW9uIChkdXJhdGlvbikge1xuICAgICAgICB2YXIgbm9ybWFsaXplZElucHV0ID0gbm9ybWFsaXplT2JqZWN0VW5pdHMoZHVyYXRpb24pLFxuICAgICAgICAgICAgeWVhcnMgPSBub3JtYWxpemVkSW5wdXQueWVhciB8fCAwLFxuICAgICAgICAgICAgcXVhcnRlcnMgPSBub3JtYWxpemVkSW5wdXQucXVhcnRlciB8fCAwLFxuICAgICAgICAgICAgbW9udGhzID0gbm9ybWFsaXplZElucHV0Lm1vbnRoIHx8IDAsXG4gICAgICAgICAgICB3ZWVrcyA9IG5vcm1hbGl6ZWRJbnB1dC53ZWVrIHx8IDAsXG4gICAgICAgICAgICBkYXlzID0gbm9ybWFsaXplZElucHV0LmRheSB8fCAwLFxuICAgICAgICAgICAgaG91cnMgPSBub3JtYWxpemVkSW5wdXQuaG91ciB8fCAwLFxuICAgICAgICAgICAgbWludXRlcyA9IG5vcm1hbGl6ZWRJbnB1dC5taW51dGUgfHwgMCxcbiAgICAgICAgICAgIHNlY29uZHMgPSBub3JtYWxpemVkSW5wdXQuc2Vjb25kIHx8IDAsXG4gICAgICAgICAgICBtaWxsaXNlY29uZHMgPSBub3JtYWxpemVkSW5wdXQubWlsbGlzZWNvbmQgfHwgMDtcblxuICAgICAgICAvLyByZXByZXNlbnRhdGlvbiBmb3IgZGF0ZUFkZFJlbW92ZVxuICAgICAgICB0aGlzLl9taWxsaXNlY29uZHMgPSArbWlsbGlzZWNvbmRzICtcbiAgICAgICAgICAgIHNlY29uZHMgKiAxZTMgKyAvLyAxMDAwXG4gICAgICAgICAgICBtaW51dGVzICogNmU0ICsgLy8gMTAwMCAqIDYwXG4gICAgICAgICAgICBob3VycyAqIDM2ZTU7IC8vIDEwMDAgKiA2MCAqIDYwXG4gICAgICAgIC8vIEJlY2F1c2Ugb2YgZGF0ZUFkZFJlbW92ZSB0cmVhdHMgMjQgaG91cnMgYXMgZGlmZmVyZW50IGZyb20gYVxuICAgICAgICAvLyBkYXkgd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1VUQyA9IHRydWU7XG4gICAgICAgICAgICBpZiAobG9jYWxBZGp1c3QgIT0gbnVsbCkge1xuICAgICAgICAgICAgICAgIHRoaXMuYWRkKGxvY2FsQWRqdXN0LCAnbScpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG9mZnNldCAhPT0gaW5wdXQpIHtcbiAgICAgICAgICAgICAgICBpZiAoIWtlZXBMb2NhbFRpbWUgfHwgdGhpcy5fY2hhbmdlSW5Qcm9ncmVzcykge1xuICAgICAgICAgICAgICAgICAgICBhZGRfc3VidHJhY3RfX2FkZFN1YnRyYWN0KHRoaXMsIGNyZWF0ZV9fY3JlYXRlRHVyYXRpb24oaW5wdXQgLSBvZmZzZXQsICdtJyksIDEsIGZhbHNlKTtcbiAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKCF0aGlzLl9jaGFuZ2VJblByb2dyZXNzKSB7XG4gICAgICAgICAgICAgICAgICAgIHRoaXMuX2NoYW5nZUluUHJvZ3Jlc3MgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICB1dGlsc19ob29rc19faG9va3MudXBkYXRlT2Zmc2V0KHRoaXMsIHRydWUpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLl9jaGFuZ2VJblByb2dyZXNzID0gbnVsbDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl9pc1VUQyA/IG9mZnNldCA6IGdldERhdGVPZmZzZXQodGhpcyk7XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICBmdW5jdGlvbiBnZXRTZXRab25lIChpbnB1dCwga2VlcExvY2FsVGltZSkge1xuICAgICAgICBpZiAoaW5wdXQgIT0gbnVsbCkge1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBpbnB1dCAhPT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgICAgICBpbnB1dCA9IC1pbnB1dDtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdGhpcy51dGNPZmZzZXQoaW5wdXQsIGtlZXBMb2NhbFRpbWUpO1xuXG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiAtdGhpcy51dGNPZmZzZXQoKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIHNldE9mZnNldFRvVVRDIChrZWVwTG9jYWxUaW1lKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnV0Y09mZnNldCgwLCBrZWVwTG9jYWxUaW1lKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzZXRPZmZzZXRUb0xvY2FsIChrZWVwTG9jYWxUaW1lKSB7XG4gICAgICAgIGlmICh0aGlzLl9pc1VUQykge1xuICAgICAgICAgICAgdGhpcy51dGNPZmZzZXQoMCwga2VlcExvY2FsVGltZSk7XG4gICAgICAgICAgICB0aGlzLl9pc1VUQyA9IGZhbHNlO1xuXG4gICAgICAgICAgICBpZiAoa2VlcExvY2FsVGltZSkge1xuICAgICAgICAgICAgICAgIHRoaXMuc3VidHJhY3QoZ2V0RGF0ZU9mZnNldCh0aGlzKSwgJ20nKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBzZXRPZmZzZXRUb1BhcnNlZE9mZnNldCAoKSB7XG4gICAgICAgIGlmICh0aGlzLl90em0pIHtcbiAgICAgICAgICAgIHRoaXMudXRjT2Zmc2V0KHRoaXMuX3R6bSk7XG4gICAgICAgIH0gZWxzZSBpZiAodHlwZW9mIHRoaXMuX2kgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICB0aGlzLnV0Y09mZnNldChvZmZzZXRGcm9tU3RyaW5nKHRoaXMuX2kpKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcztc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cztcblxuICAgICAgICBpZiAoaXNEdXJhdGlvbihpbnB1dCkpIHtcbiAgICAgICAgICAgIGR1cmF0aW9uID0ge1xuICAgICAgICAgICAgICAgIG1zIDogaW5wdXQuX21pbGxpc2Vjb25kcyxcbiAgICAgICAgICAgICAgICBkICA6IGlucHV0Ll9kYXlzLFxuICAgICAgICAgICAgICAgIE0gIDogaW5wdXQuX21vbnRoc1xuICAgICAgICAgICAgfTtcbiAgICAgICAgfSBlbHNlIGlmICh0eXBlb2YgaW5wdXQgPT09ICdudW1iZXInKSB7XG4gICAgICAgICAgICBkdXJhdGlvbiA9IHt9O1xuICAgICAgICAgICAgaWYgKGtleSkge1xuICAgICAgICAgICAgICAgIGR1cmF0aW9uW2tleV0gPSBpbnB1dDtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZHVyYXRpb24ubWlsbGlzZWNvbmRzID0gaW5wdXQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoISEobWF0Y2ggPSBhc3BOZXRSZWdleC5leGVjKGlucHV0KSkpIHtcbiAgICAgICAgICAgIHNpZ24gPSAobWF0Y2hbMV0gPT09ICctJykgPyAtMSA6IDE7XG4gICAgICAgICAgICBkdXJhdGlvbiA9IHtcbiAgICAgICAgICAgICAgICB5ICA6IDAsXG4gICAgICAgICAgICAgICAgZCAgOiB0b0ludChtYXRjaFtEQVRFXSkgICAgICAgICogc2lnbixcbiAgICAgICAgICAgICAgICBoICA6IHRvSW50KG1hdGNoW0hPVVJdKSAgICAgICAgKiBzaWduLFxuICAgICAgICAgICAgICAgIG0gIDogdG9JbnQobWF0Y2hbTUlOVVRFXSkgICAgICAqIHNpZ24sXG4gICAgICAgICAgICAgICAgcyAgOiB0b0ludChtYXRjaFtTRUNPTkRdKSAgICAgICogc2lnbixcbiAgICAgICAgICAgICAgICBtcyA6IHRvSW50KG1hdGNoW01JTExJU0VDT05EXSkgKiBzaWduXG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2UgaWYgKCEhKG1hdGNoID0gY3JlYXRlX19pc29SZWdleC5leGVjKGlucHV0KSkpIHtcbiAgICAgICAgICAgIHNpZ24gPSAobWF0Y2hbMV0gPT09ICctJykgPyAtMSA6IDE7XG4gICAgICAgICAgICBkdXJhdGlvbiA9IHtcbiAgICAgICAgICAgICAgICB5IDogcGFyc2VJc28obWF0Y2hbMl0sIHNpZ24pLFxuICAgICAgICAgICAgICAgIE0gOiBwYXJzZUlzbyhtYXRjaFszXSwgc2lnbiksXG4gICAgICAgICAgICAgICAgZCA6IHBhcnNlSXNvKG1hdGNoWzRdLCBzaWduKSxcbiAgICAgICAgICAgICAgICBoIDogcGFyc2VJc28obWF0Y2hbNV0sIHNpZ24pLFxuICAgICAgICAgICAgICAgIG0gOiBwYXJzZUlzbyhtYXRjaFs2XSwgc2lnbiksXG4gICAgICAgICAgICAgICAgcyA6IHBhcnNlSXNvKG1hdGNoWzddLCBzaWduKSxcbiAgICAgICAgICAgICAgICB3IDogcGFyc2VJc28obWF0Y2hbOF0sIHNpZ24pXG4gICAgICAgICAgICB9O1xuICAgICAgICB9IGVsc2UgaWYgKGR1cmF0aW9uID09IG51bGwpIHsvLyBjaGVja3MgZm9yIG51bGwgb3IgdW5kZWZpbmVkXG4gICAgICAgICAgICBkdXJhdGlvbiA9IHt9O1xuICAgICAgICB9IGVsc2UgaWYgKHR5cGVvZiBkdXJhdGlvbiA9PT0gJ29iamVjdCcgJiYgKCdmcm9tJyBpbiBkdXJhdGlvbiB8fCAndG8nIGluIGR1cmF0aW9uKSkge1xuICAgICAgICAgICAgZGlmZlJlcyA9IG1vbWVudHNEaWZmZXJlbmNlKGxvY2FsX19jcmVhdGVMb2NhbChkdXJhdGlvbi5mcm9tKSwgbG9jYWxfX2NyZWF0ZUxvY2FsKGR1cmF0aW9uLnRvKSk7XG5cbiAgICAgICAgICAgIGR1cmF0aW9uID0ge307XG4gICAgICAgICAgICBkdXJhdGlvbi5tcyA9IGRpZm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c2UubW9udGgoKSArXG4gICAgICAgICAgICAob3RoZXIueWVhcigpIC0gYmFzZS55ZWFyKCkpICogMTI7XG4gICAgICAgIGlmIChiYXNlLmNsb25lKCkuYWRkKHJlcy5tb250aHMsICdNJykuaXNBZnRlcihvdGhlcikpIHtcbiAgICAgICAgICAgIC0tcmVzLm1vbnRocztcbiAgICAgICAgfVxuXG4gICAgICAgIHJlcy5taWxsaXNlY29uZHMgPSArb3RoZXIgLSArKGJhc2UuY2xvbmUoKS5hZGQocmVzLm1vbnRocywgJ00nKSk7XG5cbiAgICAgICAgcmV0dXJuIHJlcztcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBtb21lbnRzRGlmZmVyZW5jZShiYXNlLCBvdGhlcikge1xuICAgICAgICB2YXIgcmVzO1xuICAgICAgICBvdGhlciA9IGNsb25lV2l0aE9mZnNldChvdGhlciwgYmFzZSk7XG4gICAgICAgIGlmIChiYXNlLmlzQmVmb3JlKG90aGVyKSkge1xuICAgICAgICAgICAgcmVzID0gcG9zaXRpdmVNb21lbnRzRGlmZmVyZW5jZShiYXNlLCBvdGhlcik7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICByZXMgPSBwb3NpdGl2ZU1vbWVudHNEaWZmZXJlbmNlKG90aGVyLCBiYXNlKTtcbiAgICAgICAgICAgIHJlcy5taWxsaXNlY29uZHMgPSAtcmVzLm1pbGxpc2Vjb25kcztcbiAgICAgICAgICAgIHJlcy5tb250aHMgPSAtcmVzLm1vbnRocztcbiAgICAgICAgfVxuXG4gICAgICAgIHJldHVybiByZXM7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gY3JlYXRlQWRkZXIoZGlyZWN0aW9uLCBuYW1lKSB7XG4gICAgICAgIHJldHVybiBmdW5jdGlvbiAodmFsLCBwZXJpb2QpIHtcbiAgICAgICAgICAgIHZhciBkdXIsIHRtcDtcbiAgICAgICAgICAgIC8vaW52ZXJ0IHRoZSBhcmd1bWVudHMsIGJ1dCBjb21wbGFpb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AgICBpZiAodW5pdHMgPT09ICdtaWxsaXNlY29uZCcpIHtcbiAgICAgICAgICAgIGlucHV0ID0gaXNNb21lbnQoaW5wdXQpID8gaW5wdXQgOiBsb2NhbF9fY3JlYXRlTG9jYWwoaW5wdXQpO1xuICAgICAgICAgICAgcmV0dXJuICt0aGlzID09PSAraW5wdXQ7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBpbnB1dE1zID0gK2xvY2FsX19jcmVhdGVMb2NhbChpbnB1dCk7XG4gICAgICAgICAgICByZXR1cm4gKyh0aGlzLmNsb25lKCkuc3RhcnRPZih1bml0cykpIDw9IGlucHV0TXMgJiYgaW5wdXRNcyA8PSArKHRoaXMuY2xvbmUoKS5lbmRPZih1bml0cykpO1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gYWJzRmxvb3IgKG51bWJlcikge1xuICAgICAgICBpZiAobnVtYmVyIDwgMCkge1xuICAgICAgICAgICAgcmV0dXJuIE1hdGguY2VpbChudW1iZXIpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIE1hdGguZmxvb3IobnVtYmVyKTtcbiAgICAgICAgfVxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGRpZmYgKGlucHV0LCB1bml0cywgYXNGbG9hdCkge1xuICAgICAgICB2YXIgdGhhdCA9IGNsb25lV2l0aE9mZnNldChpbnB1dCwgdGhpcyksXG4gICAgICAgICAgICB6b25lRGVsdGEgPSAodGhhdC51dGNPZmZzZXQoKSAtIHRoaXMudXRjT2Zmc2V0KCkpICogNmU0LFxuICAgICAgICAgICAgZGVsdGEsIG91dHB1dDtcblxuICAgICAgICB1bml0cyA9IG5vcm1hbGl6ZVVuaXRzKHVuaXRzKTtcblxuICAgICAgICBpZiAodW5pdHMgPT09ICd5ZWFyJyB8fCB1bml0cyA9PT0gJ21vbnRoJyB8fCB1bml0cyA9PT0gJ3F1YXJ0ZXInKSB7XG4gICAgICAgICAgICBvdXRwdXQgPSBtb250aERpZmYodGhpcywgdGhhdCk7XG4gICAgICAgICAgICBpZiAodW5pdHMgPT09ICdxdWFydGVyJykge1xuICAgICAgICAgICAgICAgIG91dHB1dCA9IG91dHB1dCAvIDM7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHVuaXRzID09PSAneWVhcicpIHtcbiAgICAgICAgICAgICAgICBvdXRwdXQgPSBvdXRwdXQgLyAxMjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIGRlbHRhID0gdGhpcyAtIHRoYXQ7XG4gICAgICAgICAgICBvdXRwdXQgPSB1bml0cyA9PT0gJ3NlY29uZCcgPyBkZWx0YSAvIDFlMyA6IC8vIDEwMDBcbiAgICAgICAgICAgICAgICB1bml0cyA9PT0gJ21pbnV0ZScgPyBkZWx0YSAvIDZlNCA6IC8vIDEwMDAgKiA2MFxuICAgICAgICAgICAgICAgIHVuaXRzID09PSAnaG91cicgPyBkZWx0YSAvIDM2ZTUgOiAvLyAxMDAwICogNjAgKiA2MFxuICAgICAgICAgICAgICAgIHVuaXRzID09PSAnZGF5JyA/IChkZWx0YSAtIHpvbmVEZWx0YSkgLyA4NjRlNSA6IC8vIDEwMDAgKiA2MCAqIDYwICogMjQsIG5lZ2F0ZSBkc3RcbiAgICAgICAgICAgICAgICB1bml0cyA9PT0gJ3dlZWsnID8gKGRlbHRhIC0gem9uZURlbHRhKSAvIDYwNDhlNSA6IC8vIDEwMDAgKiA2MCAqIDYwICogMjQgKiA3LCBuZWdhdGUgZHN0XG4gICAgICAgICAgICAgICAgZGVsdGE7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGFzRmxvYXQgPyBvdXRwdXQgOiBhYnNGbG9vcihvdXRwdXQpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIG1vbnRoRGlmZiAoYSwgYikge1xuICAgICAgICAvLyBkaWZmZXJlbmNlIGluIG1vbnRoc1xuICAgICAgICB2YXIgd2hvbGVNb250a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zLlxuICAgICAgICBzd2l0Y2ggKHVuaXRzKSB7XG4gICAgICAgIGNhc2UgJ3llYXInOlxuICAgICAgICAgICAgdGhpcy5tb250aCgwKTtcbiAgICAgICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgICAgY2FzZSAncXVhcnRlcic6XG4gICAgICAgIGNhc2UgJ21vbnRoJzpcbiAgICAgICAgICAgIHRoaXMuZGF0ZSgxKTtcbiAgICAgICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgICAgY2FzZSAnd2Vlayc6XG4gICAgICAgIGNhc2UgJ2lzb1dlZWsnOlxuICAgICAgICBjYXNlICdkYXknOlxuICAgICAgICAgICAgdGhpcy5ob3VycygwKTtcbiAgICAgICAgICAgIC8qIGZhbGxzIHRocm91Z2ggKi9cbiAgICAgICAgY2FzZSAnaG91cic6XG4gICAgICAgICAgICB0aGlzLm1pbnV0ZXMoMCk7XG4gICAgICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICAgIGNhc2UgJ21pbnV0ZSc6XG4gICAgICAgICAgICB0aGlzLnNlY29uZHMoMCk7XG4gICAgICAgICAgICAvKiBmYWxscyB0aHJvdWdoICovXG4gICAgICAgIGNhc2UgJ3NlY29uZCc6XG4gICAgICAgICAgICB0aGlzLm1pbGxpc2Vjb25kcygwKTtcbiAgICAgICAgfVxuXG4gICAgICAgIC8vIHdlZWtzIGFyZSBhIHNwZWNpYWwgY2FzZVxuICAgICAgICBpZiAodW5pdHMgPT09ICd3ZWVrJykge1xuICAgICAgICAgICAgdGhpcy53ZWVrZGF5KDApO1xuICAgICAgICB9XG4gICAgICAgIGlmICh1bml0cyA9PT0gJ2lzb1dlZWsnKSB7XG4gICAgICAgICAgICB0aGlzLmlzb1dlZWtkYXkoMSk7XG4gICAgICAgIH1cblxuICAgICAgICAvLyBxdWFydGVycyBhcmUgYWxzbyBzcGVjaWFsXG4gICAgICAgIGlmICh1bml0cyA9PT0gJ3F1YXJ0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3Byb3RvLmxvY2FsZSAgICAgICA9IGxvY2FsZTtcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLmxvY2FsZURhdGEgICA9IGxvY2FsZURhdGE7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5tYXggICAgICAgICAgPSBwcm90b3R5cGVNYXg7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5taW4gICAgICAgICAgPSBwcm90b3R5cGVNaW47XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5wYXJzaW5nRmxhZ3MgPSBwYXJzaW5nRmxhZ3M7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5zZXQgICAgICAgICAgPSBnZXRTZXQ7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5zdGFydE9mICAgICAgPSBzdGFydE9mO1xuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8uc3VidHJhY3QgICAgID0gYWRkX3N1YnRyYWN0X19zdWJ0cmFjdDtcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLnRvQXJyYXkgICAgICA9IHRvQXJyYXk7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by50b0RhdGUgICAgICAgPSB0b0RhdGU7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by50b0lTT1N0cmluZyAgPSBtb21lbnRfZm9ybWF0X190b0lTT1N0cmluZztcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLnRvSlNPTiAgICAgICA9IG1vbWVudF9mb3JtYXRfX3RvSVNPU3RyaW5nO1xuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8udG9TdHJpbmcgICAgID0gdG9TdHJpbmc7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by51bml4ICAgICAgICAgPSB1bml4O1xuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8udmFsdWVPZiAgICAgID0gdG9fdHlwZV9fdmFsdWVPZjtcblxuICAgIC8vIFllYXJcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLnllYXIgICAgICAgPSBnZXRTZXRZZWFyO1xuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8uaXNMZWFwWWVhciA9IGdldElzTGVhcFllYXI7XG5cbiAgICAvLyBXZWVrIFllYXJcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLndlZWtZZWFyICAgID0gZ2V0U2V0V2Vla1llYXI7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5pc29XZWVrWWVhciA9IGdldFNldElTT1dlZWtZZWFyO1xuXG4gICAgLy8gUXVhcnRlclxuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8ucXVhcnRlciA9IG1vbWVudFByb3RvdHlwZV9fcHJvdG8ucXVhcnRlcnMgPSBnZXRTZXRRdWFydGVyO1xuXG4gICAgLy8gTW9udGhcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLm1vbnRoICAgICAgID0gZ2V0U2V0TW9udGg7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5kYXlzSW5Nb250aCA9IGdldERheXNJbk1vbnRoO1xuXG4gICAgLy8gV2Vla1xuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8ud2VlayAgICAgICAgICAgPSBtb21lbnRQcm90b3R5cGVfX3Byb3RvLndlZWtzICAgICAgICA9IGdldFNldFdlZWs7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5pc29XZWVrICAgICAgICA9IG1vbWVudFByb3RvdHlwZV9fcHJvdG8uaXNvV2Vla3MgICAgID0gZ2V0U2V0SVNPV2VlaztcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLndlZWtzSW5ZZWFyICAgID0gZ2V0V2Vla3NJblllYXI7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5pc29XZWVrc0luWWVhciA9IGdldElTT1dlZWtzSW5ZZWFyO1xuXG4gICAgLy8gRGF5XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5kYXRlICAgICAgID0gZ2V0U2V0RGF5T2ZNb250aDtcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLmRheSAgICAgICAgPSBtb21lbnRQcm90b3R5cGVfX3Byb3RvLmRheXMgICAgICAgICAgICAgPSBnZXRTZXREYXlPZldlZWs7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by53ZWVrZGF5ICAgID0gZ2V0U2V0TG9jYWxlRGF5T2ZXZWVrO1xuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8uaXNvV2Vla2RheSA9IGdldFNldElTT0RheU9mV2VlaztcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLmRheU9mWWVhciAgPSBnZXRTZXREYXlPZlllYXI7XG5cbiAgICAvLyBIb3VyXG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by5ob3VyID0gbW9tZW50UHJvdG90eXBlX19wcm90by5ob3VycyA9IGdldFNldEhvdXI7XG5cbiAgICAvLyBNaW51dGVcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLm1pbnV0ZSA9IG1vbWVudFByb3RvdHlwZV9fcHJvdG8ubWludXRlcyA9IGdldFNldE1pbnV0ZTtcblxuICAgIC8vIFNlY29uZFxuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8uc2Vjb25kID0gbW9tZW50UHJvdG90eXBlX19wcm90by5zZWNvbmRzID0gZ2V0U2V0U2Vjb25kO1xuXG4gICAgLy8gTWlsbGlzZWNvbmRcbiAgICBtb21lbnRQcm90b3R5cGVfX3Byb3RvLm1pbGxpc2Vjb25kID0gbW9tZW50UHJvdG90eXBlX19wcm90by5taWxsaXNlY29uZHMgPSBnZXRTZXRNaWxsaXNlY29uZDtcblxuICAgIC8vIE9mZnNldFxuICAgIG1vbWVudFByb3RvdHlwZV9fcHJvdG8udXRjT2Zmc2V0ICAgICAgICAgICAgPSBnZXRTZXRPZmZzZXQ7XG4gICAgbW9tZW50UHJvdG90eXBlX19wcm90by51dGMgICAgICAgIC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TU18RER8ZGRkZC9nLCBmdW5jdGlvbiAodmFsKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHZhbC5zbGljZSgxKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgdGhpcy5fbG9uZ0RhdGVGb3JtYXRba2V5XSA9IG91dHB1dDtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gb3V0cHV0O1xuICAgIH1cblxuICAgIHZhciBkZWZhdWx0SW52YWxpZERhdGUgPSAnSW52YWxpZCBkYXRlJztcblxuICAgIGZ1bmN0aW9uIGludmFsaWREYXRlICgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX2ludmFsaWREYXRlO1xuICAgIH1cblxuICAgIHZhciBkZWZhdWx0T3JkaW5hbCA9ICclZCc7XG4gICAgdmFyIGRlZmF1bHRPcmRpbmFsUGFyc2UgPSAvXFxkezEsMn0vO1xuXG4gICAgZnVuY3Rpb24gb3JkaW5hbCAobnVtYmVyKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9vcmRpbmFsLnJlcGxhY2UoJyVkJywgbnVtYmVyKTtcbiAgICB9XG5cbiAgICBmdW5jdGlvbiBwcmVQYXJzZVBvc3RGb3JtYXQgKHN0cmluZykge1xuICAgICAgICByZXR1cm4gc3RyaW5nO1xuICAgIH1cblxuICAgIHZhciBkZWZhdWx0UmVsYXRpdmVUaW1lID0ge1xuICAgICAgICBmdXR1cmUgOiAnaW4gJXMnLFxuICAgICAgICBwYXN0ICAgOiAnJXMgYWdvJyxcbiAgICAgICAgcyAgOiAnYSBmZXcgc2Vjb25kcycsXG4gICAgICAgIG0gIDogJ2EgbWludXRlJyxcbiAgICAgICAgbW0gOiAnJWQgbWludXRlcycsXG4gICAgICAgIGggIDogJ2FuIGhvdXInLFxuICAgICAgICBoaCA6ICclZCBob3VycycsXG4gICAgICAgIGQgIDogJ2EgZGF5JyxcbiAgICAgICAgZGQgOiAnJWQgZGF5cycsXG4gICAgICAgIE0gIDogJ2EgbW9udGgn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dmFsdWUpIHtcbiAgICAgICAgcmV0dXJuIGR1cmF0aW9uX2FkZF9zdWJ0cmFjdF9fYWRkU3VidHJhY3QodGhpcywgaW5wdXQsIHZhbHVlLCAtMSk7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gYnViYmxlICgpIHtcbiAgICAgICAgdmFyIG1pbGxpc2Vjb25kcyA9IHRoaXMuX21pbGxpc2Vjb25kcztcbiAgICAgICAgdmFyIGRheXMgICAgICAgICA9IHRoaXMuX2RheXM7XG4gICAgICAgIHZhciBtb250aHMgICAgICAgPSB0aGlzLl9tb250aHM7XG4gICAgICAgIHZhciBkYXRhICAgICAgICAgPSB0aGlzLl9kYXRhO1xuICAgICAgICB2YXIgc2Vjb25kcywgbWludXRlcywgaG91cnMsIHllYXJzID0gMDtcblxuICAgICAgICAvLyBUaGUgZm9sbG93aW5nIGNvZGUgYnViYmxlcyB1cCB2YWx1ZXMsIHNlZSB0aGUgdGVzdHMgZm9yXG4gICAgICAgIC8vIGV4YW1wbGVzIG9mIHdoYXQgdGhhdCBtZWFucy5cbiAgICAgICAgZGF0YS5taWxsaXNlY29uZHMgPSBtaWxsaXNlY29uZHMgJSAxMDAwO1xuXG4gICAgICAgIHNlY29uZHMgICAgICAgICAgID0gYWJzRmxvb3IobWlsbGlzZWNvbmRzIC8gMTAwMCk7XG4gICAgICAgIGRhdGEuc2Vjb25kcyAgICAgID0gc2Vjb25kcyAlIDYwO1xuXG4gICAgICAgIG1pbnV0ZXMgICAgICAgICAgID0gYWJzRmxvb3Ioc2Vjb25kcyAvIDYwKTtcbiAgICAgICAgZGF0YS5taW51dGVzICAgICAgPSBtaW51dGVzICUgNjA7XG5cbiAgICAgICAgaG91cnMgICAgICAgICAgICAgPSBhYnNGbG9vcihtaW51dGVzIC8gNjApO1xuICAgICAgICBkYXRhLmhvdXJzICAgICAgICA9IGhvdXJzICUgMjQ7XG5cbiAgICAgICAgZGF5cyArPSBhYnNGbG9vcihob3VycyAvIDI0KTtcblxuICAgIC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KSArIGFic0Zsb29yKHllYXJzIC8gNDAwKTtcbiAgICAgICAgcmV0dXJuIHllYXJzICogMTQ2MDk3IC8gNDAwO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIGFzICh1bml0cykge1xuICAgICAgICB2YXIgZGF5cztcbiAgICAgICAgdmFyIG1vbnRocztcbiAgICAgICAgdmFyIG1pbGxpc2Vjb25kcyA9IHRoaXMuX21pbGxpc2Vjb25kcztcblxuICAgICAgICB1bml0cyA9IG5vcm1hbGl6ZVVuaXRzKHVuaXRzKTtcblxuICAgICAgICBpZiAodW5pdHMgPT09ICdtb250aCcgfHwgdW5pdHMgPT09ICd5ZWFyJykge1xuICAgICAgICAgICAgZGF5cyAgID0gdGhpcy5fZGF5cyAgICsgbWlsbGlzZWNvbmRzIC8gODY0ZTU7XG4gICAgICAgICAgICBtb250aHMgPSB0aGlzLl9tb250aHMgKyBkYXlzVG9ZZWFycyhkYXlzKSAqIDEyO1xuICAgICAgICAgICAgcmV0dXJuIHVuaXRzID09PSAnbW9udGgnID8gbW9udGhzIDogbW9udGhzIC8gMTI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAvLyBoYW5kbGUgbWlsbGlzZWNvbmRzIHNlcGFyYXRlbHkgYmVjYXVzZSBvZiBmbG9hdGluZyBwb2ludCBtYXRoIGVycm9ycyAoaXNzdWUgIzE4NjcpXG4gICAgICAgICAgICBkYXlzID0gdGhpcy5fZGF5cyArIE1hdGgucm91bmQoeWVhcnNUb0RheXModGhpcy5fbW9udGhzIC8gMTIpKTtcbiAgICAgICAgICAgIHN3aXRjaCAodW5pdHMpIHtcbiAgICAgICAgICAgICAgICBjYXNlICd3ZWVrJyAgIDogcmV0dXJuIGRheXMgLyA3ICAgICArIG1pbGxpc2Vjb25kcyAvIDYwNDhlNTtcbiAgICAgICAgICAgICAgICBjYXNlICdkYXknICAgIDogcmV0dXJuIGRheXMgICAgICAgICArIG1pbGxpc2Vjb25kcyAvIDg2NGU1O1xuICAgICAgICAgICAgICAgIGNhc2UgJ2hvdXInICAgOiByZXR1cm4gZGF5cyAqIDI0ICAgICsgbWlsbGlzZWNvbmRzIC8gMzZlNTtcbiAgICAgICAgICAgICAgICBjYXNlICdtaW51dGUnIDogcmV0dXJuIGRheXMgKiAxNDQwICArIG1pbGxpc2Vjb25kcyAvIDZlNDtcbiAgICAgICAgICAgICAgICBjYXNlICdzZWNvbmQnIDogcmV0dXJuIGRheXMgKiA4NjQwMCArIG1pbGxpc2Vjb25kcyAvIDEwMDA7XG4gICAgICAgICAgICAgICAgLy8gTWF0aC5mbG9vciBwcmV2ZW50cyBmbG9hdGluZyBwb2ludCBtYXRoIGVycm9ycyBoZXJlXG4gICAgICAgICAgICAgICAgY2FzZSAnbWlsbGlzZWNvbmQnOiByZXR1cm4gTWF0aC5mbG9vcihkYXlzICogODY0ZTUpICsgbWlsbGlzZWNvbmRzO1xuICAgICAgICAgICAgICAgIGRlZmF1bHQ6IHRocm93IG5ldyBFcnJvcignVW5rbm93biB1bml0ICcgKyB1bml0cyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG5cbiAgICAvLyBUT0RPOiBVc2UgdGhpcy5hcygnbXMnKT9cbiAgICBmdW5jdGlvbiBkdXJhdGlvbl9hc19fdmFsdWVPZiAoKSB7XG4gICAgICAgIHJldHVybiAoXG4gICAgICAgICAgICB0aGlzLl9taWxsaXNlY29uZHMgK1xuICAgICAgICAgICAgdGhpcy5fZGF5cyAqIDg2NGU1ICtcbiAgICAgICAgICAgICh0aGlzLl9tb250aHMgJSAxMikgKiAyNTkyZTYgK1xuICAgICAgICAgICAgdG9JbnQodGhpcy5fbW9udGhzIC8gMTIpICogMzE1MzZlNlxuICAgICAgICApO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIG1ha2VBcyAoYWxpYXMpIHtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uICgpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmFzKGFsaWFzKTtc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aW9uKS5hYnMoKTtcbiAgICAgICAgdmFyIHNlY29uZHMgID0gcm91bmQoZHVyYXRpb24uYXMoJ3MnKSk7XG4gICAgICAgIHZhciBtaW51dGVzICA9IHJvdW5kKGR1cmF0aW9uLmFzKCdtJykpO1xuICAgICAgICB2YXIgaG91cnMgICAgPSByb3VuZChkdXJhdGlvbi5hcygnaCcpKTtcbiAgICAgICAgdmFyIGRheXMgICAgID0gcm91bmQoZHVyYXRpb24uYXMoJ2QnKSk7XG4gICAgICAgIHZhciBtb250aHMgICA9IHJvdW5kKGR1cmF0aW9uLmFzKCdNJykpO1xuICAgICAgICB2YXIgeWVhcnMgICAgPSByb3VuZChkdXJhdGlvbi5hcygneScpKTtcblxuICAgICAgICB2YXIgYSA9IHNlY29uZHMgPCB0aHJlc2hvbGRzLnMgJiYgWydzJywgc2Vjb25kc10gIHx8XG4gICAgICAgICAgICAgICAgbWludXRlcyA9PT0gMSAgICAgICAgICAmJiBbJ20nXSAgICAgICAgICAgfHxcbiAgICAgICAgICAgICAgICBtaW51dGVzIDwgdGhyZXNob2xkcy5tICYmIFsnbW0nLCBtaW51dGVzXSB8fFxuICAgICAgICAgICAgICAgIGhvdXJzICAgPT09IDEgICAgICAgICAgJiYgWydoJ10gICAgICAgICAgIHx8XG4gICAgICAgICAgICAgICAgaG91cnMgICA8IHRocmVzaG9sZHMuaCAmJiBbJ2hoJywgaG91cnNdICAgfHxcbiAgICAgICAgICAgICAgICBkYXlzICAgID09PSAxICAgICAgICAgICYmIFsnZCddICAgICAgICAgICB8fFxuICAgICAgICAgICAgICAgIGRheXMgICAgPCB0aHJlc2hvbGRzLmQgJiYgWydkZCcsIGRheXNdICAgIHx8XG4gICAgICAgICAgICAgICAgbW9udGhzICA9PT0gMSAgICAgICAgICAmJiBbJ00nXSAgICAgICAgICAgfHxcbiAgICAgICAgICAgICAgICBtb250aHMgIDwgdGhyZXNob2xkcy5NICYmIFsnTU0nLCBtb250aHNdICB8fFxuICAgICAgICAgICAgICAgIHllYXJzICAgPT09IDEgICAgICAgICAgJiYgWyd5J10gICAgICAgICAgIHx8IFsneXknLCB5ZWFyc107XG5cbiAgICAgICAgYVsyXSA9IHdpdGhvdXRTdWZmaXg7XG4gICAgICAgIGFbM10gPSArcG9zTmVnRHVyYXRpb24gPiAwO1xuICAgICAgICBhWzRdID0gbG9jYWxlO1xuICAgICAgICByZXR1cm4gc3Vic3RpdHV0ZVRpbWVBZ28uYXBwbHkobnVsbCwgYSk7XG4gICAgfVxuXG4gICAgLy8gVGhpcyBmdW5jdGlvbiBhbGxvd3MgeW91IHRvIHNldCBhIHRocmVzaG9sZCBmb3IgcmVsYXRpdmUgdGltZSBzdHJpbmdzXG4gICAgZnVuY3Rpb24gZHVyYXRpb25faHVtYW5pemVfX2dldFNldFJlbGF0aXZlVGltZVRocmVzaG9sZCAodGhyZXNob2xkLCBsaW1pdCkge1xuICAgICAgICBpZiAodGhyZXNob2xkc1t0aHJlc2hvbGRdID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAobGltaXQgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgcmV0dXJuIHRocmVzaG9sZHNbdGhyZXNob2xkXTtcbiAgICAgICAgfVxuICAgICAgICB0aHJlc2hvbGRzW3RocmVzaG9sZF0gPSBsaW1pdDtcbiAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgfVxuXG4gICAgZnVuY3Rpb24gaHVtYW5pemUgKHdpdGhTdWZmaXgpIHtcbiAgICAgICAgdmFyIGxvY2FsZSA9IHRoaXMubG9jYWxlRGF0YSgpO1xuICAgICAgICB2YXIgb3V0cHV0ID0gZHVyYXRpb25faHVtYW5pemVfX3JlbGF0aXZlVGltZSh0aGlzLCAhd2l0aFN1ZmZpeCwgbG9jYWxlKTtcblxuICAgICAgICBpZiAod2l0aFN1ZmZpeCkge1xuICAgICAgICAgICAgb3V0cHV0ID0gbG9jYWxlLnBhc3RGdXR1cmUoK3RoaXMsIG91dHB1dCk7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gbG9jYWxlLnBvc3Rmb3JtYXQob3V0cHV0KTtcbiAgICB9XG5cbiAgICB2YXIgaXNvX3N0cmluZ19fYWJzID0gTWF0aC5hYnM7XG5cbiAgICBmdW5jdGlvbiBpc29fc3RyaW5nX190b0lTT1N0cmluZygpIHtcbiAgICAgICAgLy8gaW5zcGlyZWQgYnkgaHR0cHM6Ly9naXRodWIuY29tL2RvcmRpbGxlL21vbWVudC1pc29kdXJhdGlvbi9ibG9iL21hc3Rlci9tb21lbnQuaXNvZHVyYXRpb24uanNcbiAgICAgICAgdmFyIFkgPSBpc29fc3RyaW5nX19hYnModGhpcy55ZWFycygpKTtcbiAgICAgICAgdmFyIE0gPSBpc29fc3RyaW5nX19hYnModGhpcy5tb250aHMoKSk7XG4gICAgICAgIHZhciBEID0gaXNvX3N0cmluZ19fYWJzKHRoaXMuZGF5cygpKTtcbiAgICAgICAgdmFyIGggPSBpc29fc3RyaW5nX19hYnModGhpcy5ob3VycygpKTtcbiAgICAgICAgdmFyIG0gPSBpc29fc3RyaW5nX19hYnModGhpcy5taW51dGVzKCkpO1xuICAgICAgICB2YXIgcyA9IGlzb19zdHJpbmdfX2Ficyh0aGlzLnNlY29uZHMoKSArIHRoaXMubWlsbGlzZWNvbmRzKCkgLyAxMDAwKTtcbiAgICAgICAgdmFyIHRvdGFsID0gdGhpcy5hc1NlY29uZHMoKTtcblxuICAgICAgICBpZiAoIXRvdGFsKSB7XG4gICAgICAgICAgICAvLyB0aGlzIGlzIHRoZSBzYW1lIGFzIEMjJ3MgKE5vZGEpIGFuZCBweXRob24gKGlzb2RhdGUpLi4uXG4gICAgICAgICAgICAvLyBidXQgbm90IG90aGVyIEpTIChnb29nLmRhdGUpXG4gICAgICAgICAgICByZXR1cm4gJ1AwRCc7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gKHRvdGFsIDwgMCA/ICctJyA6ICcnKSArXG4gICAgICAgICAgICAnUCcgK1xuICAgICAgICAgICAgKFkgPyBZICsgJ1knIDogJycpICtcbiAgICAgICAgICAgIChNID8gTSArICdNJyA6ICcnKSArXG4gICAgICAgICAgICAoRCA/IEQgKyAnRCcgOiAnJykgK1xuICAgICAgICAgICAgKChoIHx8IG0gfHwgcykgPyAnVCcgOiAnJykgK1xuICAgICAgICAgICAgKGggPyBoICsgJ0gnIDogJycpICtcbiAgICAgICAgICAgIChtID8gbSArICdNJyA6ICcnKSArXG4gICAgICAgICAgICAocyA/IHMgKyAnUycgOiAnJyk7XG4gICAgfVxuXG4gICAgdmFyIGR1cmF0aW9uX3Byb3RvdHlwZV9fcHJvdG8gPSBEdXJhdGlvbi5wcm90b3R5cGU7XG5cbiAgICBkdXJhdGlvbl9wcm90b3R5cGVfX3Byb3RvLmFicyAgICAgICAgICAgID0gZHVyYXRpb25fYWJzX19hYnM7XG4gICAgZHVyYXRpb25fcHJvdG90eXBlX19wcm90by5hZGQgICAgICAgICAgICA9IGR1cmF0aW9uX2FkZF9zdWJ0cmFjdF9fYWRkO1xuICAgIGR1cmF0aW9uX3Byb3RvdHlwZV9fcHJvdG8uc3VidHJhY3QgICAgICAgPSBkdXJhdGlvbl9hZGRfc3VidHJhY3RfX3N1YnRyYWN0O1xuICAgIGR1cmF0aW9uX3Byb3RvdHlwZV9fcHJvdG8uYXMgICAgICAgICAgICAgPSBhcztcbiAgICBkdXJhdGlvbl9wcm90b3R5cGVfX3Byb3RvLmFzTWlsbGlzZWNvbmRzID0gYXNNaWxsaXNlY29uZHM7XG4gICAgZHVyYXRpb25fcHJvdG90eXBlX19wcm90by5hc1NlY29uZHMgICAgICA9IGFzU2Vjb25kcztcbiAgICBkdXJhdGlvbl9wcm90b3R5cGVfX3Byb3RvLmFzTWludXRlcyAgICAgID0gYXNNaW51dGVzO1xuICAgIGR1cmF0aW9uX3Byb3RvdHlwZV9fcHJvdG8uYXNIb3VycyAgICAgICAgPSBhc0hvd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XhUb2tlbigneCcsIG1hdGNoU2lnbmVkKTtcbiAgICBhZGRSZWdleFRva2VuKCdYJywgbWF0Y2hUaW1lc3RhbXApO1xuICAgIGFkZFBhcnNlVG9rZW4oJ1gnLCBmdW5jdGlvbiAoaW5wdXQsIGFycmF5LCBjb25maWcpIHtcbiAgICAgICAgY29uZmlnLl9kID0gbmV3IERhdGUocGFyc2VGbG9hdChpbnB1dCwgMTApICogMTAwMCk7XG4gICAgfSk7XG4gICAgYWRkUGFyc2VUb2tlbigneCcsIGZ1bmN0aW9uIChpbnB1dCwgYXJyYXksIGNvbmZpZykge1xuICAgICAgICBjb25maWcuX2QgPSBuZXcgRGF0ZSh0b0ludChpbnB1dCkpO1xuICAgIH0pO1xuXG4gICAgLy8gU2lkZSBlZmZlY3QgaW1wb3J0c1xuXG5cbiAgICB1dGlsc19ob29rc19faG9va3MudmVyc2lvbiA9ICcyLjEwLjMnO1xuXG4gICAgc2V0SG9va0NhbGxiYWNrKGxvY2FsX19jcmVhdGVMb2NhbCk7XG5cbiAgICB1dGlsc19ob29rc19faG9va3MuZm4gICAgICAgICAgICAgICAgICAgID0gbW9tZW50UHJvdG90eXBlO1xuICAgIHV0aWxzX2hvb2tzX19ob29rcy5taW4gICAgICAgICAgICAgICAgICAgPSBtaW47XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLm1heCAgICAgICAgICAgICAgICAgICA9IG1heDtcbiAgICB1dGlsc19ob29rc19faG9va3MudXRjICAgICAgICAgICAgICAgICAgID0gY3JlYXRlX3V0Y19fY3JlYXRlVVRDO1xuICAgIHV0aWxzX2hvb2tzX19ob29rcy51bml4ICAgICAgICAgICAgICAgICAgPSBtb21lbnRfX2NyZWF0ZVVuaXg7XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLm1vbnRocyAgICAgICAgICAgICAgICA9IGxpc3RzX19saXN0TW9udGhzO1xuICAgIHV0aWxzX2hvb2tzX19ob29rcy5pc0RhdGUgICAgICAgICAgICAgICAgPSBpc0RhdGU7XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLmxvY2FsZSAgICAgICAgICAgICAgICA9IGxvY2FsZV9sb2NhbGVzX19nZXRTZXRHbG9iYWxMb2NhbGU7XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLmludmFsaWQgICAgICAgICAgICAgICA9IHZhbGlkX19jcmVhdGVJbnZhbGlkO1xuICAgIHV0aWxzX2hvb2tzX19ob29rcy5kdXJhdGlvbiAgICAgICAgICAgICAgPSBjcmVhdGVfX2NyZWF0ZUR1cmF0aW9uO1xuICAgIHV0aWxzX2hvb2tzX19ob29rcy5pc01vbWVudCAgICAgICAgICAgICAgPSBpc01vbWVudDtcbiAgICB1dGlsc19ob29rc19faG9va3Mud2Vla2RheXMgICAgICAgICAgICAgID0gbGlzdHNfX2xpc3RXZWVrZGF5cztcbiAgICB1dGlsc19ob29rc19faG9va3MucGFyc2Vab25lICAgICAgICAgICAgID0gbW9tZW50X19jcmVhdGVJblpvbmU7XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLmxvY2FsZURhdGEgICAgICAgICAgICA9IGxvY2FsZV9sb2NhbGVzX19nZXRMb2NhbGU7XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLmlzRHVyYXRpb24gICAgICAgICAgICA9IGlzRHVyYXRpb247XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLm1vbnRoc1Nob3J0ICAgICAgICAgICA9IGxpc3RzX19saXN0TW9udGhzU2hvcnQ7XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLndlZWtkYXlzTWluICAgICAgICAgICA9IGxpc3RzX19saXN0V2Vla2RheXNNaW47XG4gICAgdXRpbHNfaG9va3NfX2hvb2tzLmRlZmluZUxvY2FsZSAgICAgICAgICA9IGRlZmluZUxvY2FsZTtcbiAgICB1dGlsc19ob29rc19faG9va3Mud2Vla2RheXNTaG9ydCAgICAgICAgID0gbGlzdHNfX2xpc3RXZWVrZGF5c1Nob3J0O1xuICAgIHV0aWxzX2hvb2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cbiAgICAgICAgICAgIGFjdGlvbiA9IHRoaXMuZGVmYXVsdEFjdGlvbnNbc3RhdGVdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHN5bWJvbCA9PT0gbnVsbCB8fCB0eXBlb2Ygc3ltYm9sID09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgc3ltYm9sID0gbGV4KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhY3Rpb24gPSB0YWJsZVtzdGF0ZV0gJiYgdGFibGVbc3RhdGVdW3N5bWJvbF07XG4gICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBhY3Rpb24gPT09ICd1bmRlZmluZWQnIHx8ICFhY3Rpb24ubGVuZ3RoIHx8ICFhY3Rpb25bMF0pIHtcbiAgICAgICAgICAgICAgICB2YXIgZXJyU3RyID0gJyc7XG4gICAgICAgICAgICAgICAgZXhwZWN0ZWQgPSBbXTtcbiAgICAgICAgICAgICAgICBmb3IgKHAgaW4gdGFibGVbc3RhdGVdKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnRlcm1pbmFsc19bcF0gJiYgcCA+IFRFUlJPUikge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhwZWN0ZWQucHVzaCgnXFwnJyArIHRoaXMudGVybWluYWxzX1twXSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobGV4ZXIuc2hvd1Bvc2l0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGVyclN0ciA9ICdQYXJzZSBlcnJvciBvbiBsaW5lICcgKyAoeXlsaW5lbm8gKyAxKSArICc6XFxuJyArIGxleGVyLnNob3dQb3NpdGlvbigpICsgJ1xcbkV4cGVjdGluZyAnICsgZXhwZWN0ZWQuam9pbignLCAnKSArICcsIGdvdCBcXCcnICsgKHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCkgKyAnXFwnJztcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlcnJTdHIgPSAnUGFyc2UgZXJyb3Igb24gbGluZSAnICsgKHl5bGluZW5vICsgMSkgKyAnOiBVbmV4cGVjdGVkICcgKyAoc3ltYm9sID09IEVPRiA/ICdlbmQgb2YgaW5wdXQnIDogJ1xcJycgKyAodGhpcy50ZXJtaW5hbHNfW3N5bWJvbF0gfHwgc3ltYm9sKSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5wYXJzZUVycm9yKGVyclN0ciwge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0OiBsZXhlci5tYXRjaCxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCxcbiAgICAgICAgICAgICAgICAgICAgbGluZTogbGV4ZXIueXlsaW5lbm8sXG4gICAgICAgICAgICAgICAgICAgIGxvYzogeXlsb2MsXG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdGVkOiBleHBlY3RlZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICBpZiAoYWN0aW9uWzBdIGluc3RhbmNlb2YgQXJyYXkgJiYgYWN0aW9uLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignUGFyc2UgRXJyb3I6IG11bHRpcGxlIGFjdGlvbnMgcG9zc2libGUgYXQgc3RhdGU6ICcgKyBzdGF0ZSArICcsIHRva2VuOiAnICsgc3ltYm9sKTtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKGFjdGlvblswXSkge1xuICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICBzdGFjay5wdXNoKHN5bWJvbCk7XG4gICAgICAgICAgICB2c3RhY2sucHVzaChsZXhlci55eXRleHQpO1xuICAgICAgICAgICAgbHN0YWNrLnB1c2gobGV4ZXIueXlsbG9jKTtcbiAgICAgICAgICAgIHN0YWNrLnB1c2goYWN0aW9uWzFdKTtcbiAgICAgICAgICAgIHN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoIXByZUVycm9yU3ltYm9sKSB7XG4gICAgICAgICAgICAgICAgeXlsZW5nID0gbGV4ZXIueXlsZW5nO1xuICAgICAgICAgICAgICAgIHl5dGV4dCA9IGxleGVyLnl5dGV4dDtcbiAgICAgICAgICAgICAgICB5eWxpbmVubyA9IGxleGVyLnl5bGluZW5vO1xuICAgICAgICAgICAgICAgIHl5bG9jID0gbGV4ZXIueXlsbG9jO1xuICAgICAgICAgICAgICAgIGlmIChyZWNvdmVyaW5nID4gMCkge1xuICAgICAgICAgICAgICAgICAgICByZWNvdmVyaW5nLS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzeW1ib2wgPSBwcmVFcnJvclN5bWJvbDtcbiAgICAgICAgICAgICAgICBwcmVFcnJvclN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgbGVuID0gdGhpcy5wcm9kdWN0aW9uc19bYWN0aW9uWzFdXVsxXTtcbiAgICAgICAgICAgIHl5dmFsLiQgPSB2c3RhY2tbdnN0YWNrLmxlbmd0aCAtIGxlbl07XG4gICAgICAgICAgICB5eXZhbC5fJCA9IHtcbiAgICAgICAgICAgICAgICBmaXJzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLmZpcnN0X2xpbmUsXG4gICAgICAgICAgICAgICAgbGFzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfbGluZSxcbiAgICAgICAgICAgICAgICBmaXJzdF9jb2x1bW46IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gKGxlbiB8fCAxKV0uZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgIGxhc3RfY29sdW1uOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfY29sdW1uXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHJhbmdlcykge1xuICAgICAgICAgICAgICAgIHl5dmFsLl8kLnJhbmdlID0gW1xuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLnJhbmdlWzBdLFxuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLnJhbmdlWzFdXG4gICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHIgPSB0aGlzLnBlcmZvcm1BY3Rpb24uYXBwbHkoeXl2YWwsIFtcbiAgICAgICAgICAgICAgICB5eXRleHQsXG4gICAgICAgICAgICAgICAgeXlsZW5nLFxuICAgICAgICAgICAgICAgIHl5bGluZW5vLFxuICAgICAgICAgICAgICAgIHNoYXJlZFN0YXRlLnl5LFxuICAgICAgICAgICAgICAgIGFjdGlvblsxXSxcbiAgICAgICAgICAgICAgICB2c3RhY2ssXG4gICAgICAgICAgICAgICAgbHN0YWNrXG4gICAgICAgICAgICBdLmNvbmNhdChhcmdzKSk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHIgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgc3RhY2sgPSBzdGFjay5zbGljZSgwLCAtMSAqIGxlbiAqIDIpO1xuICAgICAgICAgICAgICAgIHZzdGFjayA9IHZzdGFjay5zbGljZSgwLCAtMSAqIGxlbik7XG4gICAgICAgICAgICAgICAgbHN0YWNrID0gbHN0YWNrLnNsaWNlKDAsIC0xICogbGVuKTtcbiA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MuZG9uZSA9IGZhbHNlO1xuICAgICAgICB0aGlzLnl5bGluZW5vID0gdGhpcy55eWxlbmcgPSAwO1xuICAgICAgICB0aGlzLnl5dGV4dCA9IHRoaXMubWF0Y2hlZCA9IHRoaXMubWF0Y2ggPSAnJztcbiAgICAgICAgdGhpcy5jb25kaXRpb25TdGFjayA9IFsnSU5JVElBTCddO1xuICAgICAgICB0aGlzLnl5bGxvYyA9IHtcbiAgICAgICAgICAgIGZpcnN0X2xpbmU6IDEsXG4gICAgICAgICAgICBmaXJzdF9jb2x1bW46IDAsXG4gICAgICAgICAgICBsYXN0X2xpbmU6IDEsXG4gICAgICAgICAgICBsYXN0X2NvbHVtbjogMFxuICAgICAgICB9O1xuICAgICAgICBpZiAodGhpcy5vcHRpb25zLnJhbmdlcykge1xuICAgICAgICAgICAgdGhpcy55eWxsb2MucmFuZ2UgPSBbMCwwXTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm9mZnNldCA9IDA7XG4gICAgICAgIHJldHVybiB0aGlzO1xuICAgIH0sXG5cbi8vIGNvbnN1bWVzIGFuZCByZXR1cm5zIG9uZSBjaGFyIGZyb20gdGhlIGlucHV0XG5pbnB1dDpmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBjaCA9IHRoaXMuX2lucHV0WzBdO1xuICAgICAgICB0aGlzLnl5dGV4dCArPSBjaDtcbiAgICAgICAgdGhpcy55eWxlbmcrKztcbiAgICAgICAgdGhpcy5vZmZzZXQrKztcbiAgICAgICAgdGhpcy5tYXRjaCArPSBjaDtcbiAgICAgICAgdGhpcy5tYXRjaGVkICs9IGNoO1xuICAgICAgICB2YXIgbGluZXMgPSBjaC5tYXRjaCgvKD86XFxyXFxuP3xcXG4pLiovZyk7XG4gICAgICAgIGlmIChsaW5lcykge1xuICAgICAgICAgICAgdGhpcy55eWxpbmVubysrO1xuICAgICAgICAgICAgdGhpcy55eWxsb2MubGFzdF9saW5lKys7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICA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biAgICB9LFxuXG4vLyB0ZXN0IHRoZSBsZXhlZCB0b2tlbjogcmV0dXJuIEZBTFNFIHdoZW4gbm90IGEgbWF0Y2gsIG90aGVyd2lzZSByZXR1cm4gdG9rZW5cbnRlc3RfbWF0Y2g6ZnVuY3Rpb24gKG1hdGNoLCBpbmRleGVkX3J1bGUpIHtcbiAgICAgICAgdmFyIHRva2VuLFxuICAgICAgICAgICAgbGluZXMsXG4gICAgICAgICAgICBiYWNrdXA7XG5cbiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5iYWNrdHJhY2tfbGV4ZXIpIHtcbiAgICAgICAgICAgIC8vIHNhdmUgY29udGV4dFxuICAgICAgICAgICAgYmFja3VwID0ge1xuICAgICAgICAgICAgICAgIHl5bGluZW5vOiB0aGlzLnl5bGluZW5vLFxuICAgICAgICAgICAgICAgIHl5bGxvYzoge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdF9saW5lOiB0aGlzLnl5bGxvYy5maXJzdF9saW5lLFxuICAgICAgICAgICAgICAgICAgICBsYXN0X2xpbmU6IHRoaXMubGFzdF9saW5lLFxuICAgICAgICAgICAgICAgICAgICBmaXJzdF9jb2x1bW46IHRoaXMueXlsbG9jLmZpcnN0X2NvbHVtbixcbiAgICAgICAgICAgICAgICAgICAgbGFzdF9jb2x1bW46IHRoaXMueXlsbG9jLmxhc3RfY29sdW1uXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB5eXRleHQ6IHRoaXMueXl0ZXh0LFxuICAgICAgICAgICAgICAgIG1hdGNoOiB0aGlzLm1hdGNoLFxuICAgICAgICAgICAgICAgIG1hdGNoZXM6IHRoaXMubWF0Y2hlcyxcbiAgICAgICAgICAgICAgICBtYXRjaGVkOiB0aGlzLm1hdGNoZWQsXG4gICAgICAgICAgICAgICAgeXlsZW5nOiB0aGlzLnl5bGVuZyxcbiAgICAgICAgICAgICAgICBvZmZzZXQ6IHRoaXMub2Zmc2V0LFxuICAgICAgICAgICAgICAgIF9tb3JlOiB0aGlzLl9tb3JlLFxuICAgICAgICAgICAgICAgIF9pbnB1dDogdGhpcy5faW5wdXQsXG4gICAgICAgICAgICAgICAgeXk6IHRoaXMueXksXG4gICAgICAgICAgICAgICAgY29uZGl0aW9uU3RhY2s6IHRoaXMuY29uZGl0aW9uU3RhY2suc2xpY2UoMCksXG4gICAgICAgICAgICAgICAgZG9uZTogdGhpcy5kb25lXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5yYW5nZXMpIHtcbiAgICAgICAgICAgICAgICBiYWNrdXAueXlsbG9jLnJhbmdlID0gdGhpcy55eWxsb2MucmFuZ2Uuc2xpY2UoMCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBsaW5lcyA9IG1hdGNoWzBdLm1hdGNoKC8oPzpcXHJcXG4/fFxcbikuKi9nKTtcbiAgICAgICAgaWYgKGxpbmVzKSB7XG4gICAgICAgICAgICB0aGlzLnl5bGluZW5vICs9IGxpbmVzLmxlbmd0aDtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnl5bGxvYyA9IHtcbiAgICAgICAgICAgIGZpcnN0X2xpbmU6IHRoaXMueXlsbG9jLmxhc3RfbGluZSxcbiAgICAgICAgICAgIGxhc3RfbGluZTogdGhpcy55eWxpbmVubyArIDEsXG4gICAgICAgICAgICBmaXJzdF9jb2x1bW46IHRoaXMueXlsbG9jLmxhc3RfY29sdW1uLFxuICAgICAgICAgICAgbGFzdF9jb2x1bW46IGxpbmVzID9cbiAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lc1tsaW5lcy5sZW5ndGggLSAxXS5sZW5ndGggLSBsaW5lc1tsaW5lcy5sZW5ndGggLSAxXS5tYXRjaCgvXFxyP1xcbj8vKVswXS5sZW5ndGggOlxuICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueXlsbG9jLmxhc3RfY29sdW1uICsgbWF0Y2hbMF0ubGVuZ3RoXG4gICAgICAgI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CA9IGk7XG4gICAgICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5iYWNrdHJhY2tfbGV4ZXIpIHtcbiAgICAgICAgICAgICAgICAgICAgdG9rZW4gPSB0aGlzLnRlc3RfbWF0Y2godGVtcE1hdGNoLCBydWxlc1tpXSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0b2tlbiAhPT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9iYWNrdHJhY2spIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hdGNoID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsgLy8gcnVsZSBhY3Rpb24gY2FsbGVkIHJlamVjdCgpIGltcGx5aW5nIGEgcnVsZSBNSVNtYXRjaC5cbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGVsc2U6IHRoaXMgaXMgYSBsZXhlciBydWxlIHdoaWNoIGNvbnN1bWVzIGlucHV0IHdpdGhvdXQgcHJvZHVjaW5nIGEgdG9rZW4gKGUuZy4gd2hpdGVzcGFjZSlcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIXRoaXMub3B0aW9ucy5mbGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAobWF0Y2gpIHtcbiAgICAgICAgICAgIHRva2VuID0gdGhpcy50ZXN0X21hdGNoKG1hdGNoLCBydWxlc1tpbmRleF0pO1xuICAgICAgICAgICAgaWYgKHRva2VuICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGVsc2U6IHRoaXMgaXMgYSBsZXhlciBydWxlIHdoaWNoIGNvbnN1bWVzIGlucHV0IHdpdGhvdXQgcHJvZHVjaW5nIGEgdG9rZW4gKGUuZy4gd2hpdGVzcGFjZSlcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faW5wdXQgPT09IFwiXCIpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLkVPRjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnBhcnNlRXJyb3IoJ0xleGljYWwgZXJyb3Igb24gbGluZSAnICsgKHRoaXMueXlsaW5lbm8gKyAxKSArICcuIFVucmVjb2duaXplZCB0ZXh0LlxcbicgKyB0aGlzLnNob3dQb3NpdGlvbigpLCB7XG4gICAgICAgICAgICAgICAgdGV4dDogXCJcIixcbiAgICAgICAgICAgICAgICB0b2tlbjogbnVsbCxcbiAgICAgICAgICAgICAgICBsaW5lOiB0aGlzLnl5bGluZW5vXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH0sXG5cbi8vIHJldHVybiBuZXh0IG1hdGNoIHRoYXQgaGFzIGEgdG9rZW5cbmxleDpmdW5jdGlvbiBsZXgoKSB7XG4gICAgICAgIHZhciByID0gdGhpcy5uZXh0KCk7XG4gICAgICAgIGlmIChyKSB7XG4gICAgICAgICAgICByZXR1cm4gcjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmxleCgpO1xuICAgICAgICB9XG4gICAgfSxcblxuLy8gYWN0aXZhdGVzIGEgbmV3IGxleGVyIGNvbmRpdGlvbiBzdGF0ZSAocHVzaGVzIHRoZSBuZXcgbGV4ZXIgY29uZGl0aW9uIHN0YXRlIG9udG8gdGhlIGNvbmRpdGlvbiBzdGFjaylcbmJlZ2luOmZ1bmN0aW9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NlZCBwYXJhbWV0ZXJzXG4gICAgICAgIHN3aXRjaCh2ZXJ0aWNlLnR5cGUpe1xuICAgICAgICAgICAgY2FzZSAncm91bmQnOlxuICAgICAgICAgICAgICAgIHJhZGlvdXMgPSA1O1xuICAgICAgICAgICAgICAgIF9zaGFwZSA9ICdyZWN0JztcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ3NxdWFyZSc6XG4gICAgICAgICAgICAgICAgX3NoYXBlID0gJ3JlY3QnO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnZGlhbW9uZCc6XG4gICAgICAgICAgICAgICAgX3NoYXBlID0gJ3F1ZXN0aW9uJztcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ29kZCc6XG4gICAgICAgICAgICAgICAgX3NoYXBlID0gJ3JlY3RfbGVmdF9pbnZfYXJyb3cnO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnb2RkX3JpZ2h0JzpcbiAgICAgICAgICAgICAgICBfc2hhcGUgPSAncmVjdF9sZWZ0X2ludl9hcnJvdyc7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlICdjaXJjbGUnOlxuICAgICAgICAgICAgICAgIF9zaGFwZSA9ICdjaXJjbGUnO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICBfc2hhcGUgPSAncmVjdCc7XG4gICAgICAgIH1cbiAgICAgICAgLy8gQWRkIHRoZSBub2RlXG4gICAgICAgIGcuc2V0Tm9kZSh2ZXJ0aWNlLmlkLCB7bGFiZWxUeXBlOiBsYWJlbFR5cGVTdHIsIHNoYXBlOl9zaGFwZSwgbGFiZWw6IHZlcnRpY2VUZXh0LCByeDogcmFkaW91cywgcnk6IHJhZGlvdXMsIGNsYXNzOiBjbGFzc1N0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gICAgIHN0eWxlID0gc3R5bGUgKyBzICsnOyc7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBlbHNle1xuICAgICAgICAgICAgc3dpdGNoKGVkZ2Uuc3Ryb2tlKXtcbiAgICAgICAgICAgICAgICBjYXNlICdub3JtYWwnOlxuICAgICAgICAgICAgICAgICAgICBzdHlsZSA9ICdmaWxsOm5vbmUnO1xuICAgICAgICAgICAgICAgICAgICBpZih0eXBlb2YgZGVmYXVsdFN0eWxlICE9PSAndW5kZWZpbmVkJyl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzdHlsZSA9IGRlZmF1bHRTdHlsZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICdkb3R0ZWQnOlxuICAgICAgICAgICAgICAgICAgICBzdHlsZSA9ICdzdHJva2U6ICMzMzM7IGZpbGw6bm9uZTtzdHJva2Utd2lkdGg6MnB4O3N0cm9rZS1kYXNoYXJyYXk6MzsnO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICd0aGljayc6XG4gICAgICAgICAgICAgICAgICAgIHN0eWxlID0gJ3N0cm9rZTogIzMzMzsgc3Ryb2tlLXdpZHRoOiAzLjVweDtmaWxsOm5vbmUnO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIC8vIEFkZCB0aGUgZWRnZSB0byB0aGUgZ3JhcGhcbiAgICAgICAgaWYgKHR5cGVvZiBlZGdlLnRleHQgPT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICBpZih0eXBlb2YgZWRnZS5zdHlsZSA9PT0gJ3VuZGVmaW5lZCcpe1xuICAgICAgICAgICAgICAgIGcuc2V0RWRnZShlZGdlLnN0YXJ0LCBlZGdlLmVuZCx7IHN0eWxlOiBzdHlsZSwgYXJyb3doZ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FwZSBmb3IgcmhvbWJ1cyB0eXBlIG9mIGJvYyAoZGVjaXNpb24pXG4gICAgcmVuZGVyLnNoYXBlcygpLnF1ZXN0aW9uID0gZnVuY3Rpb24gKHBhcmVudCwgYmJveCwgbm9kZSkge1xuICAgICAgICB2YXIgdyA9IGJib3gud2lkdGgsXG4gICAgICAgICAgICBoID0gYmJveC5oZWlnaHQsXG4gICAgICAgICAgICBzID0gKHcgKyBoKSAqIDAuOCxcbiAgICAgICAgICAgIHBvaW50cyA9IFtcbiAgICAgICAgICAgICAgICB7eDogcyAvIDIsIHk6IDB9LFxuICAgICAgICAgICAgICAgIHt4OiBzLCB5OiAtcyAvIDJ9LFxuICAgICAgICAgICAgICAgIHt4OiBzIC8gMiwgeTogLXN9LFxuICAgICAgICAgICAgICAgIHt4OiAwLCB5OiAtcyAvIDJ9XG4gICAgICAgICAgICBdO1xuICAgICAgICB2YXIgc2hhcGVTdmcgPSBwYXJlbnQuaW5zZXJ0KFwicG9seWdvblwiLCBcIjpmaXJzdC1jaGlsZFwiKVxuICAgICAgICAgICAgLmF0dHIoXCJwb2ludHNcIiwgcG9pbnRzLm1hcChmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkLnggKyBcIixcIiArIGQueTtcbiAgICAgICAgICAgIH0pLmpvaW4oXCIgXCIpKVxuICAgICAgICAgICAgLmF0dHIoXCJyeFwiLCA1KVxuICAgICAgICAgICAgLmF0dHIoXCJyeVwiLCA1KVxuICAgICAgICAgICAgLmF0dHIoXCJ0cmFuc2Zvcm1cIiwgXCJ0cmFuc2xhdGUoXCIgKyAoLXMgLyAyKSArIFwiLFwiICsgKHMgKiAyIC8gNCkgKyBcIilcIik7XG4gICAgICAgIG5vZGUuaW50ZXJzZWN0ID0gZnVuY3Rpb24gKHBvaW50KSB7XG4gICAgICAgICAgICByZXR1cm4gZGFncmVEMy5pbnRlcnNlY3QucG9seWdvbihub2RlLCBwb2ludHMsIHBvaW50KTtcbiAgICAgICAgfTtcbiAgICAgICAgcmV0dXJuIHNoYXBlU3ZnO1xuICAgIH07XG5cbiAgICAvLyBBZGQgY3VzdG9tIHNoYXBlIGZvciBib3ggd2l0aCBpbnZlcnRlZCBhcnJvdyBvbiBsZWZ0IHNpZGVcbiAgICByZW5kZXIuc2hhcGVzKCkucmVjdF9sZWZ0X2ludl9hcnJvdyA9IGZ1bmN0aW9uIChwYXJlbnQsIGJib3gsIG5vZGUpIHtcbiAgICAgICAgdmFyIHcgPSBiYm94LndpZHRoLFxuICAgICAgICAgICAgaCA9IGJib3guaGVpZ2h0LFxuICAgICAgICAgICAgcG9pbnRzID0gW1xuICAgICAgICAgICAgICAgIHt4OiAtaC8yLCB5OiAwfSxcbiAgICAgICAgICAgICAgICB7eDogdywgeTogMH0sXG4gICAgICAgICAgICAgICAge3g6IHcsIHk6IC1ofSxcbiAgICAgICAgICAgICAgICB7eDogLWgvMiwgeTogLWh9LFxuICAgICAgICAgICAgICAgIHt4OiAwLCB5OiAtaC8yfSxcbiAgICAgICAgICAgIF07XG4gICAgICAgIHZhciBzaGFwZVN2ZyA9IHBhcmVudC5pbnNlcnQoXCJwb2x5Z29uXCIsIFwiOmZpcnN0LWNoaWxkXCIpXG4gICAgICAgICAgICAuYXR0cihcInBvaW50c1wiLCBwb2ludHMubWFwKGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQueCArIFwiLFwiICsgZC55O1xuICAgICAgICAgICAgfSkuam9pbihcIiBcIikpXG4gICAgICAgICAgICAuYXR0cihcInRyYW5zZm9ybVwiLCBcInRyYW5zbGF0ZShcIiArICgtdyAvIDIpICsgXCIsXCIgKyAoaCAqIDIgLyA0KSArIFwiKVwiKTtcbiAgICAgICAgbm9kZS5pbnRlcnNlY3QgPSBmdW5jdGlvbiAocG9pbnQpIHtcbiAgICAgICAgICAgIHJldHVybiBkYWdyZUQzLmludGVyc2VjdC5wb2x5Z29uKG5vZGUsIHBvaW50cywgcG9pbnQpO1xuICAgICAgICB9O1xuICAgICAgICByZXR1cm4gc2hhcGVTdmc7XG4gICAgfTtcblxuICAgIC8vIEFkZCBjdXN0b20gc2hhcGUgZm9yIGJveCB3aXRoIGludmVydGVkIGFycm93IG9uIHJpZ2h0IHNpZGVcbiAgICByZW5kZXIuc2hhcGVzKCkucmVjdF9yaWdodF9pbnZfYXJyb3cgPSBmdW5jdGlvbiAocGFyZW50LCBiYm94LCBub2RlKSB7XG4gICAgICAgIHZhciB3ID0gYmJveC53aWR0aCxcbiAgICAgICAgICAgIGggPSBiYm94LmhlaWdodCxcbiAgICAgICAgICAgIHBvaW50cyA9IFtcbiAgICAgICAgICAgICAgICB7eDogMCwgeTogMH0sXG4gICAgICAgICAgICAgICAge3g6IHcraC8yLCB5OiAwfSxcbiAgICAgICAgICAgICAgICB7eDogdywgeTogLWgvMn0sXG4gICAgICAgICAgICAgICAge3g6IHcraC8yLCB5OiAtaH0sXG4gICAgICAgICAgICAgICAge3g6IDAsIHk6IC1ofSxcbiAgICAgICAgICAgIF07XG4gICAgICAgIHZhciBzaGFwZVN2ZyA9IHBhcmVudC5pbnNlcnQoXCJwb2x5Z29uXCIsIFwiOmZpcnN0LWNoaWxkXCIpXG4gICAgICAgICAgICAuYXR0cihcInBvaW50c1wiLCBwb2ludHMubWFwKGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQueCArIFwiLFwiICsgZC55O1xuICAgICAgICAgICAgfSkuam9pbihcIiBcIikpXG4gICAgICAgICAgICAuYXR0cihcInRyYW5zZm9ybVwiLCBcInRyYW5zbGF0ZShcIiArICgtdyAvIDIpICsgXCIsXCIgKyAoaCAqIDIgLyA0KSArIFwiKVwiKTtcbiAgICAgICAgbm9kZS5pbnRlcnNlY3QgPSBmdW5jdGlvbiAocG9pbnQpIHtcbiAgICAgICAgICAgIHJldHVybiBkYWdyZUQzLmludGVyc2VjdC5wb2x5Z29uKG5vZGUsIHBvaW50cywgcG9pbnQpO1xuICAgICA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mxpbmVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfWVsc2V7XG4gICAgICAgICAgICAvL2NvbnNvbGUubG9nKCdDaGVja2luZyBub3cgZm9yIDo6JytpZCk7XG4gICAgICAgICAgICBpZih0eXBlb2YgdmVydGljZXNbaWRdICE9PSAndW5kZWZpbmVkJyl7XG4gICAgICAgICAgICAgICAgZnVucy5wdXNoKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgIHZhciBlbGVtID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoaWQpO1xuICAgICAgICAgICAgICAgICAgICBpZihlbGVtICE9PSBudWxsKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vY29uc29sZS5sb2coJ2lkIHdhcyBOT1QgbnVsbDogJytpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBlbGVtLm9uY2xpY2sgPSBmdW5jdGlvbigpe2V2YWwoZnVuY3Rpb25OYW1lKycoXFwnJyArIGlkICsgJ1xcJyknKTt9OyAvLyBqc2hpbnQgaWdub3JlOmxpbmVcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNle1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9jb25zb2xlLmxvZygnaWQgd2FzIG51bGw6ICcraWQpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuXG59O1xuXG5leHBvcnRzLmJpbmRGdW5jdGlvbnMgPSBmdW5jdGlvbigpe1xuICAgIC8vc2V0VGltZW91dChmdW5jdGlvbigpe1xuICAgICAgICBmdW5zLmZvckVhY2goZnVuY3Rpb24oZnVuKXtcbiAgICAgICAgICAgIGZ1bigpO1xuICAgICA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E7XG4gICAgaWYoc2VjQ291bnQ+MjAwMCl7XG4gICAgICAgIHJldHVybjtcbiAgICAgICAgXG4gICAgfVxuICAgIC8vdmFyIG5Qb3MgPSBnZXRQb3NGb3JJZChzdWJHcmFwaHNbcG9zXS5pZCk7XG4gICAgcG9zQ3Jvc3NSZWZbc2VjQ291bnRdPXBvcztcbiAgICBjb25zb2xlLmxvZygnU2V0dGluZyAnLCcgJyxzZWNDb3VudCwnIHRvICcscG9zKTtcbiAgICAvLyBDaGVjayBpZiBtYXRjaFxuICAgIGlmKHN1YkdyYXBoc1twb3NdLmlkID09PSBpZCl7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICByZXN1bHQ6dHJ1ZSxcbiAgICAgICAgICAgIGNvdW50OjBcbiAgICAgICAgfTtcbiAgICB9XG4gICAgXG5cbiAgICB2YXIgY291bnQgPSAwO1xuICAgIHZhciBwb3NDb3VudCA9IDE7XG4gICAgd2hpbGUoY291bnQ8bm9kZXMubGVuZ3RoKXtcbiAgICAgICAgdmFyIGNoaWxkUG9zID0gZ2V0UG9zRm9ySWQobm9kZXNbY291bnRdKTtcbiAgICAgICAgLy8gSWdub3JlIHJlZ3VsYXIgbm9kZXMgKHBvcyB3aWxsIGJlIC0xKVxuICAgICAgICBpZihjaGlsZFBvcz49MCl7XG4gICAgICAgICAgICB2YXIgcmVzID0gaW5kZXhOb2RlcyhpZCxjaGlsZFBvcyk7XG4gICAgICAgICAgICBpZihyZXMucmVzdWx0KXtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICByZXN1bHQ6dHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgY291bnQ6cG9zQ291bnQrcmVzLmNvdW50XG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgIHBvc0NvdW50ID0gcG9zQ291bnQgKyByZXMuY291bnQ7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICA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gICAgICAgICAgICAgIGlmICh0aGlzLnRlcm1pbmFsc19bcF0gJiYgcCA+IFRFUlJPUikge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhwZWN0ZWQucHVzaCgnXFwnJyArIHRoaXMudGVybWluYWxzX1twXSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobGV4ZXIuc2hvd1Bvc2l0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGVyclN0ciA9ICdQYXJzZSBlcnJvciBvbiBsaW5lICcgKyAoeXlsaW5lbm8gKyAxKSArICc6XFxuJyArIGxleGVyLnNob3dQb3NpdGlvbigpICsgJ1xcbkV4cGVjdGluZyAnICsgZXhwZWN0ZWQuam9pbignLCAnKSArICcsIGdvdCBcXCcnICsgKHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCkgKyAnXFwnJztcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlcnJTdHIgPSAnUGFyc2UgZXJyb3Igb24gbGluZSAnICsgKHl5bGluZW5vICsgMSkgKyAnOiBVbmV4cGVjdGVkICcgKyAoc3ltYm9sID09IEVPRiA/ICdlbmQgb2YgaW5wdXQnIDogJ1xcJycgKyAodGhpcy50ZXJtaW5hbHNfW3N5bWJvbF0gfHwgc3ltYm9sKSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5wYXJzZUVycm9yKGVyclN0ciwge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0OiBsZXhlci5tYXRjaCxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCxcbiAgICAgICAgICAgICAgICAgICAgbGluZTogbGV4ZXIueXlsaW5lbm8sXG4gICAgICAgICAgICAgICAgICAgIGxvYzogeXlsb2MsXG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdGVkOiBleHBlY3RlZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICBpZiAoYWN0aW9uWzBdIGluc3RhbmNlb2YgQXJyYXkgJiYgYWN0aW9uLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignUGFyc2UgRXJyb3I6IG11bHRpcGxlIGFjdGlvbnMgcG9zc2libGUgYXQgc3RhdGU6ICcgKyBzdGF0ZSArICcsIHRva2VuOiAnICsgc3ltYm9sKTtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKGFjdGlvblswXSkge1xuICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICBzdGFjay5wdXNoKHN5bWJvbCk7XG4gICAgICAgICAgICB2c3RhY2sucHVzaChsZXhlci55eXRleHQpO1xuICAgICAgICAgICAgbHN0YWNrLnB1c2gobGV4ZXIueXlsbG9jKTtcbiAgICAgICAgICAgIHN0YWNrLnB1c2goYWN0aW9uWzFdKTtcbiAgICAgICAgICAgIHN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoIXByZUVycm9yU3ltYm9sKSB7XG4gICAgICAgICAgICAgICAgeXlsZW5nID0gbGV4ZXIueXlsZW5nO1xuICAgICAgICAgICAgICAgIHl5dGV4dCA9IGxleGVyLnl5dGV4dDtcbiAgICAgICAgICAgICAgICB5eWxpbmVubyA9IGxleGVyLnl5bGluZW5vO1xuICAgICAgICAgICAgICAgIHl5bG9jID0gbGV4ZXIueXlsbG9jO1xuICAgICAgICAgICAgICAgIGlmIChyZWNvdmVyaW5nID4gMCkge1xuICAgICAgICAgICAgICAgICAgICByZWNvdmVyaW5nLS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzeW1ib2wgPSBwcmVFcnJvclN5bWJvbDtcbiAgICAgICAgICAgICAgICBwcmVFcnJvclN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgbGVuID0gdGhpcy5wcm9kdWN0aW9uc19bYWN0aW9uWzFdXVsxXTtcbiAgICAgICAgICAgIHl5dmFsLiQgPSB2c3RhY2tbdnN0YWNrLmxlbmd0aCAtIGxlbl07XG4gICAgICAgICAgICB5eXZhbC5fJCA9IHtcbiAgICAgICAgICAgICAgICBmaXJzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLmZpcnN0X2xpbmUsXG4gICAgICAgICAgICAgICAgbGFzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfbGluZSxcbiAgICAgICAgICAgICAgICBmaXJzdF9jb2x1bW46IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gKGxlbiB8fCAxKV0uZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgIGxhc3RfY29sdW1uOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfY29sdW1uXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHJhbmdlcykge1xuICAgICAgICAgICAgICAgIHl5dmFsLl8kLnJhbmdlID0gW1xuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLnJhbmdlWzBdLFxuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLnJhbmdlWzFdXG4gICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHIgPSB0aGlzLnBlcmZvcm1BY3Rpb24uYXBwbHkoeXl2YWwsIFtcbiAgICAgICAgICAgICAgICB5eXRleHQsXG4gICAgICAgICAgICAgICAgeXlsZW5nLFxuICAgICAgICAgICAgICAgIHl5bGluZW5vLFxuICAgICAgICAgICAgICAgIHNoYXJlZFN0YXRlLnl5LFxuICAgICAgICAgICAgICAgIGFjdGlvblsxXSxcbiAgICAgICAgICAgICAgICB2c3RhY2ssXG4gICAgICAgICAgICAgICAgbHN0YWNrXG4gICAgICAgICAgICBdLmNvbmNhdChhcmdzKSk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHIgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgc3RhY2sgPSBzdGFjay5zbGljZSgwLCAtMSAqIGxlbiAqIDIpO1xuICAgICAgICAgICAgICAgIHZzdGFjayA9IHZzdGFjay5zbGljZSgwLCAtMSAqIGxlbik7XG4gICAgICAgICAgICAgICAgbHN0YWNrID0gbHN0YWNrLnNsaWNlKDAsIC0xICogbGVuKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN0YWNrLnB1c2godGhpcy5wcm9kdWN0aW9uc19bYWN0aW9uWzFdXVswXSk7XG4gICAgICAgICAgICB2c3RhY2sucHVzaCh5eXZhbC4kKTtcbiAgICAgICAgICAgIGxzdGFjay5wdXNoKHl5dmFsLl8kKTtcbiAgICAgICAgICAgIG5ld1N0YXRlID0gdGFibGVbc3RhY2tbc3RhY2subGVuZ3RoIC0gMl1dW3N0YWNrW3N0YWNrLmxlbmd0aCAtIDFdXTtcbiAgICAgICAgICAgIHN0YWNrLnB1c2gobmV3U3RhdGUpO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgMzpcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJldHVybiB0cnVlO1xufX07XG5cbi8qIGdlbmVyYXRlZCBieSBqaXNvbi1sZXggMC4zLjQgKi9cbnZhciBsZXhlciA9IChmdW5jdGlvbigpe1xudmFyIGxleGVyID0gKHtcblxuRU9GOjEsXG5cbnBhcnNlRXJyb3I6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N0X2xpbmUsXG4gICAgICAgICAgICAgICAgICAgIGZpcnN0X2NvbHVtbjogdGhpcy55eWxsb2MuZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgICAgICBsYXN0X2NvbHVtbjogdGhpcy55eWxsb2MubGFzdF9jb2x1bW5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHl5dGV4dDogdGhpcy55eXRleHQsXG4gICAgICAgICAgICAgICAgbWF0Y2g6IHRoaXMubWF0Y2gsXG4gICAgICAgICAgICAgICAgbWF0Y2hlczogdGhpcy5tYXRjaGVzLFxuICAgICAgICAgICAgICAgIG1hdGNoZWQ6IHRoaXMubWF0Y2hlZCxcbiAgICAgICAgICAgICAgICB5eWxlbmc6IHRoaXMueXlsZW5nLFxuICAgICAgICAgICAgICAgIG9mZnNldDogdGhpcy5vZmZzZXQsXG4gICAgICAgICAgICAgICAgX21vcmU6IHRoaXMuX21vcmUsXG4gICAgICAgICAgICAgICAgX2lucHV0OiB0aGlzLl9pbnB1dCxcbiAgICAgICAgICAgICAgICB5eTogdGhpcy55eSxcbiAgICAgICAgICAgICAgICBjb25kaXRpb25TdGFjazogdGhpcy5jb25kaXRpb25TdGFjay5zbGljZSgwKSxcbiAgICAgICAgICAgICAgICBkb25lOiB0aGlzLmRvbmVcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLnJhbmdlcykge1xuICAgICAgICAgICAgICAgIGJhY2t1cC55eWxsb2MucmFuZ2UgPSB0aGlzLnl5bGxvYy5yYW5nZS5zbGljZSgwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxpbmVzID0gbWF0Y2hbMF0ubWF0Y2goLyg/Olxcclxcbj98XFxuKS4qL2cpO1xuICAgICAgICBpZiAobGluZXMpIHtcbiAgICAgICAgICAgIHRoaXMueXlsaW5lbm8gKz0gbGluZXMubGVuZ3RoO1xuICAgICAgICB9XG4gICAgICAgIHRoaXM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uLmNhbGwodGhpcywgdGhpcy55eSwgdGhpcywgaW5kZXhlZF9ydWxlLCB0aGlzLmNvbmRpdGlvblN0YWNrW3RoaXMuY29uZGl0aW9uU3RhY2subGVuZ3RoIC0gMV0pO1xuICAgICAgICBpZiAodGhpcy5kb25lICYmIHRoaXMuX2lucHV0KSB7XG4gICAgICAgICAgICB0aGlzLmRvbmUgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodG9rZW4pIHtcbiAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9iYWNrdHJhY2spIHtcbiAgICAgICAgICAgIC8vIHJlY292ZXIgY29udGV4dFxuICAgICAgICAgICAgZm9yICh2YXIgayBpbiBiYWNrdXApIHtcbiAgICAgICAgICAgICAgICB0aGlzW2tdID0gYmFja3VwW2tdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlOyAvLyBydWxlIGFjdGlvbiBjYWxsZWQgcmVqZWN0KCkgaW1wbHlpbmcgdGhlIG5leHQgcnVsZSBzaG91bGQgYmUgdGVzdGVkIGluc3RlYWQuXG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH0sXG5cbi8vIHJldHVybiBuZXh0IG1hdGNoIGluIGlucHV0XG5uZXh0OmZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKHRoaXMuZG9uZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuRU9GO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5faW5wdXQpIHtcbiAgICAgICAgICAgIHRoaXMuZG9uZSA9IHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgdG9rZW4sXG4gICAgICAgICAgICBtYXRjaCxcbiAgICAgICAgICAgIHRlbXBNYXRjaCxcbiAgICAgICAgICAgIGluZGV4O1xuICAgICAgICBpZiAoIXRoaXMuX21vcmUpIHtcbiAgICAgICAgICAgIHRoaXMueXl0ZXh0ID0gJyc7XG4gICAgICAgICAgICB0aGlzLm1hdGNoID0gJyc7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHJ1bGVzID0gdGhpcy5fY3VycmVudFJ1bGVzKCk7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcnVsZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHRlbXBNYXRjaCA9IHRoaXMuX2lucHV0Lm1hdGNoKHRoaXMucnVsZXNbcnVsZXNbaV1dKTtcbiAgICAgICAgICAgIGlmICh0ZW1wTWF0Y2ggJiYgKCFtYXRjaCB8fCB0ZW1wTWF0Y2hbMF0ubGVuZ3RoID4gbWF0Y2hbMF0ubGVuZ3RoKSkge1xuICAgICAgICAgICAgICAgIG1hdGNoID0gdGVtcE1hdGNoO1xuICAgICAgICAgICAgICAgIGluZGV4ID0gaTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLmJhY2t0cmFja19sZXhlcikge1xuICAgICAgICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMudGVzdF9tYXRjaCh0ZW1wTWF0Y2gsIHJ1bGVzW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRva2VuICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRva2VuO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2JhY2t0cmFjaykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOyAvLyBydWxlIGFjdGlvbiBjYWxsZWQgcmVqZWN0KCkgaW1wbHlpbmcgYSBydWxlIE1JU21hdGNoLlxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gZWxzZTogdGhpcyBpcyBhIGxleGVyIHJ1bGUgd2hpY2ggY29uc3VtZXMgaW5wdXQgd2l0aG91dCBwcm9kdWNpbmcgYSB0b2tlbiAoZS5nLiB3aGl0ZXNwYWNlKVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5vcHRpb25zLmZsZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChtYXRjaCkge1xuICAgICAgICAgICAgdG9rZW4gPSB0aGlzLnRlc3RfbWF0Y2gobWF0Y2gsIHJ1bGVzW2luZGV4XSk7XG4gICAgICAgICAgICBpZiAodG9rZW4gIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRva2VuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gZWxzZTogdGhpcyBpcyBhIGxleGVyIHJ1bGUgd2hpY2ggY29uc3VtZXMgaW5wdXQgd2l0aG91dCBwcm9kdWNpbmcgYSB0b2tlbiAoZS5nLiB3aGl0ZXNwYWNlKVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9pbnB1dCA9PT0gXCJcIikge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuRU9GO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMucGFyc2VFcnJvcignTGV4aWNhbCBlcnJvciBvbiBsaW5lICcgKyAodGhpcy55eWxpbmVubyArIDEpICsgJy4gVW5yZWNvZ25pemVkIHRleHQuXFxuJyArIHRoaXMuc2hvd1Bvc2l0aW9uKCksIHtcbiAgICAgICAgICAgICAgICB0ZXh0OiBcIlwiLFxuICAgICAgICAgICAgICAgIHRva2VuOiBudWxsLFxuICAgICAgICAgICAgICAgIGxpbmU6IHRoaXMueXlsaW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N0YWNrLmxlbmd0aCAtIDFdO1xuICAgICAgICBpZiAodGhpcy5kZWZhdWx0QWN0aW9uc1tzdGF0ZV0pIHtcbiAgICAgICAgICAgIGFjdGlvbiA9IHRoaXMuZGVmYXVsdEFjdGlvbnNbc3RhdGVdO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgaWYgKHN5bWJvbCA9PT0gbnVsbCB8fCB0eXBlb2Ygc3ltYm9sID09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgc3ltYm9sID0gbGV4KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhY3Rpb24gPSB0YWJsZVtzdGF0ZV0gJiYgdGFibGVbc3RhdGVdW3N5bWJvbF07XG4gICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBhY3Rpb24gPT09ICd1bmRlZmluZWQnIHx8ICFhY3Rpb24ubGVuZ3RoIHx8ICFhY3Rpb25bMF0pIHtcbiAgICAgICAgICAgICAgICB2YXIgZXJyU3RyID0gJyc7XG4gICAgICAgICAgICAgICAgZXhwZWN0ZWQgPSBbXTtcbiAgICAgICAgICAgICAgICBmb3IgKHAgaW4gdGFibGVbc3RhdGVdKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnRlcm1pbmFsc19bcF0gJiYgcCA+IFRFUlJPUikge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhwZWN0ZWQucHVzaCgnXFwnJyArIHRoaXMudGVybWluYWxzX1twXSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobGV4ZXIuc2hvd1Bvc2l0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGVyclN0ciA9ICdQYXJzZSBlcnJvciBvbiBsaW5lICcgKyAoeXlsaW5lbm8gKyAxKSArICc6XFxuJyArIGxleGVyLnNob3dQb3NpdGlvbigpICsgJ1xcbkV4cGVjdGluZyAnICsgZXhwZWN0ZWQuam9pbignLCAnKSArICcsIGdvdCBcXCcnICsgKHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCkgKyAnXFwnJztcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlcnJTdHIgPSAnUGFyc2UgZXJyb3Igb24gbGluZSAnICsgKHl5bGluZW5vICsgMSkgKyAnOiBVbmV4cGVjdGVkICcgKyAoc3ltYm9sID09IEVPRiA/ICdlbmQgb2YgaW5wdXQnIDogJ1xcJycgKyAodGhpcy50ZXJtaW5hbHNfW3N5bWJvbF0gfHwgc3ltYm9sKSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5wYXJzZUVycm9yKGVyclN0ciwge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0OiBsZXhlci5tYXRjaCxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCxcbiAgICAgICAgICAgICAgICAgICAgbGluZTogbGV4ZXIueXlsaW5lbm8sXG4gICAgICAgICAgICAgICAgICAgIGxvYzogeXlsb2MsXG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdGVkOiBleHBlY3RlZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICBpZiAoYWN0aW9uWzBdIGluc3RhbmNlb2YgQXJyYXkgJiYgYWN0aW9uLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignUGFyc2UgRXJyb3I6IG11bHRpcGxlIGFjdGlvbnMgcG9zc2libGUgYXQgc3RhdGU6ICcgKyBzdGF0ZSArICcsIHRva2VuOiAnICsgc3ltYm9sKTtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKGFjdGlvblswXSkge1xuICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICBzdGFjay5wdXNoKHN5bWJvbCk7XG4gICAgICAgICAgICB2c3RhY2sucHVzaChsZXhlci55eXRleHQpO1xuICAgICAgICAgICAgbHN0YWNrLnB1c2gobGV4ZXIueXlsbG9jKTtcbiAgICAgICAgICAgIHN0YWNrLnB1c2goYWN0aW9uWzFdKTtcbiAgICAgICAgICAgIHN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoIXByZUVycm9yU3ltYm9sKSB7XG4gICAgICAgICAgICAgICAgeXlsZW5nID0gbGV4ZXIueXlsZW5nO1xuICAgICAgICAgICAgICAgIHl5dGV4dCA9IGxleGVyLnl5dGV4dDtcbiAgICAgICAgICAgICAgICB5eWxpbmVubyA9IGxleGVyLnl5bGluZW5vO1xuICAgICAgICAgICAgICAgIHl5bG9jID0gbGV4ZXIueXlsbG9jO1xuICAgICAgICAgICAgICAgIGlmIChyZWNvdmVyaW5nID4gMCkge1xuICAgICAgICAgICAgICAgICAgICByZWNvdmVyaW5nLS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzeW1ib2wgPSBwcmVFcnJvclN5bWJvbDtcbiAgICAgICAgICAgICAgICBwcmVFcnJvclN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgbGVuID0gdGhpcy5wcm9kdWN0aW9uc19bYWN0aW9uWzFdXVsxXTtcbiAgICAgICAgICAgIHl5dmFsLiQgPSB2c3RhY2tbdnN0YWNrLmxlbmd0aCAtIGxlbl07XG4gICAgICAgICAgICB5eXZhbC5fJCA9IHtcbiAgICAgICAgICAgICAgICBmaXJzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLmZpcnN0X2xpbmUsXG4gICAgICAgICAgICAgICAgbGFzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfbGluZSxcbiAgICAgICAgICAgICAgICBmaXJzdF9jb2x1bW46IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gKGxlbiB8fCAxKV0uZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgIGxhc3RfY29sdW1uOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfY29sdW1uXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHJhbmdlcykge1xuICAgICAgICAgICAgICAgIHl5dmFsLl8kLnJhbmdlID0gW1xuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLnJhbmdlWzBdLFxuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLnJhbmdlWzFdXG4gICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHIgPSB0aGlzLnBlcmZvcm1BY3Rpb24uYXBwbHkoeXl2YWwsIFtcbiAgICAgICAgICAgICAgICB5eXRleHQsXG4gICAgICAgICAgICAgICAgeXlsZW5nLFxuICAgICAgICAgICAgICAgIHl5bGluZW5vLFxuICAgICAgICAgICAgICAgIHNoYXJlZFN0YXRlLnl5LFxuICAgICAgICAgICAgICAgIGFjdGlvblsxXSxcbiAgICAgICAgICAgICAgICB2c3RhY2ssXG4gICAgICAgICAgICAgICAgbHN0YWNrXG4gICAgICAgICAgICBdLmNvbmNhdChhcmdzKSk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHIgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgc3RhY2sgPSBzdGFjay5zbGljZSgwLCAtMSAqIGxlbiAqIDIpO1xuICAgICAgICAgICAgICAgIHZzdGFjayA9IHZzdGFjay5zbGljZSgwLCAt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ICB0aGlzLl9pbnB1dCA9IGlucHV0O1xuICAgICAgICB0aGlzLl9tb3JlID0gdGhpcy5fYmFja3RyYWNrID0gdGhpcy5kb25lID0gZmFsc2U7XG4gICAgICAgIHRoaXMueXlsaW5lbm8gPSB0aGlzLnl5bGVuZyA9IDA7XG4gICAgICAgIHRoaXMueXl0ZXh0ID0gdGhpcy5tYXRjaGVkID0gdGhpcy5tYXRjaCA9ICcnO1xuICAgICAgICB0aGlzLmNvbmRpdGlvblN0YWNrID0gWydJTklUSUFMJ107XG4gICAgICAgIHRoaXMueXlsbG9jID0ge1xuICAgICAgICAgICAgZmlyc3RfbGluZTogMSxcbiAgICAgICAgICAgIGZpcnN0X2NvbHVtbjogMCxcbiAgICAgICAgICAgIGxhc3RfbGluZTogMSxcbiAgICAgICAgICAgIGxhc3RfY29sdW1uOiAwXG4gICAgICAgIH07XG4gICAgICAgIGlmICh0aGlzLm9wdGlvbnMucmFuZ2VzKSB7XG4gICAgICAgICAgICB0aGlzLnl5bGxvYy5yYW5nZSA9IFswLDBdO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMub2Zmc2V0ID0gMDtcbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgfSxcblxuLy8gY29uc3VtZXMgYW5kIHJldHVybnMgb25lIGNoYXIgZnJvbSB0aGUgaW5wdXRcbmlucHV0OmZ1bmN0aW9uICgpIHtcbiAgICAgICAgdmFyIGNoID0gdGhpcy5faW5wdXRbMF07XG4gICAgICAgIHRoaXMueXl0ZXh0ICs9IGNoO1xuICAgICAgICB0aGlzLnl5bGVuZysrO1xuICAgICAgICB0aGlzLm9mZnNldCsrO1xuICAgICAgICB0aGlzLm1hdGNoICs9IGNoO1xuICAgICAgICB0aGlzLm1hdGNoZWQgKz0gY2g7XG4gICAgICAgIHZhciBsaW5lcyA9IGNoLm1hdGNoKC8oPzpcXHJcXG4/fFxcbikuKi9nKTtcbiAgICAgICAgaWYgKGxpbmVzKSB7XG4gICAgICAgICAgICB0aGlz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XCItXCIpO1xuICAgICAgICByZXR1cm4gcHJlICsgdGhpcy51cGNvbWluZ0lucHV0KCkgKyBcIlxcblwiICsgYyArIFwiXlwiO1xuICAgIH0sXG5cbi8vIHRlc3QgdGhlIGxleGVkIHRva2VuOiByZXR1cm4gRkFMU0Ugd2hlbiBub3QgYSBtYXRjaCwgb3RoZXJ3aXNlIHJldHVybiB0b2tlblxudGVzdF9tYXRjaDpmdW5jdGlvbiAobWF0Y2gsIGluZGV4ZWRfcnVsZSkge1xuICAgICAgICB2YXIgdG9rZW4sXG4gICAgICAgICAgICBsaW5lcyxcbiAgICAgICAgICAgIGJhY2t1cDtcblxuICAgICAgICBpZiAodGhpcy5vcHRpb25zLmJhY2t0cmFja19sZXhlcikge1xuICAgICAgICAgICAgLy8gc2F2ZSBjb250ZXh0XG4gICAgICAgICAgICBiYWNrdXAgPSB7XG4gICAgICAgICAgICAgICAgeXlsaW5lbm86IHRoaXMueXlsaW5lbm8sXG4gICAgICAgICAgICAgICAgeXlsbG9jOiB7XG4gICAgICAgICAgICAgICAgICAgIGZpcnN0X2xpbmU6IHRoaXMueXlsbG9jLmZpcnN0X2xpbmUsXG4gICAgICAgICAgICAgICAgICAgIGxhc3RfbGluZTogdGhpcy5sYXN0X2xpbmUsXG4gICAgICAgICAgICAgICAgICAgIGZpcnN0X2NvbHVtbjogdGhpcy55eWxsb2MuZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgICAgICBsYXN0X2NvbHVtbjogdGhpcy55eWxsb2MubGFzdF9jb2x1bW5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHl5dGV4dDogdGhpcy55eXRleHQsXG4gICAgICAgICAgICAgICAgbWF0Y2g6IHRoaXMubWF0Y2gsXG4gICAgICAgICAgICAgICAgbWF0Y2hlczogdGhpcy5tYXRjaGVzLFxuICAgICAgICAgICAgICAgIG1hdGNoZWQ6IHRoaXMubWF0Y2hlZCxcbiAgICAgICAgICAgICAgICB5eWxlbmc6IHRoaXMueXlsZW5nLFxuICAgICAgICAgICAgICAgIG9mZnNldDogdGhpcy5vZmZzZXQsXG4gICAgICAgICAgICAgICAgX21vcmU6IHRoaXMuX21vcmUsXG4gICAgICAgICAgICAgICAgX2lucHV0OiB0aGlzLl9pbnB1dCxcbiAgICAgICAgICAgICAgICB5eTogdGhpcy55eSxcbiAgICAgICAgICAgICAgICBjb25kaXRpb25TdGFjazogdGhpcy5jb25kaXRpb25TdGFjay5zbGljZSgwKSxcbiAgICAgICAgICAgICAgICBkb25lOiB0aGlzLmRvbmVcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLnJhbmdlcykge1xuICAgICAgICAgICAgICAgIGJhY2t1cC55eWxsb2MucmFuZ2UgPSB0aGlzLnl5bGxvYy5yYW5nZS5zbGljZSgwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxpbmVzID0gbWF0Y2hbMF0ubWF0Y2goLyg/Olxcclxcbj98XFxuKS4qL2cpO1xuICAgICAgICBpZiAobGluZXMpIHtcbiAgICAgICAgICAgIHRoaXMueXlsaW5lbm8gKz0gbGluZXMubGVuZ3RoO1xuICAgICAgICB9XG4gICAgICAgIHRoaXMueXlsbG9jID0ge1xuICAgICAgICAgICAgZmlyc3RfbGluZTogdGhpcy55eWxsb2MubGFzdF9saW5lLFxuICAgICAgICAgICAgbGFzdF9saW5lOiB0aGlzLnl5bGluZW5vICsgMSxcbiAgICAgICAgICAgIGZpcnN0X2NvbHVtbjogdGhpcy55eWxsb2MubGFzdF9jb2x1bW4sXG4gICAgICAgICAgICBsYXN0X2NvbHVtbjogbGluZXMgP1xuICAgICAgICAgICAgICAgICAgICAgICAgIGxpbmVzW2xpbmVzLmxlbmd0aCAtIDFdLmxlbmd0aCAtIGxpbmVzW2xpbmVzLmxlbmd0aCAtIDFdLm1hdGNoKC9cXHI/XFxuPy8pWzBdLmxlbmd0aCA6XG4gICAgICAgICAgICAgICAgICA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xuICAgICAgICAgICAgICAgIG1hdGNoID0gdGVtcE1hdGNoO1xuICAgICAgICAgICAgICAgIGluZGV4ID0gaTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLmJhY2t0cmFja19sZXhlcikge1xuICAgICAgICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMudGVzdF9tYXRjaCh0ZW1wTWF0Y2gsIHJ1bGVzW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRva2VuICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRva2VuO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2JhY2t0cmFjaykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOyAvLyBydWxlIGFjdGlvbiBjYWxsZWQgcmVqZWN0KCkgaW1wbHlpbmcgYSBydWxlIE1JU21hdGNoLlxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gZWxzZTogdGhpcyBpcyBhIGxleGVyIHJ1bGUgd2hpY2ggY29uc3VtZXMgaW5wdXQgd2l0aG91dCBwcm9kdWNpbmcgYSB0b2tlbiAoZS5nLiB3aGl0ZXNwYWNlKVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5vcHRpb25zLmZsZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChtYXRjaCkge1xuICAgICAgICAgICAgdG9rZW4gPSB0aGlzLnRlc3RfbWF0Y2gobWF0Y2gsIHJ1bGVzW2luZGV4XSk7XG4gICAgICAgICAgICBpZiAodG9rZW4gIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRva2VuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gZWxzZTogdGhpcyBpcyBhIGxleGVyIHJ1bGUgd2hpY2ggY29uc3VtZXMgaW5wdXQgd2l0aG91dCBwcm9kdWNpbmcgYSB0b2tlbiAoZS5nLiB3aGl0ZXNwYWNlKVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9pbnB1dCA9PT0gXCJcIikge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuRU9GO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMucGFyc2VFcnJvcignTGV4aWNhbCBlcnJvciBvbiBsaW5lICcgKyAodGhpcy55eWxpbmVubyArIDEpICsgJy4gVW5yZWNvZ25pemVkIHRleHQuXFxuJyArIHRoaXMuc2hvd1Bvc2l0aW9uKCksIHtcbiAgICAgICAgICAgICAgICB0ZXh0OiBcIlwiLFxuICAgICAgICAgICAgICAgIHRva2VuOiBudWxsLFxuICAgICAgICAgICAgICAgIGxpbmU6IHRoaXMueXlsaW5lbm9cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfSxcblxuLy8gcmV0dXJuIG5leHQgbWF0Y2ggdGhhdCBoYXMgYSB0b2tlblxubGV4OmZ1bmN0aW9uIGxleCgpIHtcbiAgICAgICAgdmFyIHIgPSB0aGlzLm5leHQoKTtcbiAgICAgICAgaWYgKHIpIHtcbiAgICAgICAgICAgIHJldHVybiByO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMubGV4KCk7XG4gICAgICAgIH1cbiAgICB9LFxuXG4vLyBhY3RpdmF0ZXMgYSBuZXcgbGV4ZXIgY29uZGl0aW9uIHN0YXRlIChwdXNoZXMgdGhlIG5ldyBsZXhlciBjb25k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FzZSA1NjpyZXR1cm4gMzc7XG5icmVhaztcbmNhc2UgNTc6cmV0dXJuIDQwXG5icmVhaztcbmNhc2UgNTg6cmV0dXJuIDQxXG5icmVhaztcbmNhc2UgNTk6cmV0dXJuIDk0O1xuYnJlYWs7XG5jYXNlIDYwOnJldHVybiA5O1xuYnJlYWs7XG5jYXNlIDYxOnJldHVybiAxMDtcbmJyZWFrO1xuY2FzZSA2MjpyZXR1cm4gMTE7XG5icmVhaztcbn1cbn0sXG5ydWxlczogWy9eKD86JSVbXlxcbl0qKS8sL14oPzpzdHlsZVxcYikvLC9eKD86ZGVmYXVsdFxcYikvLC9eKD86bGlua1N0eWxlXFxiKS8sL14oPzpjbGFzc0RlZlxcYikvLC9eKD86Y2xhc3NcXGIpLywvXig/OmNsaWNrXFxiKS8sL14oPzpncmFwaFxcYikvLC9eKD86c3ViZ3JhcGhcXGIpLywvXig/OmVuZFxccyopLywvXig/OkxSXFxiKS8sL14oPzpSTFxcYikvLC9eKD86VEJcXGIpLywvXig/OkJUXFxiKS8sL14oPzpURFxcYikvLC9eKD86QlJcXGIpLywvXig/OlswLTldKykvLC9eKD86IykvLC9eKD86OikvLC9eKD86OykvLC9eKD86LCkvLC9eKD86XFwqKS8sL14oPzo8KS8sL14oPzo+KS8sL14oPzpcXF4pLywvXig/OnZcXGIpLywvXig/OlxccyotLVt4XVxccyopLywvXig/OlxccyotLT5cXHMqKS8sL14oPzpcXHMqLS1bb11cXHMqKS8sL14oPzpcXHMqLS0tXFxzKikvLC9eKD86XFxzKi1cXC4tW3hdXFxzKikvLC9eKD86XFxzKi1cXC4tPlxccyopLywvXig/OlxccyotXFwuLVtvXVxccyopLywvXig/OlxccyotXFwuLVxccyopLywvXig/OlxccyouLVt4XVxccyopLywvXig/OlxccypcXC4tPlxccyopLywvXig/OlxccypcXC4tW29dXFxzKikvLC9eKD86XFxzKlxcLi1cXHMqKS8sL14oPzpcXHMqPT1beF1cXHMqKS8sL14oPzpcXHMqPT0+XFxzKikv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nRvRGF0ZSgpO1xuICAgIH1cblxuICAgIHZhciBkID0gbW9tZW50KHByZXZUaW1lKTtcbiAgICAvLyBDaGVjayBmb3IgbGVuZ3RoXG4gICAgdmFyIHJlID0gL14oW1xcZF0rKShbd2RoXSkvO1xuICAgIHZhciBkdXJhdGlvblN0YXRlbWVudCA9IHJlLmV4ZWMoc3RyLnRyaW0oKSk7XG4gICAgXG4gICAgaWYoZHVyYXRpb25TdGF0ZW1lbnQhPT0gbnVsbCl7XG4gICAgICAgIHN3aXRjaChkdXJhdGlvblN0YXRlbWVudFsyXSl7XG4gICAgICAgICAgICBjYXNlICdoJzpcbiAgICAgICAgICAgICAgICBkLmFkZChkdXJhdGlvblN0YXRlbWVudFsxXSwgJ2hvdXJzJyk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlICdkJzpcbiAgICAgICAgICAgICAgICBkLmFkZChkdXJhdGlvblN0YXRlbWVudFsxXSwgJ2RheXMnKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ3cnOlxuICAgICAgICAgICAgICAgIGQuYWRkKGR1cmF0aW9uU3RhdGVtZW50WzFdLCAnd2Vla3MnKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZC50b0RhdGUoKTtcbiAgICB9XG4gICAgLy8gRGVmYXVsdCBkYXRlIC0gbm93XG4gICAgcmV0dXJuIGQudG9EYXRlKCk7XG59O1xuXG52YXIgdGFza0NudCA9IDA7XG52YXIgcGFyc2VJZCA9IGZ1bmN0aW9uKGlkU3RyKXtcbiAgICBpZih0eXBlb2YgaWRTdHIgPT09ICd1bmRlZmluZWQnKXtcbiAgICAgICAgdGFza0NudCA9IHRhc2tDbnQgKyAxO1xuICAgICAgICByZXR1cm4gJ3Rhc2snK3Rhc2tDbnQ7XG4gICAgfVxuICAgIHJldHVybiBpZFN0cjtcbn07XG4vLyBpZCwgc3RhcnREY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aWYoZGF0YVswXS5tYXRjaCgvXlxccypkb25lXFxzKiQvKSl7XG4gICAgICAgICAgICB0YXNrLmRvbmUgPSB0cnVlO1xuICAgICAgICAgICAgZGF0YS5zaGlmdCgxKTtcbiAgICAgICAgICAgIG1hdGNoRm91bmQgPSB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGlmKGRhdGFbMF0ubWF0Y2goL15cXHMqY3JpdFxccyokLykpe1xuICAgICAgICAgICAgdGFzay5jcml0ID0gdHJ1ZTtcbiAgICAgICAgICAgIGRhdGEuc2hpZnQoMSk7XG4gICAgICAgICAgICBtYXRjaEZvdW5kID0gdHJ1ZTtcbiAgICAgICAgfVxuICAgIH1cbiAgICB2YXIgaTtcbiAgICBmb3IoaT0wO2k8ZGF0YS5sZW5ndGg7aSsrKXtcbiAgICAgICAgZGF0YVtpXSA9IGRhdGFbaV0udHJpbSgpO1xuICAgIH1cbiAgICBcbiAgICBcbiAgICBzd2l0Y2goZGF0YS5sZW5ndGgpe1xuICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICB0YXNrLmlkID0gcGFyc2VJZCgpO1xuICAgICAgICAgICAgdGFzay5zdGFydFRpbWUgPSBwcmV2VGFzay5lbmRUaW1lO1xuICAgICAgICAgICAgdGFzay5lbmRUaW1lICAgPSBnZXRFbmREYXRlKHRhc2suc3RhcnRUaW1lLCBkZiwgZGF0YVswXSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgdGFzay5pZCA9IHBhcnNlSWQoKTtcbiAgICAgICAgICAgIHRhc2suc3RhcnRUaW1lID0gZ2V0U3RhcnREYXRlKHVuZGVmaW5lZCwgZGYsIGRhdGFbMF0pO1xuICAgICAgICAgICAgdGFzay5lbmRUaW1lICAgPSBnZXRFbmREYXRlKHRhc2suc3RhcnRUaW1lLCBkZiwgZGF0YVsxXSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAzOlxuICAgICAgICAgICAg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pXG4gICAgICAgICAgICAuYXR0cihcInhcIiwgMClcbiAgICAgICAgICAgIC5hdHRyKFwieVwiLCBmdW5jdGlvbiAoZCwgaSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBpICogdGhlR2FwICsgdGhlVG9wUGFkIC0gMjtcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuYXR0cihcIndpZHRoXCIsIGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHcgLSB0aGVTaWRlUGFkIC8gMjtcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuYXR0cihcImhlaWdodFwiLCB0aGVHYXApXG4gICAgICAgICAgICAuYXR0cignY2xhc3MnLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgY2F0ZWdvcmllcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZC50eXBlID09PSBjYXRlZ29yaWVzW2ldKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3NlY3Rpb24gc2VjdGlvbicgKyAoaSAlIGNvbmYubnVtYmVyU2VjdGlvblN0eWxlcyk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcmV0dXJuICdzZWN0aW9uIHNlY3Rpb24wJztcbiAgICAgICAgICAgIH0pO1xuXG5cbiAgICAgICAgdmFyIHJlY3RhbmdsZXMgPSBzdmcuYXBwZW5kKCdnJylcbiAgICAgICAgICAgIC5zZWxlY3RBbGwoXCJyZWN0XCIpXG4gICAgICAgICAgICAuZGF0YSh0aGVBcnJheSlcbiAgICAgICAgICAgIC5lbnRlcigpO1xuXG5cbiAgICAgICAgdmFyIGlubmVyUmVjdHMgPSByZWN0YW5nbGVzLmFwcGVuZChcInJlY3RcIilcbiAgICAgICAgICAgICAgICAuYXR0cihcInJ4XCIsIDMpXG4gICAgICAgICAgICAgICAgLmF0dHIoXCJyeVwiLCAzKVxuICAgICAgICAgICAgICAgIC5hdHRyKFwieFwiLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdGltZVNjYWxlKGQuc3RhcnRUaW1lKSArIHRoZVNpZGVQYWQ7XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAuYXR0cihcInlcIiwgZnVuY3Rpb24gKGQsIGkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGkgKiB0aGVHYXAgKyB0aGVUb3BQYWQ7XG4gICAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgICAuYXR0cihcIndpZHRoXCIsIGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiAodGltZVNjYWxlKGQuZW5kVGltZSkgLSB0aW1lU2NhbGUoZC5zdGFydFRpbWUpKTtcbiAgICAgICAgICAgICAgICB9KVxuICAgICAgICAgICAgICAgIC5hdHRyKFwiaGVpZ2h0XCIsIHRoZUJhckhlaWdodClcbiAgICAgICAgICAgICAgICAuYXR0cignY2xhc3MnLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgICAgICB2YXIgcmVzID0gJ3Rhc2sgJztcbiAgICAgICAgICAgICAgICAgICAgXG4gICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgICB2YXIgc2VjTnVtID0gMDtcbiAgICAgICAgICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjYXRlZ29yaWVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZC50eXBlID09PSBjYXRlZ29yaWVzW2ldKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VjTnVtID0gKGkgJSBjb25mLm51bWJlclNlY3Rpb25TdHlsZXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgICAgICBpZihkLmFjdGl2ZSl7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZC5jcml0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlcyArICcgYWN0aXZlQ3JpdCcrc2VjTnVtO1xuICAgICAgICAgICAgICAgICAgICAgICAgfWVsc2V7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlcyArICcgYWN0aXZlJytzZWNOdW07XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgICAgICBpZiAoZC5kb25lKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZC5jcml0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlcyArICcgZG9uZUNyaXQnK3NlY051bTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXMgKyAnIGRvbmUnK3NlY051bTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgICAgIGlmIChkLmNyaXQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiByZXMgKyAnIGNyaXQnK3NlY051bTtcbiAgICAgICAgICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlcyArICcgdGFzaycrc2VjTnVtO1xuICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICA7XG5cblxuICAgICAgICB2YXIgcmVjdFRleHQgPSByZWN0YW5nbGVzLmFwcGVuZChcInRleHRcIilcbiAgICAgICAgICAgIC50ZXh0KGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQudGFzaztcbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuYXR0cihcImZvbnQtc2l6ZVwiLGNvbmYuZm9udFNpemUpXG4gICAgICAgICAgICAvLy5hdHRyKFwiZm9udC1mYW1pbHlcIixjb25mLmZvbnRGYW1pbHkpXG4gICAgICAgICAgICAuYXR0cihcInhcIiwgZnVuY3Rpb24gKGQpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3RhcnRYID0gdGltZVNjYWxlKGQuc3RhcnRUaW1lKSxcbiAgICAgICAgICAgICAgICAgICAgZW5kWCA9IHRpbWVTY2FsZShkLmVuZFRpbWUpLFxuICAgICAgICAgICAgICAgICAgICB0ZXh0V2lkdGggPSB0aGlzLmdldEJCb3goKS53aWR0aDtcblxuICAgICAgICAgICAgICAgIC8vIENoZWNrIGlkIHRleHQgd2lkdGggPiB3aWR0aCBvZiByZWN0YW5nbGVcbiAgICAgICAgICAgICAgICBpZiAodGV4dFdpZHRoID4gKGVuZFggLSBzdGFydFgpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChlbmRYICsgdGV4dFdpZHRoICArIDEuNSpjb25mLnNpZGVQYWRkaW5nPiB3KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gc3RhcnRYICsgdGhlU2lkZVBhZCAtIDU7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZW5kWCArIHRoZVNpZGVQYWQgKyA1O1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIChlbmRYIC0gc3RhcnRYKSAvIDIgKyBzdGFydFggKyB0aGVTaWRlUGFkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuYXR0cihcInlcIiwgZnVuY3Rpb24gKGQsIGkpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gaSAqIHRoZUdhcCArIChjb25mLmJhckhlaWdodCAvIDIpICsgKGNvbmYuZm9udFNpemUgLyAyIC0gMikgKyB0aGVUb3BQYWQ7XG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgLy8uYXR0cihcInRleHQtYW5jaG9yXCIsIFwibWlkZGxlXCIpXG4gICAgICAgICAgICAuYXR0cihcInRleHQtaGVpZ2h0XCIsIHRoZUJhckhlaWdodClcbiAgICAgICAgICAgIC5hdHRyKFwiY2xhc3NcIiwgZnVuY3Rpb24gKGQpIHtcbiAgICAgICAgICAgICAgICB2YXIgc3RhcnRYID0gdGltZVNjYWxlKGQuc3RhcnRUaW1lKSxcbiAgICAgICAgICAgICAgICAgICAgZW5kWCA9IHRpbWVTY2FsZShkLmVuZFRpbWUpLFxuICAgICAgICAgICAgICAgICAgICB0ZXh0V2lkdGggPSB0aGlzLmdldEJCb3goKS53aWR0aDtcbiAgICAgICAgICAgICAgICB2YXIgc2VjTnVtID0gMDtcbiAgICAgICAgICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGNhdGVnb3JpZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGQudHlwZSA9PT0gY2F0ZWdvcmllc1tpXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc2VjTnVtID0gKGkgJSBjb25mLm51bWJlclNlY3Rpb25TdHlsZXMpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdmFyIHRhc2tUeXBlID0gJyc7XG4gICAgICAgICAgICAgICAgaWYoZC5hY3RpdmUpe1xuICAgICAgICAgICAgICAgICAgICBpZiAoZC5jcml0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0YXNrVHlwZSA9ICdhY3RpdmVDcml0VGV4dCcrc2VjTnVtO1xuICAgICAgICAgICAgICAgICAgICB9ZWxzZXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRhc2tUeXBlID0gJ2FjdGl2ZVRleHQnK3NlY051bTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmIChkLmRvbmUpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGQuY3JpdCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGFza1R5cGUgPSB0YXNrVHlwZSArICcgZG9uZUNyaXRUZXh0JytzZWNOdW07XG4gICAgICAgICAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgICAgICAgICAgdGFza1R5cGUgPSB0YXNrVHlwZSArICcgZG9uZVRleHQnK3NlY051bTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1lbHNle1xuICAgICAgICAgICAgICAgICAgICBpZiAoZC5jcml0KSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0YXNrVHlwZSA9IHRhc2tUeXBlICsgJyBjcml0VGV4dCcrc2VjTnVtO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgLy8gQ2hlY2sgaWQgdGV4dCB3aWR0aCA+IHdpZHRoIG9mIHJlY3RhbmdsZVxuICAgICAgICAgICAgICAgIGlmICh0ZXh0V2lkdGggPiAoZW5kWCAtIHN0YXJ0WCkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVuZFggKyB0ZXh0V2lkdGggKyAxLjUqY29uZi5zaWRlUGFkZGluZyA+IHcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiAndGFza1RleHRPdXRzaWRlTGVmdCB0YXNrVGV4dE91dHNpZGUnICsgc2VjTnVtICsgJyAnICsgdGFza1R5cGU7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJ3Rhc2tUZXh0T3V0c2lkZVJpZ2h0IHRhc2tUZXh0T3V0c2lkZScgKyBzZWNOdW0rICcgJyArIHRhc2tUeXBlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuICd0YXNrVGV4dCB0YXNrVGV4dCcgKyBzZWNOdW0rICcgJyArIHRhc2tUeXBlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuXG4gICAgfVxuXG5cbiAgICBmdW5jdGlvbiBtYWtlR3JpZCh0aGVTaWRlUGFkLCB0aGVUb3BQYWQsIHcsIGgpIHtcblxuICAgICAgICB2YXIgcHJlID0gW1xuICAgICAgICAgICAgW1wiLiVMXCIsIGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQuZ2V0TWlsbGlzZWNvbmRzKCk7XG4gICAgICAgICAgICB9XSxcbiAgICAgICAgICAgIFtcIjolU1wiLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkLmdldFNlY29uZHMoKTtcbiAgICAgICAgICAgIH1dLFxuICAgICAgICAgICAgLy8gV2l0aGluIGEgaG91clxuICAgICAgICAgICAgW1wiaDEgJUk6JU1cIiwgZnVuY3Rpb24gKGQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZC5nZXRNaW51dGVzKCk7XG4gICAgICAgICAgICB9XV07XG4gICAgICAgIHZhciBwb3N0ID0gW1xuICAgICAgICAgICAgW1wiJVlcIiwgZnVuY3Rpb24gKCkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICAgICAgfV1dO1xuICAgICAgICBcbiAgICAgICAgdmFyIG1pZCA9IFsgICAgICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgLy8gV2l0aGluIGEgZGF5XG4gICAgICAgICAgICBbXCIlSTolTVwiLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkLmdldEhvdXJzKCk7XG4gICAgICAgICAgICB9XSxcbiAgICAgICAgICAgIC8vIERheSB3aXRoaW4gYSB3ZWVrIChub3QgbW9uZGF5KVxuICAgICAgICAgICAgW1wiJWEgJWRcIiwgZnVuY3Rpb24gKGQpIHtcbiAgICAgICAgICAgICAgICAvL3JldHVybiBkLmdldERheSgpID09MTtcbiAgICAgICAgICAgICAgICByZXR1cm4gZC5nZXREYXkoKSAmJiBkLmdldERhdGUoKSAhPSAxO1xuICAgICAgICAgICAgfV0sXG4gICAgICAgICAgICAvLyB3aXRoaW4gYSBtb250aFxuICAgICAgICAgICAgW1wiJWIgJWRcIiwgZnVuY3Rpb24gKGQpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gZC5nZXREYXRlKCkgIT0gMTtcbiAgICAgICAgICAgIH1dLFxuICAgICAgICAgICAgLy8gTW9udGhcbiAgICAgICAgICAgIFtcIiVCXCIsIGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQuZ2V0TW9udGgoKTtcbiAgICAgICAgICAgIH1dXG4gICAgICAgIF07XG4gICAgICAgIHZhciBmb3JtYXR0ZXI7XG4gICAgICAgIGlmKHR5cGVvZiBjb25mLmF4aXNGb3JtYXR0ZXIgIT09ICd1bmRlZmluZWQnKXtcbiAgICAgICAgICAgIG1pZCA9IFtdO1xuICAgICAgICAgICAgY29uZi5heGlzRm9ybWF0dGVyLmZvckVhY2goZnVuY3Rpb24oaXRlbSl7XG4gICAgICAgICAgICAgICAgdmFyIG4gPSBbXTtcbiAgICAgICAgICAgICAgICBuWzBdID0gaXRlbVswXTtcbiAgICAgICAgICAgICAgICBuWzFdID0gaXRlbVsxXTtcbiAgICAgICAgICAgICAgICBtaWQucHVzaChuKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIGZvcm1hdHRlciA9IHByZS5jb25jYXQobWlkKS5jb25jYXQocG9zdCk7XG5cbiAgICAgICAgdmFyIHhBeGlzID0gZDMuc3ZnLmF4aXMoKVxuICAgICAgICAgICAgICAgIC5zY2FsZSh0aW1lU2NhbGUpXG4gICAgICAgICAgICAgICAgLm9yaWVudCgnYm90dG9tJylcbiAgICAgICAgICAgICAgICAudGlja1NpemUoLWggKyB0aGVUb3BQYWQgKyBjb25mLmdyaWRMaW5lU3RhcnRQYWRkaW5nLCAwLCAwKVxuICAgICAgICAgICAgICAgIC50aWNrRm9ybWF0KGQzLnRpbWUuZm9ybWF0Lm11bHRpKGZvcm1hdHRlcikpXG4gICAgICAgICAgICA7XG5cbiAgICAgICAgaWYoZGF5c0luQ2hhcnQgPjcgJiYgZGF5c0luQ2hhcnQ8MjMwKXtcbiAgICAgICAgICAgIHhBeGlzID0geEF4aXMudGlja3MoZDMudGltZS5tb25kYXkucmFuZ2UpO1xuICAgICAgICB9XG5cbiAgICAgICAgdmFyIGdyaWQgPSBzdmcuYXBwZW5kKCdnJylcbiAgICAgICAgICAgIC5hdHRyKCdjbGFzcycsICdncmlkJylcbiAgICAgICAgICAgIC5hdHRyKCd0cmFuc2Zvcm0nLCAndHJhbnNsYXRlKCcgKyB0aGVTaWRlUGFkICsgJywgJyArIChoIC0gNTApICsgJyknKVxuICAgICAgICAgICAgLmNhbGwoeEF4aXMpXG4gICAgICAgICAgICAuc2VsZWN0QWxsKFwidGV4dFwiKVxuICAgICAgICAgICAgLnN0eWxlKFwidGV4dC1hbmNob3JcIiwgXCJtaWRkbGVcIilcbiAgICAgICAgICAgIC5hdHRyKFwiZmlsbFwiLCBcIiMwMDBcIilcbiAgICAgICAgICAgIC5hdHRyKFwic3Ryb2tlXCIsIFwibm9uZVwiKVxuICAgICAgICAgICAgLmF0dHIoXCJmb250LXNpemVcIiwgMTApXG4gICAgICAgICAgICAuYXR0cihcImR5XCIsIFwiMWVtXCIpO1xuICAgIH1cblxuICAgIGZ1bmN0aW9uIHZlcnRMYWJlbHModGhlR2FwLCB0aGVUb3BQYWQsIHRoZVNpZGVQYWQsIHRoZUJhckhlaWdodCwgdGhlQ29sb3JTY2FsZSkge1xuICAgICAgICB2YXIgbnVtT2NjdXJhbmNlcyA9IFtdO1xuICAgICAgICB2YXIgcHJldkdhcCA9IDA7XG5cbiAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjYXRlZ29yaWVzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgICBudW1PY2N1cmFuY2VzW2ldID0gW2NhdGVnb3JpZXNbaV0sIGdldENvdW50KGNhdGVnb3JpZXNbaV0sIGNhdHNVbmZpbHRlcmVkKV07XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgYXhpc1RleHQgPSBzdmcuYXBwZW5kKFwiZ1wiKSAvL3dpdGhvdXQgZG9pbmcgdGhpcywgaW1wb3NzaWJsZSB0byBwdXQgZ3JpZCBsaW5lcyBiZWhpbmQgdGV4dFxuICAgICAgICAgICAgLnNlbGVjdEFsbChcInRleHRcIilcbiAgICAgICAgICAgIC5kYXRhKG51bU9jY3VyYW5jZXMpXG4gICAgICAgICAgICAuZW50ZXIoKVxuICAgICAgICAgICAgLmFwcGVuZChcInRleHRcIilcbiAgICAgICAgICAgIC50ZXh0KGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGRbMF07XG4gICAgICAgICAgICB9KVxuICAgICAgICAgICAgLmF0dHIoXCJ4XCIsIDEwKVxuICAgICAgICAgICAgLmF0dHIoXCJ5XCIsIGZ1bmN0aW9uIChkLCBpKSB7XG4gICAgICAgICAgICAgICAgaWYgKGkgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIGZvciAodmFyIGogPSAwOyBqIDwgaTsgaisrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBwcmV2R2FwICs9IG51bU9jY3VyYW5jZXNbaSAtIDFdWzFdO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gY29uc29sZS5sb2cocHJldkdhcCk7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZFsxXSAqIHRoZUdhcCAvIDIgKyBwcmV2R2FwICogdGhlR2FwICsgdGhlVG9wUGFkO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGRbMV0gKiB0aGVHYXAgLyAyICsgdGhlVG9wUGFkO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAuYXR0cignY2xhc3MnLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgY2F0ZWdvcmllcy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZFswXSA9PT0gY2F0ZWdvcmllc1tpXSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuICdzZWN0aW9uVGl0bGUgc2VjdGlvblRpdGxlJyArIChpICUgY29uZi5udW1iZXJTZWN0aW9uU3R5bGVzKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gJ3NlY3Rpb25UaXRsZSc7XG4gICAgICAgICAgICB9KTtcblxuICAgIH1cblxuICAgIGZ1bmN0aW9uIGRyYXdUb2RheSh0aGVTaWRlUGFkLCB0aGVUb3BQYWQsIHcsIGgpIHtcbiAgICAgICAgdmFyIHRvZGF5RyA9IHN2Zy5hcHBlbmQoJ2cnKVxuICAgICAgICAgICAgLmF0dHIoJ2NsYXNzJywgJ3RvZGF5Jyk7XG5cbiAgICAgICAgdmFyIHRvZGF5ID0gbmV3IERhdGUoKTtcblxuICAgICAgICB2YXIgdG9kYXlMaW5lID0gdG9kYXlHLmFwcGVuZChcImxpbmVcIilcbiAgICAgICAgICAgICAgICAuYXR0cihcIngxXCIsIHRpbWVTY2FsZSh0b2RheSkgKyB0aGVTaWRlUGFkKVxuICAgICAgICAgICAgICAgIC5hdHRyKFwieDJcIiwgdGltZVNjYWxlKHRvZGF5KSArIHRoZVNpZGVQYWQpXG4gICAgICAgICAgICAgICAgLmF0dHIoX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ICAgaWYgKHN5bWJvbCA9PT0gbnVsbCB8fCB0eXBlb2Ygc3ltYm9sID09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgc3ltYm9sID0gbGV4KCk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBhY3Rpb24gPSB0YWJsZVtzdGF0ZV0gJiYgdGFibGVbc3RhdGVdW3N5bWJvbF07XG4gICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBhY3Rpb24gPT09ICd1bmRlZmluZWQnIHx8ICFhY3Rpb24ubGVuZ3RoIHx8ICFhY3Rpb25bMF0pIHtcbiAgICAgICAgICAgICAgICB2YXIgZXJyU3RyID0gJyc7XG4gICAgICAgICAgICAgICAgZXhwZWN0ZWQgPSBbXTtcbiAgICAgICAgICAgICAgICBmb3IgKHAgaW4gdGFibGVbc3RhdGVdKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0aGlzLnRlcm1pbmFsc19bcF0gJiYgcCA+IFRFUlJPUikge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhwZWN0ZWQucHVzaCgnXFwnJyArIHRoaXMudGVybWluYWxzX1twXSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAobGV4ZXIuc2hvd1Bvc2l0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGVyclN0ciA9ICdQYXJzZSBlcnJvciBvbiBsaW5lICcgKyAoeXlsaW5lbm8gKyAxKSArICc6XFxuJyArIGxleGVyLnNob3dQb3NpdGlvbigpICsgJ1xcbkV4cGVjdGluZyAnICsgZXhwZWN0ZWQuam9pbignLCAnKSArICcsIGdvdCBcXCcnICsgKHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCkgKyAnXFwnJztcbiAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICBlcnJTdHIgPSAnUGFyc2UgZXJyb3Igb24gbGluZSAnICsgKHl5bGluZW5vICsgMSkgKyAnOiBVbmV4cGVjdGVkICcgKyAoc3ltYm9sID09IEVPRiA/ICdlbmQgb2YgaW5wdXQnIDogJ1xcJycgKyAodGhpcy50ZXJtaW5hbHNfW3N5bWJvbF0gfHwgc3ltYm9sKSArICdcXCcnKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgdGhpcy5wYXJzZUVycm9yKGVyclN0ciwge1xuICAgICAgICAgICAgICAgICAgICB0ZXh0OiBsZXhlci5tYXRjaCxcbiAgICAgICAgICAgICAgICAgICAgdG9rZW46IHRoaXMudGVybWluYWxzX1tzeW1ib2xdIHx8IHN5bWJvbCxcbiAgICAgICAgICAgICAgICAgICAgbGluZTogbGV4ZXIueXlsaW5lbm8sXG4gICAgICAgICAgICAgICAgICAgIGxvYzogeXlsb2MsXG4gICAgICAgICAgICAgICAgICAgIGV4cGVjdGVkOiBleHBlY3RlZFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICBpZiAoYWN0aW9uWzBdIGluc3RhbmNlb2YgQXJyYXkgJiYgYWN0aW9uLmxlbmd0aCA+IDEpIHtcbiAgICAgICAgICAgIHRocm93IG5ldyBFcnJvcignUGFyc2UgRXJyb3I6IG11bHRpcGxlIGFjdGlvbnMgcG9zc2libGUgYXQgc3RhdGU6ICcgKyBzdGF0ZSArICcsIHRva2VuOiAnICsgc3ltYm9sKTtcbiAgICAgICAgfVxuICAgICAgICBzd2l0Y2ggKGFjdGlvblswXSkge1xuICAgICAgICBjYXNlIDE6XG4gICAgICAgICAgICBzdGFjay5wdXNoKHN5bWJvbCk7XG4gICAgICAgICAgICB2c3RhY2sucHVzaChsZXhlci55eXRleHQpO1xuICAgICAgICAgICAgbHN0YWNrLnB1c2gobGV4ZXIueXlsbG9jKTtcbiAgICAgICAgICAgIHN0YWNrLnB1c2goYWN0aW9uWzFdKTtcbiAgICAgICAgICAgIHN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICBpZiAoIXByZUVycm9yU3ltYm9sKSB7XG4gICAgICAgICAgICAgICAgeXlsZW5nID0gbGV4ZXIueXlsZW5nO1xuICAgICAgICAgICAgICAgIHl5dGV4dCA9IGxleGVyLnl5dGV4dDtcbiAgICAgICAgICAgICAgICB5eWxpbmVubyA9IGxleGVyLnl5bGluZW5vO1xuICAgICAgICAgICAgICAgIHl5bG9jID0gbGV4ZXIueXlsbG9jO1xuICAgICAgICAgICAgICAgIGlmIChyZWNvdmVyaW5nID4gMCkge1xuICAgICAgICAgICAgICAgICAgICByZWNvdmVyaW5nLS07XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICBzeW1ib2wgPSBwcmVFcnJvclN5bWJvbDtcbiAgICAgICAgICAgICAgICBwcmVFcnJvclN5bWJvbCA9IG51bGw7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAyOlxuICAgICAgICAgICAgbGVuID0gdGhpcy5wcm9kdWN0aW9uc19bYWN0aW9uWzFdXVsxXTtcbiAgICAgICAgICAgIHl5dmFsLiQgPSB2c3RhY2tbdnN0YWNrLmxlbmd0aCAtIGxlbl07XG4gICAgICAgICAgICB5eXZhbC5fJCA9IHtcbiAgICAgICAgICAgICAgICBmaXJzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLmZpcnN0X2xpbmUsXG4gICAgICAgICAgICAgICAgbGFzdF9saW5lOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfbGluZSxcbiAgICAgICAgICAgICAgICBmaXJzdF9jb2x1bW46IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gKGxlbiB8fCAxKV0uZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgIGxhc3RfY29sdW1uOiBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLmxhc3RfY29sdW1uXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHJhbmdlcykge1xuICAgICAgICAgICAgICAgIHl5dmFsLl8kLnJhbmdlID0gW1xuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIChsZW4gfHwgMSldLnJhbmdlWzBdLFxuICAgICAgICAgICAgICAgICAgICBsc3RhY2tbbHN0YWNrLmxlbmd0aCAtIDFdLnJhbmdlWzFdXG4gICAgICAgICAgICAgICAgXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHIgPSB0aGlzLnBlcmZvcm1BY3Rpb24uYXBwbHkoeXl2YWwsIFtcbiAgICAgICAgICAgICAgICB5eXRleHQsXG4gICAgICAgICAgICAgICAgeXlsZW5nLFxuICAgICAgICAgICAgICAgIHl5bGluZW5vLFxuICAgICAgICAgICAgICAgIHNoYXJlZFN0YXRlLnl5LFxuICAgICAgICAgICAgICAgIGFjdGlvblsxXSxcbiAgICAgICAgICAgICAgICB2c3RhY2ssXG4gICAgICAgICAgICAgICAgbHN0YWNrXG4gICAgICAgICAgICBdLmNvbmNhdChhcmdzKSk7XG4gICAgICAgICAgICBpZiAodHlwZW9mIHIgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAobGVuKSB7XG4gICAgICAgICAgICAgICAgc3RhY2sgPSBzdGFjay5zbGljZSgwLCAtMSAqIGxlbiAqIDIpO1xuICAgICAgICAgICAgICAgIHZzdGFjayA9IHZzdGFjay5zbGljZSgwLCAtMSAqIGxlbik7XG4gICAgICAgICAgICAgICAgbHN0YWNrID0gbHN0YWNrLnNsaWNlKDAsIC0xICogbGVuKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHN0YWNrLnB1c2godGhpcy5wcm9kdWN0aW9uc19bYWN0aW9uWzFdXVswXSk7XG4gICAgICAgICAg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9IHRoaXMubWF0Y2hlZCA9IHRoaXMubWF0Y2ggPSAnJztcbiAgICAgICAgdGhpcy5jb25kaXRpb25TdGFjayA9IFsnSU5JVElBTCddO1xuICAgICAgICB0aGlzLnl5bGxvYyA9IHtcbiAgICAgICAgICAgIGZpcnN0X2xpbmU6IDEsXG4gICAgICAgICAgICBmaXJzdF9jb2x1bW46IDAsXG4gICAgICAgICAgICBsYXN0X2xpbmU6IDEsXG4gICAgICAgICAgICBsYXN0X2NvbHVtbjogMFxuICAgICAgICB9O1xuICAgICAgICBpZiAodGhpcy5vcHRpb25zLnJhbmdlcykge1xuICAgICAgICAgICAgdGhpcy55eWxsb2MucmFuZ2UgPSBbMCwwXTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLm9mZnNldCA9IDA7XG4gICAgICAgIHJldHVybiB0aGlzO1xuICAgIH0sXG5cbi8vIGNvbnN1bWVzIGFuZCByZXR1cm5zIG9uZSBjaGFyIGZyb20gdGhlIGlucHV0XG5pbnB1dDpmdW5jdGlvbiAoKSB7XG4gICAgICAgIHZhciBjaCA9IHRoaXMuX2lucHV0WzBdO1xuICAgICAgICB0aGlzLnl5dGV4dCArPSBjaDtcbiAgICAgICAgdGhpcy55eWxlbmcrKztcbiAgICAgICAgdGhpcy5vZmZzZXQrKztcbiAgICAgICAgdGhpcy5tYXRjaCArPSBjaDtcbiAgICAgICAgdGhpcy5tYXRjaGVkICs9IGNoO1xuICAgICAgICB2YXIgbGluZXMgPSBjaC5tYXRjaCgvKD86XFxyXFxuP3xcXG4pLiovZyk7XG4gICAgICAgIGlmIChsaW5lcykge1xuICAgICAgICAgICAgdGhpcy55eWxpbmVubysrO1xuICAgICAgICAgICAgdGhpcy55eWxsb2MubGFzdF9saW5lKys7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICB0aGlzLnl5bGxvYy5sYXN0X2NvbHVtbisrO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLm9wdGlvbnMucmFuZ2VzKSB7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lzZSByZXR1cm4gdG9rZW5cbnRlc3RfbWF0Y2g6ZnVuY3Rpb24gKG1hdGNoLCBpbmRleGVkX3J1bGUpIHtcbiAgICAgICAgdmFyIHRva2VuLFxuICAgICAgICAgICAgbGluZXMsXG4gICAgICAgICAgICBiYWNrdXA7XG5cbiAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5iYWNrdHJhY2tfbGV4ZXIpIHtcbiAgICAgICAgICAgIC8vIHNhdmUgY29udGV4dFxuICAgICAgICAgICAgYmFja3VwID0ge1xuICAgICAgICAgICAgICAgIHl5bGluZW5vOiB0aGlzLnl5bGluZW5vLFxuICAgICAgICAgICAgICAgIHl5bGxvYzoge1xuICAgICAgICAgICAgICAgICAgICBmaXJzdF9saW5lOiB0aGlzLnl5bGxvYy5maXJzdF9saW5lLFxuICAgICAgICAgICAgICAgICAgICBsYXN0X2xpbmU6IHRoaXMubGFzdF9saW5lLFxuICAgICAgICAgICAgICAgICAgICBmaXJzdF9jb2x1bW46IHRoaXMueXlsbG9jLmZpcnN0X2NvbHVtbixcbiAgICAgICAgICAgICAgICAgICAgbGFzdF9jb2x1bW46IHRoaXMueXlsbG9jLmxhc3RfY29sdW1uXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB5eXRleHQ6IHRoaXMueXl0ZXh0LFxuICAgICAgICAgICAgICAgIG1hdGNoOiB0aGlzLm1hdGNoLFxuICAgICAgICAgICAgICAgIG1hdGNoZXM6IHRoaXMubWF0Y2hlcyxcbiAgICAgICAgICAgICAgICBtYXRjaGVkOiB0aGlzLm1hdGNoZWQsXG4gICAgICAgICAgICAgICAgeXlsZW5nOiB0aGlzLnl5bGVuZyxcbiAgICAgICAgICAgICAgICBvZmZzZXQ6IHRoaXMub2Zmc2V0LFxuICAgICAgICAgICAgICAgIF9tb3JlOiB0aGlzLl9tb3JlLFxuICAgICAgICAgICAgICAgIF9pbnB1dDogdGhpcy5faW5wdXQsXG4gICAgICAgICAgICAgICAgeXk6IHRoaXMueXksXG4gICAgICAgICAgICAgICAgY29uZGl0aW9uU3RhY2s6IHRoaXMuY29uZGl0aW9uU3RhY2suc2xpY2UoMCksXG4gICAgICAgICAgICAgICAgZG9uZTogdGhpcy5kb25lXG4gICAgICAgICAgICB9O1xuICAgICAgICAgICAgaWYgKHRoaXMub3B0aW9ucy5yYW5nZXMpIHtcbiAgICAgICAgICAgICAgICBiYWNrdXAueXlsbG9jLnJhbmdlID0gdGhpcy55eWxsb2MucmFuZ2Uuc2xpY2UoMCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICBsaW5lcyA9IG1hdGNoWzBdLm1hdGNoKC8oPzpcXHJcXG4/fFxcbikuKi9nKTtcbiAgICAgICAgaWYgKGxpbmVzKSB7XG4gICAgICAgICAgICB0aGlzLnl5bGluZW5vICs9IGxpbmVzLmxlbmd0aDtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLnl5bGxvYyA9IHtcbiAgICAgICAgICAgIGZpcnN0X2xpbmU6IHRoaXMueXlsbG9jLmxhc3RfbGluZSxcbiAgICAgICAgICAgIGxhc3RfbGluZTogdGhpcy55eWxpbmVubyArIDEsXG4gICAgICAgICAgICBmaXJzdF9jb2x1bW46IHRoaXMueXlsbG9jLmxhc3RfY29sdW1uLFxuICAgICAgICAgICAgbGFzdF9jb2x1bW46IGxpbmVzID9cbiAgICAgICAgICAgICAgICAgICAgICAgICBsaW5lc1tsaW5lcy5sZW5ndGggLSAxXS5sZW5ndGggLSBsaW5lc1tsaW5lcy5sZW5ndGggLSAxXS5tYXRjaCgvXFxyP1xcbj8vKVswXS5sZW5ndGggOlxuICAgICAgICAgICAgICAgICAgICAgICAgIHRoaXMueXlsbG9jLmxhc3RfY29sdW1uICsgbWF0Y2hbMF0ubGVuZ3RoXG4gICAgICAgIH07XG4gICAgICAgIHRoaXMueXl0ZXh0ICs9IG1hdGNoWzBdO1xuICAgICAgICB0aGlzLm1hdGNoICs9IG1hdGNoWzBdO1xuICAgICAgICB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dG9rZW4gPSB0aGlzLnRlc3RfbWF0Y2godGVtcE1hdGNoLCBydWxlc1tpXSk7XG4gICAgICAgICAgICAgICAgICAgIGlmICh0b2tlbiAhPT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9iYWNrdHJhY2spIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1hdGNoID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTsgLy8gcnVsZSBhY3Rpb24gY2FsbGVkIHJlamVjdCgpIGltcGx5aW5nIGEgcnVsZSBNSVNtYXRjaC5cbiAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIGVsc2U6IHRoaXMgaXMgYSBsZXhlciBydWxlIHdoaWNoIGNvbnN1bWVzIGlucHV0IHdpdGhvdXQgcHJvZHVjaW5nIGEgdG9rZW4gKGUuZy4gd2hpdGVzcGFjZSlcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0gZWxzZSBpZiAoIXRoaXMub3B0aW9ucy5mbGV4KSB7XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAobWF0Y2gpIHtcbiAgICAgICAgICAgIHRva2VuID0gdGhpcy50ZXN0X21hdGNoKG1hdGNoLCBydWxlc1tpbmRleF0pO1xuICAgICAgICAgICAgaWYgKHRva2VuICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIC8vIGVsc2U6IHRoaXMgaXMgYSBsZXhlciBydWxlIHdoaWNoIGNvbnN1bWVzIGlucHV0IHdpdGhvdXQgcHJvZHVjaW5nIGEgdG9rZW4gKGUuZy4gd2hpdGVzcGFjZSlcbiAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodGhpcy5faW5wdXQgPT09IFwiXCIpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLkVPRjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLnBhcnNlRXJyb3IoJ0xleGljYWwgZXJyb3Igb24gbGluZSAnICsgKHRoaXMueXlsaW5lbm8gKyAxKSArICcuIFVucmVjb2duaXplZCB0ZXh0LlxcbicgKyB0aGlzLnNob3dQb3NpdGlvbigpLCB7XG4gICAgICAgICAgICAgICAgdGV4dDogXCJcIixcbiAgICAgICAgICAgICAgICB0b2tlbjogbnVsbCxcbiAgICAgICAgICAgICAgICBsaW5lOiB0aGlzLnl5bGluZW5vXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH0sXG5cbi8vIHJldHVybiBuZXh0IG1hdGNoIHRoYXQgaGFzIGEgdG9rZW5cbmxleDpmdW5jdGlvbiBsZXgoKSB7XG4gICAgICAgIHZhciByID0gdGhpcy5uZXh0KCk7XG4gICAgICAgIGlmIChyKSB7XG4gICAgICAgICAgICByZXR1cm4gcjtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLmxleCgpO1xuICAgICAgICB9XG4gICAgfSxcblxuLy8gYWN0aXZhdGVzIGEgbmV3IGxleGVyIGNvbmRpdGlvbiBzdGF0ZSAocHVzaGVzIHRoZSBuZXcgbGV4ZXIgY29uZGl0aW9uIHN0YXRlIG9udG8gdGhlIGNvbmRpdGlvbiBzdGFjaylcbmJlZ2luOmZ1bmN0aW9uIGJlZ2luKGNvbmRpdGlvbikge1xuICAgICAgICB0aGlzLmNvbmRpdGlvblN0YWNrLnB1c2goY29uZGl0aW9uKTtcbiAgICB9LFxuXG4v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ICAgICAgICBleHBlY3RlZCA9IFtdO1xuICAgICAgICAgICAgICAgIGZvciAocCBpbiB0YWJsZVtzdGF0ZV0pIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRoaXMudGVybWluYWxzX1twXSAmJiBwID4gVEVSUk9SKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBleHBlY3RlZC5wdXNoKCdcXCcnICsgdGhpcy50ZXJtaW5hbHNfW3BdICsgJ1xcJycpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChsZXhlci5zaG93UG9zaXRpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgZXJyU3RyID0gJ1BhcnNlIGVycm9yIG9uIGxpbmUgJyArICh5eWxpbmVubyArIDEpICsgJzpcXG4nICsgbGV4ZXIuc2hvd1Bvc2l0aW9uKCkgKyAnXFxuRXhwZWN0aW5nICcgKyBleHBlY3RlZC5qb2luKCcsICcpICsgJywgZ290IFxcJycgKyAodGhpcy50ZXJtaW5hbHNfW3N5bWJvbF0gfHwgc3ltYm9sKSArICdcXCcnO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGVyclN0ciA9ICdQYXJzZSBlcnJvciBvbiBsaW5lICcgKyAoeXlsaW5lbm8gKyAxKSArICc6IFVuZXhwZWN0ZWQgJyArIChzeW1ib2wgPT0gRU9GID8gJ2VuZCBvZiBpbnB1dCcgOiAnXFwnJyArICh0aGlzLnRlcm1pbmFsc19bc3ltYm9sXSB8fCBzeW1ib2wpICsgJ1xcJycpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB0aGlzLnBhcnNlRXJyb3IoZXJyU3RyLCB7XG4gICAgICAgICAgICAgICAgICAgIHRleHQ6IGxleGVyLm1hdGNoLFxuICAgICAgICAgICAgICAgICAgICB0b2tlbjogdGhpcy50ZXJtaW5hbHNfW3N5bWJvbF0gfHwgc3ltYm9sLFxuICAgICAgICAgICAgICAgICAgICBsaW5lOiBsZXhlci55eWxpbmVubyxcbiAgICAgICAgICAgICAgICAgICAgbG9jOiB5eWxvYyxcbiAgICAgICAgICAgICAgICAgICAgZXhwZWN0ZWQ6IGV4cGVjdGVkXG4gICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIGlmIChhY3Rpb25bMF0gaW5zdGFuY2VvZiBBcnJheSAmJiBhY3Rpb24ubGVuZ3RoID4gMSkge1xuICAgICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdQYXJzZSBFcnJvcjogbXVsdGlwbGUgYWN0aW9ucyBwb3NzaWJsZSBhdCBzdGF0ZTogJyArIHN0YXRlICsgJywgdG9rZW46ICcgKyBzeW1ib2wpO1xuICAgICAgICB9XG4gICAgICAgIHN3aXRjaCAoYWN0aW9uWzBdKSB7XG4gICAgICAgIGNhc2UgMTpcbiAgICAgICAgICAgIHN0YWNrLnB1c2goc3ltYm9sKTtcbiAgICAgICAgICAgIHZzdGFjay5wdXNoKGxleGVyLnl5dGV4dCk7XG4gICAgICAgICAgICBsc3RhY2sucHVzaChsZXhlci55eWxsb2MpO1xuICAgICAgICAgICAgc3RhY2sucHVzaChhY3Rpb25bMV0pO1xuICAgICAgICAgICAgc3ltYm9sID0gbnVsbDtcbiAgICAgICAgICAgIGlmICghcHJlRXJyb3JTeW1ib2wpIHtcbiAgICAgICAgICAgICAgICB5eWxlbmcgPSBsZXhlci55eWxlbmc7XG4gICAgICAgICAgICAgICAgeXl0ZXh0ID0gbGV4ZXIueXl0ZXh0O1xuICAgICAgICAgICAgICAgIHl5bGluZW5vID0gbGV4ZXIueXlsaW5lbm87XG4gICAgICAgICAgICAgICAgeXlsb2MgPSBsZXhlci55eWxsb2M7XG4gICAgICAgICAgICAgICAgaWYgKHJlY292ZXJpbmcgPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJlY292ZXJpbmctLTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIHN5bWJvbCA9IHByZUVycm9yU3ltYm9sO1xuICAgICAgICAgICAgICAgIHByZUVycm9yU3ltYm9sID0gbnVsbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlIDI6XG4gICAgICAgICAgICBsZW4gPSB0aGlzLnByb2R1Y3Rpb25zX1thY3Rpb25bMV1dWzFdO1xuICAgICAgICAgICAgeXl2YWwuJCA9IHZzdGFja1t2c3RhY2subGVuZ3RoIC0gbGVuXTtcbiAgICAgICAgICAgIHl5dmFsLl8kID0ge1xuICAgICAgICAgICAgICAgIGZpcnN0X2xpbmU6IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gKGxlbiB8fCAxKV0uZmlyc3RfbGluZSxcbiAgICAgICAgICAgICAgICBsYXN0X2xpbmU6IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gMV0ubGFzdF9saW5lLFxuICAgICAgICAgICAgICAgIGZpcnN0X2NvbHVtbjogbHN0YWNrW2xzdGFjay5sZW5ndGggLSAobGVuIHx8IDEpXS5maXJzdF9jb2x1bW4sXG4gICAgICAgICAgICAgICAgbGFzdF9jb2x1bW46IGxzdGFja1tsc3RhY2subGVuZ3RoIC0gMV0ubGFzdF9jb2x1bW5cbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAocmFuZ2VzKSB7XG4gICAgICAgICAgICAgICAgeXl2YWwuXyQucmFuZ2UgPSBbXG4gICAgICAgICAgICAgICAgICAgIGxzdGFja1tsc3RhY2subGVuZ3RoIC0gKGxlbiB8fCAxKV0ucmFuZ2VbMF0sXG4gICAgICAgICAgICAgICAgICAgIGxzdGFja1tsc3RhY2subGVuZ3RoIC0gMV0ucmFuZ2VbMV1cbiAgICAgICAgICAgICAgICBdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgciA9IHRoaXMucGVyZm9ybUFjdGlvbi5hcHBseSh5eXZhbCwgW1xuICAgICAgICAgICAgICAgIHl5dGV4dCxcbiAgICAgICAgICAgICAgICB5eWxlbmcsXG4gICAgICAgICAgICAgICAgeXlsaW5lbm8sXG4gICAgICAgICAgICAgICAgc2hhcmVkU3RhdGUueXksXG4gICAgICAgICAgICAgICAgYWN0aW9uWzFdLFxuICAgICAgICAgICAgICAgIHZzdGFjayxcbiAgICAgICAgICAgICAgICBsc3RhY2tcbiAgICAgICAgICAgIF0uY29uY2F0KGFyZ3MpKTtcbiAgICAgICAgICAgIGlmICh0eXBlb2YgciAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gcjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChsZW4pIHtcbiAgICAgICAgICAgICAgICBzdGFjayA9IHN0YWNrLnNsaWNlKDAsIC0xICogbGVuICogMik7XG4gICAgICAgICAgICAgICAgdnN0YWNrID0gdnN0YWNrLnNsaWNlKDAsIC0xICogbGVuKTtcbiAgICAgICAgICAgICAgICBsc3RhY2sgPSBsc3RhY2suc2xpY2UoMCwgLTEgKiBsZW4pO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgc3RhY2sucHVzaCh0aGlzLnByb2R1Y3Rpb25zX1thY3Rpb25bMV1dWzBdKTtcbiAgICAgICAgICAgIHZzdGFjay5wdXNoKHl5dmFsLiQpO1xuICAgICAgICAgICAgbHN0YWNrLnB1c2goeXl2YWwuXyQpO1xuICAgICAgICAgICAgbmV3U3RhdGUgPSB0YWJsZVtzdGFja1tzdGFjay5sZW5ndGggLSAyXV1bc3RhY2tbc3RhY2subGVuZ3RoIC0gMV1dO1xuICAgICAgICAgICAgc3RhY2sucHVzaChuZXdTdGF0ZSk7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAzOlxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIHRydWU7XG59fTtcbi8qIGdlbmVyYXRlZCBieSBq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gICAgICAgICAgIGZpcnN0X2xpbmU6IHRoaXMueXlsbG9jLmZpcnN0X2xpbmUsXG4gICAgICAgICAgICAgICAgICAgIGxhc3RfbGluZTogdGhpcy5sYXN0X2xpbmUsXG4gICAgICAgICAgICAgICAgICAgIGZpcnN0X2NvbHVtbjogdGhpcy55eWxsb2MuZmlyc3RfY29sdW1uLFxuICAgICAgICAgICAgICAgICAgICBsYXN0X2NvbHVtbjogdGhpcy55eWxsb2MubGFzdF9jb2x1bW5cbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHl5dGV4dDogdGhpcy55eXRleHQsXG4gICAgICAgICAgICAgICAgbWF0Y2g6IHRoaXMubWF0Y2gsXG4gICAgICAgICAgICAgICAgbWF0Y2hlczogdGhpcy5tYXRjaGVzLFxuICAgICAgICAgICAgICAgIG1hdGNoZWQ6IHRoaXMubWF0Y2hlZCxcbiAgICAgICAgICAgICAgICB5eWxlbmc6IHRoaXMueXlsZW5nLFxuICAgICAgICAgICAgICAgIG9mZnNldDogdGhpcy5vZmZzZXQsXG4gICAgICAgICAgICAgICAgX21vcmU6IHRoaXMuX21vcmUsXG4gICAgICAgICAgICAgICAgX2lucHV0OiB0aGlzLl9pbnB1dCxcbiAgICAgICAgICAgICAgICB5eTogdGhpcy55eSxcbiAgICAgICAgICAgICAgICBjb25kaXRpb25TdGFjazogdGhpcy5jb25kaXRpb25TdGFjay5zbGljZSgwKSxcbiAgICAgICAgICAgICAgICBkb25lOiB0aGlzLmRvbmVcbiAgICAgICAgICAgIH07XG4gICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLnJhbmdlcykge1xuICAgICAgICAgICAgICAgIGJhY2t1cC55eWxsb2MucmFuZ2UgPSB0aGlzLnl5bGxvYy5yYW5nZS5zbGljZSgwKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuXG4gICAgICAgIGxpbmVzID0gbWF0Y2hbMF0ubWF0Y2goLyg/Olxcclxcbj98XFxuKS4qL2cpO1xuIC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aFswXS5sZW5ndGgpO1xuICAgICAgICB0aGlzLm1hdGNoZWQgKz0gbWF0Y2hbMF07XG4gICAgICAgIHRva2VuID0gdGhpcy5wZXJmb3JtQWN0aW9uLmNhbGwodGhpcywgdGhpcy55eSwgdGhpcywgaW5kZXhlZF9ydWxlLCB0aGlzLmNvbmRpdGlvblN0YWNrW3RoaXMuY29uZGl0aW9uU3RhY2subGVuZ3RoIC0gMV0pO1xuICAgICAgICBpZiAodGhpcy5kb25lICYmIHRoaXMuX2lucHV0KSB7XG4gICAgICAgICAgICB0aGlzLmRvbmUgPSBmYWxzZTtcbiAgICAgICAgfVxuICAgICAgICBpZiAodG9rZW4pIHtcbiAgICAgICAgICAgIHJldHVybiB0b2tlbjtcbiAgICAgICAgfSBlbHNlIGlmICh0aGlzLl9iYWNrdHJhY2spIHtcbiAgICAgICAgICAgIC8vIHJlY292ZXIgY29udGV4dFxuICAgICAgICAgICAgZm9yICh2YXIgayBpbiBiYWNrdXApIHtcbiAgICAgICAgICAgICAgICB0aGlzW2tdID0gYmFja3VwW2tdO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlOyAvLyBydWxlIGFjdGlvbiBjYWxsZWQgcmVqZWN0KCkgaW1wbHlpbmcgdGhlIG5leHQgcnVsZSBzaG91bGQgYmUgdGVzdGVkIGluc3RlYWQuXG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH0sXG5cbi8vIHJldHVybiBuZXh0IG1hdGNoIGluIGlucHV0XG5uZXh0OmZ1bmN0aW9uICgpIHtcbiAgICAgICAgaWYgKHRoaXMuZG9uZSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuRU9GO1xuICAgICAgICB9XG4gICAgICAgIGlmICghdGhpcy5faW5wdXQpIHtcbiAgICAgICAgICAgIHRoaXMuZG9uZSA9IHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICB2YXIgdG9rZW4sXG4gICAgICAgICAgICBtYXRjaCxcbiAgICAgICAgICAgIHRlbXBNYXRjaCxcbiAgICAgICAgICAgIGluZGV4O1xuICAgICAgICBpZiAoIXRoaXMuX21vcmUpIHtcbiAgICAgICAgICAgIHRoaXMueXl0ZXh0ID0gJyc7XG4gICAgICAgICAgICB0aGlzLm1hdGNoID0gJyc7XG4gICAgICAgIH1cbiAgICAgICAgdmFyIHJ1bGVzID0gdGhpcy5fY3VycmVudFJ1bGVzKCk7XG4gICAgICAgIGZvciAodmFyIGkgPSAwOyBpIDwgcnVsZXMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIHRlbXBNYXRjaCA9IHRoaXMuX2lucHV0Lm1hdGNoKHRoaXMucnVsZXNbcnVsZXNbaV1dKTtcbiAgICAgICAgICAgIGlmICh0ZW1wTWF0Y2ggJiYgKCFtYXRjaCB8fCB0ZW1wTWF0Y2hbMF0ubGVuZ3RoID4gbWF0Y2hbMF0ubGVuZ3RoKSkge1xuICAgICAgICAgICAgICAgIG1hdGNoID0gdGVtcE1hdGNoO1xuICAgICAgICAgICAgICAgIGluZGV4ID0gaTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5vcHRpb25zLmJhY2t0cmFja19sZXhlcikge1xuICAgICAgICAgICAgICAgICAgICB0b2tlbiA9IHRoaXMudGVzdF9tYXRjaCh0ZW1wTWF0Y2gsIHJ1bGVzW2ldKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRva2VuICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRva2VuO1xuICAgICAgICAgICAgICAgICAgICB9IGVsc2UgaWYgKHRoaXMuX2JhY2t0cmFjaykge1xuICAgICAgICAgICAgICAgICAgICAgICAgbWF0Y2ggPSBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlOyAvLyBydWxlIGFjdGlvbiBjYWxsZWQgcmVqZWN0KCkgaW1wbHlpbmcgYSBydWxlIE1JU21hdGNoLlxuICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gZWxzZTogdGhpcyBpcyBhIGxleGVyIHJ1bGUgd2hpY2ggY29uc3VtZXMgaW5wdXQgd2l0aG91dCBwcm9kdWNpbmcgYSB0b2tlbiAoZS5nLiB3aGl0ZXNwYWNlKVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSBlbHNlIGlmICghdGhpcy5vcHRpb25zLmZsZXgpIHtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChtYXRjaCkge1xuICAgICAgICAgICAgdG9rZW4gPSB0aGlzLnRlc3RfbWF0Y2gobWF0Y2gsIHJ1bGVzW2luZGV4XSk7XG4gICAgICAgICAgICBpZiAodG9rZW4gIT09IGZhbHNlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHRva2VuO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgLy8gZWxzZTogdGhpcyBpcyBhIGxleGVyIHJ1bGUgd2hpY2ggY29uc3VtZXMgaW5wdXQgd2l0aG91dCBwcm9kdWNpbmcgYSB0b2tlbiAoZS5nLiB3aGl0ZXNwYWNlKVxuICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLl9pbnB1dCA9PT0gXCJcIikge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuRU9GO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMucGFyc2VFcnJvcignTGV4aWNhbCBlcnJvciBvbiBsaW5lICcgKyAodGhpcy55eWxpbmVubyArIDEpICsgJy4gVW5yZWNvZ25pemVkIHRleHQuXFxuJyArIHRoaXMuc2hvd1Bvc2l0aW9uKCksIHtcbi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9ydHMuYXBwbHkgPSBmdW5jdGlvbihwYXJhbSl7XG4gICAgaWYocGFyYW0gaW5zdGFuY2VvZiBBcnJheSApe1xuICAgICAgICBwYXJhbS5mb3JFYWNoKGZ1bmN0aW9uKGl0ZW0pe1xuICAgICAgICAgICAgZXhwb3J0cy5hcHBseShpdGVtKTtcbiAgICAgICAgfSk7XG4gICAgfSBlbHNlIHtcbiAgICAgICAgLy8gY29uc29sZS5sb2cocGFyYW0pO1xuICAgICAgICBzd2l0Y2gocGFyYW0udHlwZSl7XG4gICAgICAgICAgICBjYXNlICdhZGRBY3Rvcic6XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5hZGRBY3RvcihwYXJhbS5hY3RvciwgcGFyYW0uYWN0b3IsIHBhcmFtLmFjdG9yKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ2FkZE5vdGUnOlxuICAgICAgICAgICAgICAgIGV4cG9ydHMuYWRkTm90ZShwYXJhbS5hY3RvcixwYXJhbS5wbGFjZW1lbnQsIHBhcmFtLnRleHQpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnYWRkTWVzc2FnZSc6XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5hZGRTaWduYWwocGFyYW0uZnJvbSwgcGFyYW0udG8sIHBhcmFtLm1zZywgcGFyYW0uc2lnbmFsVHlwZSk7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlICdsb29wU3RhcnQnOlxuICAgICAgICAgICAgICAgIC8vY29uc29sZS5sb2coJ0xvb3AgdGV4dDogJyxwYXJhbS5sb29wVGV4dCk7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5hZGRTaWduYWwodW5kZWZpbmVkLCB1bmRlZmluZWQsIHBhcmFtLmxvb3BUZXh0LCBwYXJhbS5zaWduYWxUeXBlKTtcbiAgICAgICAgICAgICAgICAvL3l5LmFkZFNpZ25hbCh1bmRlZmlu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uZm9yRWFjaChmdW5jdGlvbihtc2cpe1xuICAgICAgICB2YXIgbG9vcERhdGE7XG5cbiAgICAgICAgc3dpdGNoKG1zZy50eXBlKXtcbiAgICAgICAgICAgIGNhc2Ugc3EueXkuTElORVRZUEUuTk9URTpcbiAgICAgICAgICAgICAgICBleHBvcnRzLmJvdW5kcy5idW1wVmVydGljYWxQb3MoY29uZi5ib3hNYXJnaW4pO1xuXG4gICAgICAgICAgICAgICAgc3RhcnR4ID0gYWN0b3JzW21zZy5mcm9tXS54O1xuICAgICAgICAgICAgICAgIHN0b3B4ID0gYWN0b3JzW21zZy50b10ueDtcblxuICAgICAgICAgICAgICAgIGlmKG1zZy5wbGFjZW1lbnQgIT09IDApe1xuICAgICAgICAgICAgICAgICAgICAvLyBSaWdodCBvZlxuICAgICAgICAgICAgICAgICAgICBkcmF3Tm90ZShkaWFncmFtLCBzdGFydHggKyAoY29uZi53aWR0aCArIGNvbmYuYWN0b3JNYXJnaW4pLzIsIGV4cG9ydHMuYm91bmRzLmdldFZlcnRpY2FsUG9zKCksIG1zZyk7XG5cbiAgICAgICAgICAgICAgICB9ZWxzZXtcbiAgICAgICAgICAgICAgICAgICAgLy8gTGVmdCBvZlxuICAgICAgICAgICAgICAgICAgICBkcmF3Tm90ZShkaWFncmFtLCBzdGFydHggLSAoY29uZi53aWR0aCArIGNvbmYuYWN0b3JNYXJnaW4pLzIsIGV4cG9ydHMuYm91bmRzLmdldFZlcnRpY2FsUG9zKCksIG1zZyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBzcS55eS5MSU5FVFlQRS5MT09QX1NUQVJUOlxuICAgICAgICAgICAgICAgIGV4cG9ydHMuYm91bmRzLmJ1bXBWZXJ0aWNhbFBvcyhjb25mLmJveE1hcmdpbik7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMubmV3TG9vcChtc2cubWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMuYnVtcFZlcnRpY2FsUG9zKGNvbmYuYm94TWFyZ2luICsgY29uZi5ib3hUZXh0TWFyZ2luKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2Ugc3EueXkuTElORVRZUEUuTE9PUF9FTkQ6XG4gICAgICAgICAgICAgICAgbG9vcERhdGEgPSBleHBvcnRzLmJvdW5kcy5lbmRMb29wKCk7XG5cbiAgICAgICAgICAgICAgICBzdmdEcmF3LmRyYXdMb29wKGRpYWdyYW0sIGxvb3BEYXRhLCdsb29wJywgY29uZik7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMuYnVtcFZlcnRpY2FsUG9zKGNvbmYuYm94TWFyZ2luKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2Ugc3EueXkuTElORVRZUEUuT1BUX1NUQVJUOlxuICAgICAgICAgICAgICAgIGV4cG9ydHMuYm91bmRzLmJ1bXBWZXJ0aWNhbFBvcyhjb25mLmJveE1hcmdpbik7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMubmV3TG9vcChtc2cubWVzc2FnZSk7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMuYnVtcFZlcnRpY2FsUG9zKGNvbmYuYm94TWFyZ2luICsgY29uZi5ib3hUZXh0TWFyZ2luKTtcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2Ugc3EueXkuTElORVRZUEUuT1BUX0VORDpcbiAgICAgICAgICAgICAgICBsb29wRGF0YSA9IGV4cG9ydHMuYm91bmRzLmVuZExvb3AoKTtcblxuICAgICAgICAgICAgICAgIHN2Z0RyYXcuZHJhd0xvb3AoZGlhZ3JhbSwgbG9vcERhdGEsICdvcHQnLCBjb25mKTtcbiAgICAgICAgICAgICAgICBleHBvcnRzLmJvdW5kcy5idW1wVmVydGljYWxQb3MoY29uZi5ib3hNYXJnaW4pO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBzcS55eS5MSU5FVFlQRS5BTFRfU1RBUlQ6XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMuYnVtcFZlcnRpY2FsUG9zKGNvbmYuYm94TWFyZ2luKTtcbiAgICAgICAgICAgICAgICBleHBvcnRzLmJvdW5kcy5uZXdMb29wKG1zZy5tZXNzYWdlKTtcbiAgICAgICAgICAgICAgICBleHBvcnRzLmJvdW5kcy5idW1wVmVydGljYWxQb3MoY29uZi5ib3hNYXJnaW4gKyBjb25mLmJveFRleHRNYXJnaW4pO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBzcS55eS5MSU5FVFlQRS5BTFRfRUxTRTpcblxuICAgICAgICAgICAgICAgIC8vZXhwb3J0cy5kcmF3TG9vcChkaWFncmFtLCBsb29wRGF0YSk7XG4gICAgICAgICAgICAgICAgZXhwb3J0cy5ib3VuZHMuYnVtcFZlcnRpY2FsUG9zKGNvbmYuYm94TWFyZ2luKTtcbiAgICAgICAgICAgICAgICBsb29wRGF0YSA9IGV4cG9ydHMuYm91bmRzLmFkZEVsc2VUb0xvb3AobXNnLm1lc3NhZ2UpO1xuICAgICAgICAgICAgICAgIGV4cG9ydHMuYm91bmRzLmJ1bXBWZXJ0aWNhbFBvcyhjb25mLmJveE1hcmdpbik7XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICBjYXNlIHNxLnl5LkxJTkVUWVBFLkFMVF9FTkQ6XG4gICAgICAgICAgICAgICAgbG9vcERhdGEgPSBleHBvcnRzLmJvdW5kcy5lbmRMb29wKCk7XG5cbiAgICAgICAgICAgICAgICBzdmdEcmF3LmRyYXdMb29wKGRpYWdyYW0sIGxvb3BEYXRhLCdhbHQnLCBjb25mKTtcbiAgICAgICAgICAgICAgICBleHBvcnRzLmJvdW5kcy5idW1wVmVydGljYWxQb3MoY29uZi5ib3h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uIGNzcyBzdHlsaW5nIHRoaXMgbWlnaHQgbmVlZCBhZGp1c3RtZW50XG4gICAgICAgIC8vIFByb2xvbmdzIHRoZSBlZGdlIG9mIHRoZSBkaWFncmFtIGRvd253YXJkc1xuICAgICAgICBib3R0b21NYXJnaW5BZGo6MVxuICAgIH0sXG4gICAgZ2FudHQ6e1xuICAgICAgICB0aXRsZVRvcE1hcmdpbjogMjUsXG4gICAgICAgIGJhckhlaWdodDogMjAsXG4gICAgICAgIGJhckdhcDogNCxcbiAgICAgICAgdG9wUGFkZGluZzogNTAsXG4gICAgICAgIHNpZGVQYWRkaW5nOiA3NSxcbiAgICAgICAgZ3JpZExpbmVTdGFydFBhZGRpbmc6IDM1LFxuICAgICAgICBmb250U2l6ZTogMTEsXG4gICAgICAgIGZvbnRGYW1pbHk6ICdcIk9wZW4tU2Fuc1wiLCBcInNhbnMtc2VyaWZcIicsXG4gICAgICAgIG51bWJlclNlY3Rpb25TdHlsZXM6MyxcbiAgICAgICAgYXhpc0Zvcm1hdHRlcjogW1xuICAgICAgICAgICAgLy8gV2l0aGluIGEgZGF5XG4gICAgICAgICAgICBbXCIlSTolTVwiLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkLmdldEhvdXJzKCk7XG4gICAgICAgICAgICB9XSxcbiAgICAgICAgICAgIC8vIE1vbmRheSBhIHdlZWtcbiAgICAgICAgICAgIFtcIncuICVVXCIsIGZ1bmN0aW9uIChkKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGQuZ2V0RGF5KCkgPT0gMTtcbiAgICAgICAgICAgIH1dLFxuICAgICAgICAgICAgLy8gRGF5IHdpdGhpbiBhIHdlZWsgKG5vdCBtb25kYXkpXG4gICAgICAgICAgICBbXCIlYSAlZFwiLCBmdW5jdGlvbiAoZCkge1xuICAgICAgICAgICAgICAgIHJldHVybiBkLmdldERheSgpICYmIGQuZ2V0RGF0ZSgpICE9IDE7XG4gICAgICAgICAgICB9XSxcbiA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c2VyO1xuICAgICAgICAgICAgcGFyc2VyLnBhcnNlci55eSA9IHNlcXVlbmNlRGI7XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAnaW5mbyc6XG4gICAgICAgICAgICBwYXJzZXIgPSBpbmZvUGFyc2VyO1xuICAgICAgICAgICAgcGFyc2VyLnBhcnNlci55eSA9IGluZm9EYjtcbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlICdnYW50dCc6XG4gICAgICAgICAgICBwYXJzZXIgPSBnYW50dFBhcnNlcjtcbiAgICAgICAgICAgIHBhcnNlci5wYXJzZXIueXkgPSBnYW50dERiO1xuICAgICAgICAgICAgYnJlYWs7XG4gICAgfVxuXG4gICAgdHJ5e1xuICAgICAgICBwYXJzZXIucGFyc2UodGV4dCk7XG4gICAgICAgIHJldHVybiB0cnVlO1xuICAgIH1cbiAgICBjYXRjaChlcnIpe1xuICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgfVxufTtcblxuLyoqXG4gKiBGdW5jdGlvbiByZXR1cm5pbmcgdmVyc2lvbiBpbmZvcm1hdGlvblxuICogQHJldHVybnMge3N0cmluZ30gQSBzdHJpbmcgY29udGFpbmluZyB0aGUgdmVyc2lvbiBpbmZvXG4gKi9cbmV4cG9ydHMudmVyc2lvbiA9IGZ1bmN0aW9uKCl7XG4gICAgcmV0dXJuIHJlcXVpcmUoJy4uL3BhY2thZ2UuanNvbicpLnZlcnNpb247XG59O1xuXG52YXIgcmVuZGVyID0gZnVuY3Rpb24oaWQsIHR4dCxjYil7XG5cbiAgICBkMy5zZWxlY3QoJ2JvZHknKS5hcHBlbmQoJ2RpdicpXG4gICAgICAgIC5hdHRyKCdpZCcsICdkJytpZClcbiAgICAgICAgLmFwcGVuZCgnc3ZnJylcbiAgICAgICAgLmF0dHIoJ2lkJywgaWQpXG4gICAgICAgIC5hdHRyKCd3aWR0aCcsJzEwMCUnKVxuICAgICAgICAuYXR0cigneG1sbnMnLCdodHRwOi8vd3d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ldENsYXNzZXModHh0LCB0cnVlKTtcbiAgICAgICAgICAgICAgICB1dGlscy5jbG9uZUNzc1N0eWxlcyhlbGVtZW50LmZpcnN0Q2hpbGQsIGNsYXNzZXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgJ3NlcXVlbmNlRGlhZ3JhbSc6XG4gICAgICAgICAgICAvL2lmKHR5cGVvZiBtZXJtYWlkLnNlcXVlbmNlQ29uZmlnID09PSAnb2JqZWN0Jyl7XG4gICAgICAgICAgICBzZXEuc2V0Q29uZihjb25maWcuc2VxdWVuY2VEaWFncmFtKTtcbiAgICAgICAgICAgIC8vfVxuICAgICAgICAgICAgc2VxLmRyYXcodHh0LGlkKTtcbiAgICAgICAgICAgIGlmKGNvbmZpZy5tZXJtYWlkLmNsb25lQ3NzU3R5bGVzKSB7XG4gICAgICAgICAgICAgICAgdXRpbHMuY2xvbmVDc3NTdHlsZXMoZWxlbWVudC5maXJzdENoaWxkLCBbXSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAnZ2FudHQnOlxuICAgICAgICAgICAgZ2FudHQuc2V0Q29uZihjb25maWcuZ2FudHQpO1xuICAgICAgICAgICAgZ2FudHQuZHJhdyh0eHQsaWQpO1xuICAgICAgICAgICAgaWYoY29uZmlnLm1lcm1haWQuY2xvbmVDc3NTdHlsZXMpIHtcbiAgICAgICAgICAgICAgICB1dGlscy5jbG9uZUNzc1N0eWxlcyhlbGVtZW50LmZpcnN0Q2hpbGQsIFtdKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICBjYXNlICdpbmZvJzpcbiAgICAgICAgICAgIGluZm8uZHJhdyh0eHQsaWQsZXhwb3J0cy52ZXJzaW9uKCkpO1xuICAgICAgICAgICAgaWYoY29uZmlnLm1lcm1haWQuY2xvbmVDc3NTdHlsZXMpIHtcbiAgICAgICAgICAgICAgICB1d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gICAvL1xuICAgIC8vIHBhc3MgdGhlIGh0bWwgc3R1YiB0byBqc0RvbVxuICAgICAgIC8qIGpzZG9tLmVudih7IFxuICAgICAgICAgICAgZmVhdHVyZXMgOiB7IFF1ZXJ5U2VsZWN0b3JBbGwgOiB0cnVlIH0sXG4gICAgICAgICAgICBodG1sIDogaHRtbFN0dWIsXG4gICAgICAgICAgICBkb25lIDogZnVuY3Rpb24oZXJyb3JzLCB3aW4pIHtcbiAgICAgICAgICAgICAgICAvLyBwcm9jZXNzIHRoZSBodG1sIGRvY3VtZW50LCBsaWtlIGlmIHdlIHdlcmUgYXQgY2xpZW50IHNpZGVcbiAgICAgICAgICAgICAgICAvLyBjb2RlIHRvIGdlbmVyYXRlIHRoZSBkYXRhdml6IGFuZCBwcm9jZXNzIHRoZSByZXN1bHRpbmcgaHRtbCBmaWxlIHRvIGJlIGFkZGVkIGhlcmVcbiAgICAgICAgICAgICAgICAvL3ZhciBkMyA9IHJlcXVpcmUoJ2QzJyk7XG4gICAgICAgICAgICAgICAgLy9jb25zb2xlLmxvZygnSGVyZSB3ZSBnbzogJytKU09OLnN0cmluZ2lmeShkMykpO1xuICAgICAgICAgICAgICAgIFxuICAgICAgICAgICAgICAgIGdsb2JhbC5kb2N1bWVudCA9IHdpbi5kb2N1bWVudDtcbiAgICAgICAgICAgICAgICBnbG9iYWwud2luZG93ID0gd2luO1xuXG4gICAgICAgICAgICAgICAgdmFyIGVsZW1lbnQgPSB3aW4uZG9jdW1lbnQuY3JlYXRlRWxlbWVudCgnZGl2Jyk7XG4gICAgICAgICAgICAgICAgZWxlbWVudC5zZXRBdHRyaWJ1dGUoJ2lkJywnZGlkJyk7XG4gICAgICAgICAgICAgICAgLy9kb2N1bWVudC5cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhkb2N1bWVudC5ib2R5LmlubmVySFRNTCk7XG4gICAgICAgICAgICAgICAgLy9jb25zb2xlLmxvZygnRWxlbWVudDonLGVsZW1lbnQpO1xuICAgICAgICAgICAgICAgIC8vY29uc29sZS5sb2cod2luKTtcbiAgICAgICAgICAgICAgICAvL21lcm1haWQuaW5pdCgpO1xuICAgICAgICAgICAgICAgIC8vcmVuZGVyKHdpbi5kb2N1bWVudCwgJ215SWQnLCB0ZXh0LCBjYWxsYmFjayk7XG4gICAgICAgICAgICAgICAgXG4gICAgICAgICAgICB9XG4gICAgICAgIH0pOyovXG4gICAgICAgIC8vdmFyIGpzZG9tID0gcmVxdWlyZSgnanNkb20nKS5qc2RvbTtcbiAgICAgICAgLy9nbG9iYWwuZG9jdW1lbnQgPSBqc2RvbShodG1sU3R1Yik7XG4gICAgICAgIC8vZ2xvYmFsLndpbmRvdyA9IGRvY3VtZW50LnBhcmVudFdpbmRvdztcbiAgICAgICAgLy9cbiAgICAgICAgLy9yZW5kZXIoaWQsIHRleHQsIGNiKTtcbiAgICAgICAgICAgICAgICAvL3ZhciBlbGVtZW50ID0gd2luLmRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ2RpdicpO1xuICAgICAgICAgICAgICAgIC8vZWxlbWVudC5zZXRBdHRyaWJ1dGUoJ2lkJywnZGlkJyk7XG4gICAgICAgICAgICAgICAgLy9kb2N1bWVudC5cbiAgICB9XG4gICAgZWxzZXtcbiAgICAgICAgLy8gSW4gYnJvd3NlclxuICAgICAgICByZW5kZXIoIGlkLCB0ZXh0LCBjYik7XG4gICAgfVxufTtcblxuXG52YXIgc2V0Q29uZiA9IGZ1bmN0aW9uKGNuZil7XG4gICAgLy8gVG9wIGxldmVsIGluaXRpYWxseSBtZXJtYWlkLCBnZmxvdywgc2VxdWVuY2VEaWFncmFtIGFuZCBnYW50dFxuICAgIHZhciBsdmwxS2V5cyA9IE9iamVjdC5rZXlzKGNuZik7XG4gICAgdmFyIGk7XG4gICAgZm9yKGk9MDtpPGx2bDFLZXlzLmxlbmd0aDtpKyspe1xuICAgICAgICB2YXIgbHZsMktleXMgPSBPYmplY3Qua2V5cyhjbmZbbHZsMUtleXNbaV1dKTt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BpKyspIHtcbiAgICAgICAgLy8gQXZvaWQgbXVsdGlwbGUgaW5jbHVzaW9uIG9uIHBhZ2VzIHdpdGggbXVsdGlwbGUgZ3JhcGhzXG4gICAgICAgIGlmIChzaGVldHNbaV0udGl0bGUgIT09ICdtZXJtYWlkLXN2Zy1pbnRlcm5hbC1jc3MnKSB7XG4gICAgICAgICAgICB0cnkge1xuXG4gICAgICAgICAgICAgICAgdmFyIHJ1bGVzID0gc2hlZXRzW2ldLmNzc1J1bGVzO1xuICAgICAgICAgICAgICAgIGlmIChydWxlcyAhPT0gbnVsbCkge1xuICAgICAgICAgICAgICAgICAgICBmb3IgKHZhciBqID0gMDsgaiA8IHJ1bGVzLmxlbmd0aDsgaisrKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcnVsZSA9IHJ1bGVzW2pdO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZihydWxlLnN0eWxlKSAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgZWxlbXM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxlbXMgPSBzdmcucXVlcnlTZWxlY3RvckFsbChydWxlLnNlbGVjdG9yVGV4dCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGVsZW1zLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXNlZFN0eWxlcyArPSBydWxlLnNlbGVjdG9yVGV4dCArIFwiIHsgXCIgKyBydWxlLnN0eWxlLmNzc1RleHQgKyBcIiB9XFxuXCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY2F0Y2goZXJyKSB7XG4gICAgICAgICAgICAgICAgaWYodHlwZW9mIGNvbnNvbGUgIT09ICd1bmRlZmluZWQnKXtcbiAgICAgICAgICAgICAgICAgICAgaWYoY29uc29sZS53YXJuICE9PSAndW5kZWZpbmVkJyl7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZihydWxlICE9PSAndW5kZWZpbmVkJyl7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS53YXJuKCdJbnZhbGlkIENTUyBzZWxlY3RvciBcIicgKyBydWxlLnNlbGVjdG9yVGV4dCArICdcIicsIGVycik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gXG4gICAgfVxuXG4gICAgdmFyIGRlZmF1bHRTdHlsZXMgPSBcIlwiO1xuICAgIHZhciBlbWJlZGRlZFN0eWxlcyA9IFwiXCI7XG5cbiAgICBmb3IgKHZhciBjbGFzc05hbWUgaW4gY2xhc3Nlcykge1xuICAgICAgICBpZiAoY2xhc3Nlcy5oYXNPd25Qcm9wZXJ0eShjbGFzc05hbWUpICYmIHR5cGVvZihjbGFzc05hbWUpICE9IFwidW5kZWZpbmVkXCIpIHtcbiAgICAgICAgICAgIGlmIChjbGFzc05hbWUgPT09ICdkZWZhdWx0Jykge1xuICAgICAgICAgICAgICAgIGlmIChjbGFzc2VzLmRlZmF1bHQuc3R5bGVzIGluc3RhbmNlb2YgQXJyYXkpIHtcbiAgICAgICAgICAgICAgICAgICAgZGVmYXVsdFN0eWxlcyArPSBcIiNcIiArIHN2Zy5pZC50cmltKCkgKyAnIC5ub2RlJyArICcgeyAnICsgY2xhc3Nlc1tjbGFzc05hbWVdLnN0eWxlcy5qb2luKFwiOyBcIikgKyAnOyB9XFxuJztcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgaWYgKGNsYXNzZXMuZGVmYXVsdC5ub2RlTGFiZWxTdHlsZXMgaW5zdGFuY2VvZiBBcnJheSkge1xuICAgICAg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