3411 lines
788 KiB
HTML
Raw Normal View History

2025-01-12 00:52:51 +08:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Printing a tibble: Control and data flow</title>
<script>// Pandoc 2.9 adds attributes on both header and div. We remove the former (to
// be compatible with the behavior of Pandoc < 2.8).
document.addEventListener('DOMContentLoaded', function(e) {
var hs = document.querySelectorAll("div.section[class*='level'] > :first-child");
var i, h, a;
for (i = 0; i < hs.length; i++) {
h = hs[i];
if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6
a = h.attributes;
while (a.length > 0) h.removeAttribute(a[0].name);
}
});
</script>
<style type="text/css">@layer htmltools {
.html-fill-container {
display: flex;
flex-direction: column;
min-height: 0;
min-width: 0;
}
.html-fill-container > .html-fill-item {
flex: 1 1 auto;
min-height: 0;
min-width: 0;
}
.html-fill-container > :not(.html-fill-item) {
flex: 0 0 auto;
}
}
</style>
<script>(function() {
// If window.HTMLWidgets is already defined, then use it; otherwise create a
// new object. This allows preceding code to set options that affect the
// initialization process (though none currently exist).
window.HTMLWidgets = window.HTMLWidgets || {};
// See if we're running in a viewer pane. If not, we're in a web browser.
var viewerMode = window.HTMLWidgets.viewerMode =
/\bviewer_pane=1\b/.test(window.location);
// See if we're running in Shiny mode. If not, it's a static document.
// Note that static widgets can appear in both Shiny and static modes, but
// obviously, Shiny widgets can only appear in Shiny apps/documents.
var shinyMode = window.HTMLWidgets.shinyMode =
typeof(window.Shiny) !== "undefined" && !!window.Shiny.outputBindings;
// We can't count on jQuery being available, so we implement our own
// version if necessary.
function querySelectorAll(scope, selector) {
if (typeof(jQuery) !== "undefined" && scope instanceof jQuery) {
return scope.find(selector);
}
if (scope.querySelectorAll) {
return scope.querySelectorAll(selector);
}
}
function asArray(value) {
if (value === null)
return [];
if ($.isArray(value))
return value;
return [value];
}
// Implement jQuery's extend
function extend(target /*, ... */) {
if (arguments.length == 1) {
return target;
}
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var prop in source) {
if (source.hasOwnProperty(prop)) {
target[prop] = source[prop];
}
}
}
return target;
}
// IE8 doesn't support Array.forEach.
function forEach(values, callback, thisArg) {
if (values.forEach) {
values.forEach(callback, thisArg);
} else {
for (var i = 0; i < values.length; i++) {
callback.call(thisArg, values[i], i, values);
}
}
}
// Replaces the specified method with the return value of funcSource.
//
// Note that funcSource should not BE the new method, it should be a function
// that RETURNS the new method. funcSource receives a single argument that is
// the overridden method, it can be called from the new method. The overridden
// method can be called like a regular function, it has the target permanently
// bound to it so "this" will work correctly.
function overrideMethod(target, methodName, funcSource) {
var superFunc = target[methodName] || function() {};
var superFuncBound = function() {
return superFunc.apply(target, arguments);
};
target[methodName] = funcSource(superFuncBound);
}
// Add a method to delegator that, when invoked, calls
// delegatee.methodName. If there is no such method on
// the delegatee, but there was one on delegator before
// delegateMethod was called, then the original version
// is invoked instead.
// For example:
//
// var a = {
// method1: function() { console.log('a1'); }
// method2: function() { console.log('a2'); }
// };
// var b = {
// method1: function() { console.log('b1'); }
// };
// delegateMethod(a, b, "method1");
// delegateMethod(a, b, "method2");
// a.method1();
// a.method2();
//
// The output would be "b1", "a2".
function delegateMethod(delegator, delegatee, methodName) {
var inherited = delegator[methodName];
delegator[methodName] = function() {
var target = delegatee;
var method = delegatee[methodName];
// The method doesn't exist on the delegatee. Instead,
// call the method on the delegator, if it exists.
if (!method) {
target = delegator;
method = inherited;
}
if (method) {
return method.apply(target, arguments);
}
};
}
// Implement a vague facsimilie of jQuery's data method
function elementData(el, name, value) {
if (arguments.length == 2) {
return el["htmlwidget_data_" + name];
} else if (arguments.length == 3) {
el["htmlwidget_data_" + name] = value;
return el;
} else {
throw new Error("Wrong number of arguments for elementData: " +
arguments.length);
}
}
// http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex
function escapeRegExp(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
}
function hasClass(el, className) {
var re = new RegExp("\\b" + escapeRegExp(className) + "\\b");
return re.test(el.className);
}
// elements - array (or array-like object) of HTML elements
// className - class name to test for
// include - if true, only return elements with given className;
// if false, only return elements *without* given className
function filterByClass(elements, className, include) {
var results = [];
for (var i = 0; i < elements.length; i++) {
if (hasClass(elements[i], className) == include)
results.push(elements[i]);
}
return results;
}
function on(obj, eventName, func) {
if (obj.addEventListener) {
obj.addEventListener(eventName, func, false);
} else if (obj.attachEvent) {
obj.attachEvent(eventName, func);
}
}
function off(obj, eventName, func) {
if (obj.removeEventListener)
obj.removeEventListener(eventName, func, false);
else if (obj.detachEvent) {
obj.detachEvent(eventName, func);
}
}
// Translate array of values to top/right/bottom/left, as usual with
// the "padding" CSS property
// https://developer.mozilla.org/en-US/docs/Web/CSS/padding
function unpackPadding(value) {
if (typeof(value) === "number")
value = [value];
if (value.length === 1) {
return {top: value[0], right: value[0], bottom: value[0], left: value[0]};
}
if (value.length === 2) {
return {top: value[0], right: value[1], bottom: value[0], left: value[1]};
}
if (value.length === 3) {
return {top: value[0], right: value[1], bottom: value[2], left: value[1]};
}
if (value.length === 4) {
return {top: value[0], right: value[1], bottom: value[2], left: value[3]};
}
}
// Convert an unpacked padding object to a CSS value
function paddingToCss(paddingObj) {
return paddingObj.top + "px " + paddingObj.right + "px " + paddingObj.bottom + "px " + paddingObj.left + "px";
}
// Makes a number suitable for CSS
function px(x) {
if (typeof(x) === "number")
return x + "px";
else
return x;
}
// Retrieves runtime widget sizing information for an element.
// The return value is either null, or an object with fill, padding,
// defaultWidth, defaultHeight fields.
function sizingPolicy(el) {
var sizingEl = document.querySelector("script[data-for='" + el.id + "'][type='application/htmlwidget-sizing']");
if (!sizingEl)
return null;
var sp = JSON.parse(sizingEl.textContent || sizingEl.text || "{}");
if (viewerMode) {
return sp.viewer;
} else {
return sp.browser;
}
}
// @param tasks Array of strings (or falsy value, in which case no-op).
// Each element must be a valid JavaScript expression that yields a
// function. Or, can be an array of objects with "code" and "data"
// properties; in this case, the "code" property should be a string
// of JS that's an expr that yields a function, and "data" should be
// an object that will be added as an additional argument when that
// function is called.
// @param target The object that will be "this" for each function
// execution.
// @param args Array of arguments to be passed to the functions. (The
// same arguments will be passed to all functions.)
function evalAndRun(tasks, target, args) {
if (tasks) {
forEach(tasks, function(task) {
var theseArgs = args;
if (typeof(task) === "object") {
theseArgs = theseArgs.concat([task.data]);
task = task.code;
}
var taskFunc = tryEval(task);
if (typeof(taskFunc) !== "function") {
throw new Error("Task must be a function! Source:\n" + task);
}
taskFunc.apply(target, theseArgs);
});
}
}
// Attempt eval() both with and without enclosing in parentheses.
// Note that enclosing coerces a function declaration into
// an expression that eval() can parse
// (otherwise, a SyntaxError is thrown)
function tryEval(code) {
var result = null;
try {
result = eval("(" + code + ")");
} catch(error) {
if (!(error instanceof SyntaxError)) {
throw error;
}
try {
result = eval(code);
} catch(e) {
if (e instanceof SyntaxError) {
throw error;
} else {
throw e;
}
}
}
return result;
}
function initSizing(el) {
var sizing = sizingPolicy(el);
if (!sizing)
return;
var cel = document.getElementById("htmlwidget_container");
if (!cel)
return;
if (typeof(sizing.padding) !== "undefined") {
document.body.style.margin = "0";
document.body.style.padding = paddingToCss(unpackPadding(sizing.padding));
}
if (sizing.fill) {
document.body.style.overflow = "hidden";
document.body.style.width = "100%";
document.body.style.height = "100%";
document.documentElement.style.width = "100%";
document.documentElement.style.height = "100%";
cel.style.position = "absolute";
var pad = unpackPadding(sizing.padding);
cel.style.top = pad.top + "px";
cel.style.right = pad.right + "px";
cel.style.bottom = pad.bottom + "px";
cel.style.left = pad.left + "px";
el.style.width = "100%";
el.style.height = "100%";
return {
getWidth: function() { return cel.getBoundingClientRect().width; },
getHeight: function() { return cel.getBoundingClientRect().height; }
};
} else {
el.style.width = px(sizing.width);
el.style.height = px(sizing.height);
return {
getWidth: function() { return cel.getBoundingClientRect().width; },
getHeight: function() { return cel.getBoundingClientRect().height; }
};
}
}
// Default implementations for methods
var defaults = {
find: function(scope) {
return querySelectorAll(scope, "." + this.name);
},
renderError: function(el, err) {
var $el = $(el);
this.clearError(el);
// Add all these error classes, as Shiny does
var errClass = "shiny-output-error";
if (err.type !== null) {
// use the classes of the error condition as CSS class names
errClass = errClass + " " + $.map(asArray(err.type), function(type) {
return errClass + "-" + type;
}).join(" ");
}
errClass = errClass + " htmlwidgets-error";
// Is el inline or block? If inline or inline-block, just display:none it
// and add an inline error.
var display = $el.css("display");
$el.data("restore-display-mode", display);
if (display === "inline" || display === "inline-block") {
$el.hide();
if (err.message !== "") {
var errorSpan = $("<span>").addClass(errClass);
errorSpan.text(err.message);
$el.after(errorSpan);
}
} else if (display === "block") {
// If block, add an error just after the el, set visibility:none on the
// el, and position the error to be on top of the el.
// Mark it with a unique ID and CSS class so we can remove it later.
$el.css("visibility", "hidden");
if (err.message !== "") {
var errorDiv = $("<div>").addClass(errClass).css("position", "absolute")
.css("top", el.offsetTop)
.css("left", el.offsetLeft)
// setting width can push out the page size, forcing otherwise
// unnecessary scrollbars to appear and making it impossible for
// the element to shrink; so use max-width instead
.css("maxWidth", el.offsetWidth)
.css("height", el.offsetHeight);
errorDiv.text(err.message);
$el.after(errorDiv);
// Really dumb way to keep the size/position of the error in sync with
// the parent element as the window is resized or whatever.
var intId = setInterval(function() {
if (!errorDiv[0].parentElement) {
clearInterval(intId);
return;
}
errorDiv
.css("top", el.offsetTop)
.css("left", el.offsetLeft)
.css("maxWidth", el.offsetWidth)
.css("height", el.offsetHeight);
}, 500);
}
}
},
clearError: function(el) {
var $el = $(el);
var display = $el.data("restore-display-mode");
$el.data("restore-display-mode", null);
if (display === "inline" || display === "inline-block") {
if (display)
$el.css("display", display);
$(el.nextSibling).filter(".htmlwidgets-error").remove();
} else if (display === "block"){
$el.css("visibility", "inherit");
$(el.nextSibling).filter(".htmlwidgets-error").remove();
}
},
sizing: {}
};
// Called by widget bindings to register a new type of widget. The definition
// object can contain the following properties:
// - name (required) - A string indicating the binding name, which will be
// used by default as the CSS classname to look for.
// - initialize (optional) - A function(el) that will be called once per
// widget element; if a value is returned, it will be passed as the third
// value to renderValue.
// - renderValue (required) - A function(el, data, initValue) that will be
// called with data. Static contexts will cause this to be called once per
// element; Shiny apps will cause this to be called multiple times per
// element, as the data changes.
window.HTMLWidgets.widget = function(definition) {
if (!definition.name) {
throw new Error("Widget must have a name");
}
if (!definition.type) {
throw new Error("Widget must have a type");
}
// Currently we only support output widgets
if (definition.type !== "output") {
throw new Error("Unrecognized widget type '" + definition.type + "'");
}
// TODO: Verify that .name is a valid CSS classname
// Support new-style instance-bound definitions. Old-style class-bound
// definitions have one widget "object" per widget per type/class of
// widget; the renderValue and resize methods on such widget objects
// take el and instance arguments, because the widget object can't
// store them. New-style instance-bound definitions have one widget
// object per widget instance; the definition that's passed in doesn't
// provide renderValue or resize methods at all, just the single method
// factory(el, width, height)
// which returns an object that has renderValue(x) and resize(w, h).
// This enables a far more natural programming style for the widget
// author, who can store per-instance state using either OO-style
// instance fields or functional-style closure variables (I guess this
// is in contrast to what can only be called C-style pseudo-OO which is
// what we required before).
if (definition.factory) {
definition = createLegacyDefinitionAdapter(definition);
}
if (!definition.renderValue) {
throw new Error("Widget must have a renderValue function");
}
// For static rendering (non-Shiny), use a simple widget registration
// scheme. We also use this scheme for Shiny apps/documents that also
// contain static widgets.
window.HTMLWidgets.widgets = window.HTMLWidgets.widgets || [];
// Merge defaults into the definition; don't mutate the original definition.
var staticBinding = extend({}, defaults, definition);
overrideMethod(staticBinding, "find", function(superfunc) {
return function(scope) {
var results = superfunc(scope);
// Filter out Shiny outputs, we only want the static kind
return filterByClass(results, "html-widget-output", false);
};
});
window.HTMLWidgets.widgets.push(staticBinding);
if (shinyMode) {
// Shiny is running. Register the definition with an output binding.
// The definition itself will not be the output binding, instead
// we will make an output binding object that delegates to the
// definition. This is because we foolishly used the same method
// name (renderValue) for htmlwidgets definition and Shiny bindings
// but they actually have quite different semantics (the Shiny
// bindings receive data that includes lots of metadata that it
// strips off before calling htmlwidgets renderValue). We can't
// just ignore the difference because in some widgets it's helpful
// to call this.renderValue() from inside of resize(), and if
// we're not delegating, then that call will go to the Shiny
// version instead of the htmlwidgets version.
// Merge defaults with definition, without mutating either.
var bindingDef = extend({}, defaults, definition);
// This object will be our actual Shiny binding.
var shinyBinding = new Shiny.OutputBinding();
// With a few exceptions, we'll want to simply use the bindingDef's
// version of methods if they are available, otherwise fall back to
// Shiny's defaults. NOTE: If Shiny's output bindings gain additional
// methods in the future, and we want them to be overrideable by
// HTMLWidget binding definitions, then we'll need to add them to this
// list.
delegateMethod(shinyBinding, bindingDef, "getId");
delegateMethod(shinyBinding, bindingDef, "onValueChange");
delegateMethod(shinyBinding, bindingDef, "onValueError");
delegateMethod(shinyBinding, bindingDef, "renderError");
delegateMethod(shinyBinding, bindingDef, "clearError");
delegateMethod(shinyBinding, bindingDef, "showProgress");
// The find, renderValue, and resize are handled differently, because we
// want to actually decorate the behavior of the bindingDef methods.
shinyBinding.find = function(scope) {
var results = bindingDef.find(scope);
// Only return elements that are Shiny outputs, not static ones
var dynamicResults = results.filter(".html-widget-output");
// It's possible that whatever caused Shiny to think there might be
// new dynamic outputs, also caused there to be new static outputs.
// Since there might be lots of different htmlwidgets bindings, we
// schedule execution for later--no need to staticRender multiple
// times.
if (results.length !== dynamicResults.length)
scheduleStaticRender();
return dynamicResults;
};
// Wrap renderValue to handle initialization, which unfortunately isn't
// supported natively by Shiny at the time of this writing.
shinyBinding.renderValue = function(el, data) {
Shiny.renderDependencies(data.deps);
// Resolve strings marked as javascript literals to objects
if (!(data.evals instanceof Array)) data.evals = [data.evals];
for (var i = 0; data.evals && i < data.evals.length; i++) {
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[i]);
}
if (!bindingDef.renderOnNullValue) {
if (data.x === null) {
el.style.visibility = "hidden";
return;
} else {
el.style.visibility = "inherit";
}
}
if (!elementData(el, "initialized")) {
initSizing(el);
elementData(el, "initialized", true);
if (bindingDef.initialize) {
var rect = el.getBoundingClientRect();
var result = bindingDef.initialize(el, rect.width, rect.height);
elementData(el, "init_result", result);
}
}
bindingDef.renderValue(el, data.x, elementData(el, "init_result"));
evalAndRun(data.jsHooks.render, elementData(el, "init_result"), [el, data.x]);
};
// Only override resize if bindingDef implements it
if (bindingDef.resize) {
shinyBinding.resize = function(el, width, height) {
// Shiny can call resize before initialize/renderValue have been
// called, which doesn't make sense for widgets.
if (elementData(el, "initialized")) {
bindingDef.resize(el, width, height, elementData(el, "init_result"));
}
};
}
Shiny.outputBindings.register(shinyBinding, bindingDef.name);
}
};
var scheduleStaticRenderTimerId = null;
function scheduleStaticRender() {
if (!scheduleStaticRenderTimerId) {
scheduleStaticRenderTimerId = setTimeout(function() {
scheduleStaticRenderTimerId = null;
window.HTMLWidgets.staticRender();
}, 1);
}
}
// Render static widgets after the document finishes loading
// Statically render all elements that are of this widget's class
window.HTMLWidgets.staticRender = function() {
var bindings = window.HTMLWidgets.widgets || [];
forEach(bindings, function(binding) {
var matches = binding.find(document.documentElement);
forEach(matches, function(el) {
var sizeObj = initSizing(el, binding);
var getSize = function(el) {
if (sizeObj) {
return {w: sizeObj.getWidth(), h: sizeObj.getHeight()}
} else {
var rect = el.getBoundingClientRect();
return {w: rect.width, h: rect.height}
}
};
if (hasClass(el, "html-widget-static-bound"))
return;
el.className = el.className + " html-widget-static-bound";
var initResult;
if (binding.initialize) {
var size = getSize(el);
initResult = binding.initialize(el, size.w, size.h);
elementData(el, "init_result", initResult);
}
if (binding.resize) {
var lastSize = getSize(el);
var resizeHandler = function(e) {
var size = getSize(el);
if (size.w === 0 && size.h === 0)
return;
if (size.w === lastSize.w && size.h === lastSize.h)
return;
lastSize = size;
binding.resize(el, size.w, size.h, initResult);
};
on(window, "resize", resizeHandler);
// This is needed for cases where we're running in a Shiny
// app, but the widget itself is not a Shiny output, but
// rather a simple static widget. One example of this is
// an rmarkdown document that has runtime:shiny and widget
// that isn't in a render function. Shiny only knows to
// call resize handlers for Shiny outputs, not for static
// widgets, so we do it ourselves.
if (window.jQuery) {
window.jQuery(document).on(
"shown.htmlwidgets shown.bs.tab.htmlwidgets shown.bs.collapse.htmlwidgets",
resizeHandler
);
window.jQuery(document).on(
"hidden.htmlwidgets hidden.bs.tab.htmlwidgets hidden.bs.collapse.htmlwidgets",
resizeHandler
);
}
// This is needed for the specific case of ioslides, which
// flips slides between display:none and display:block.
// Ideally we would not have to have ioslide-specific code
// here, but rather have ioslides raise a generic event,
// but the rmarkdown package just went to CRAN so the
// window to getting that fixed may be long.
if (window.addEventListener) {
// It's OK to limit this to window.addEventListener
// browsers because ioslides itself only supports
// such browsers.
on(document, "slideenter", resizeHandler);
on(document, "slideleave", resizeHandler);
}
}
var scriptData = document.querySelector("script[data-for='" + el.id + "'][type='application/json']");
if (scriptData) {
var data = JSON.parse(scriptData.textContent || scriptData.text);
// Resolve strings marked as javascript literals to objects
if (!(data.evals instanceof Array)) data.evals = [data.evals];
for (var k = 0; data.evals && k < data.evals.length; k++) {
window.HTMLWidgets.evaluateStringMember(data.x, data.evals[k]);
}
binding.renderValue(el, data.x, initResult);
evalAndRun(data.jsHooks.render, initResult, [el, data.x]);
}
});
});
invokePostRenderHandlers();
}
function has_jQuery3() {
if (!window.jQuery) {
return false;
}
var $version = window.jQuery.fn.jquery;
var $major_version = parseInt($version.split(".")[0]);
return $major_version >= 3;
}
/*
/ Shiny 1.4 bumped jQuery from 1.x to 3.x which means jQuery's
/ on-ready handler (i.e., $(fn)) is now asyncronous (i.e., it now
/ really means $(setTimeout(fn)).
/ https://jquery.com/upgrade-guide/3.0/#breaking-change-document-ready-handlers-are-now-asynchronous
/
/ Since Shiny uses $() to schedule initShiny, shiny>=1.4 calls initShiny
/ one tick later than it did before, which means staticRender() is
/ called renderValue() earlier than (advanced) widget authors might be expecting.
/ https://github.com/rstudio/shiny/issues/2630
/
/ For a concrete example, leaflet has some methods (e.g., updateBounds)
/ which reference Shiny methods registered in initShiny (e.g., setInputValue).
/ Since leaflet is privy to this life-cycle, it knows to use setTimeout() to
/ delay execution of those methods (until Shiny methods are ready)
/ https://github.com/rstudio/leaflet/blob/18ec981/javascript/src/index.js#L266-L268
/
/ Ideally widget authors wouldn't need to use this setTimeout() hack that
/ leaflet uses to call Shiny methods on a staticRender(). In the long run,
/ the logic initShiny should be broken up so that method registration happens
/ right away, but binding happens later.
*/
function maybeStaticRenderLater() {
if (shinyMode && has_jQuery3()) {
window.jQuery(window.HTMLWidgets.staticRender);
} else {
window.HTMLWidgets.staticRender();
}
}
if (document.addEventListener) {
document.addEventListener("DOMContentLoaded", function() {
document.removeEventListener("DOMContentLoaded", arguments.callee, false);
maybeStaticRenderLater();
}, false);
} else if (document.attachEvent) {
document.attachEvent("onreadystatechange", function() {
if (document.readyState === "complete") {
document.detachEvent("onreadystatechange", arguments.callee);
maybeStaticRenderLater();
}
});
}
window.HTMLWidgets.getAttachmentUrl = function(depname, key) {
// If no key, default to the first item
if (typeof(key) === "undefined")
key = 1;
var link = document.getElementById(depname + "-" + key + "-attachment");
if (!link) {
throw new Error("Attachment " + depname + "/" + key + " not found in document");
}
return link.getAttribute("href");
};
window.HTMLWidgets.dataframeToD3 = function(df) {
var names = [];
var length;
for (var name in df) {
if (df.hasOwnProperty(name))
names.push(name);
if (typeof(df[name]) !== "object" || typeof(df[name].length) === "undefined") {
throw new Error("All fields must be arrays");
} else if (typeof(length) !== "undefined" && length !== df[name].length) {
throw new Error("All fields must be arrays of the same length");
}
length = df[name].length;
}
var results = [];
var item;
for (var row = 0; row < length; row++) {
item = {};
for (var col = 0; col < names.length; col++) {
item[names[col]] = df[names[col]][row];
}
results.push(item);
}
return results;
};
window.HTMLWidgets.transposeArray2D = function(array) {
if (array.length === 0) return array;
var newArray = array[0].map(function(col, i) {
return array.map(function(row) {
return row[i]
})
});
return newArray;
};
// Split value at splitChar, but allow splitChar to be escaped
// using escapeChar. Any other characters escaped by escapeChar
// will be included as usual (including escapeChar itself).
function splitWithEscape(value, splitChar, escapeChar) {
var results = [];
var escapeMode = false;
var currentResult = "";
for (var pos = 0; pos < value.length; pos++) {
if (!escapeMode) {
if (value[pos] === splitChar) {
results.push(currentResult);
currentResult = "";
} else if (value[pos] === escapeChar) {
escapeMode = true;
} else {
currentResult += value[pos];
}
} else {
currentResult += value[pos];
escapeMode = false;
}
}
if (currentResult !== "") {
results.push(currentResult);
}
return results;
}
// Function authored by Yihui/JJ Allaire
window.HTMLWidgets.evaluateStringMember = function(o, member) {
var parts = splitWithEscape(member, '.', '\\');
for (var i = 0, l = parts.length; i < l; i++) {
var part = parts[i];
// part may be a character or 'numeric' member name
if (o !== null && typeof o === "object" && part in o) {
if (i == (l - 1)) { // if we are at the end of the line then evalulate
if (typeof o[part] === "string")
o[part] = tryEval(o[part]);
} else { // otherwise continue to next embedded object
o = o[part];
}
}
}
};
// Retrieve the HTMLWidget instance (i.e. the return value of an
// HTMLWidget binding's initialize() or factory() function)
// associated with an element, or null if none.
window.HTMLWidgets.getInstance = function(el) {
return elementData(el, "init_result");
};
// Finds the first element in the scope that matches the selector,
// and returns the HTMLWidget instance (i.e. the return value of
// an HTMLWidget binding's initialize() or factory() function)
// associated with that element, if any. If no element matches the
// selector, or the first matching element has no HTMLWidget
// instance associated with it, then null is returned.
//
// The scope argument is optional, and defaults to window.document.
window.HTMLWidgets.find = function(scope, selector) {
if (arguments.length == 1) {
selector = scope;
scope = document;
}
var el = scope.querySelector(selector);
if (el === null) {
return null;
} else {
return window.HTMLWidgets.getInstance(el);
}
};
// Finds all elements in the scope that match the selector, and
// returns the HTMLWidget instances (i.e. the return values of
// an HTMLWidget binding's initialize() or factory() function)
// associated with the elements, in an array. If elements that
// match the selector don't have an associated HTMLWidget
// instance, the returned array will contain nulls.
//
// The scope argument is optional, and defaults to window.document.
window.HTMLWidgets.findAll = function(scope, selector) {
if (arguments.length == 1) {
selector = scope;
scope = document;
}
var nodes = scope.querySelectorAll(selector);
var results = [];
for (var i = 0; i < nodes.length; i++) {
results.push(window.HTMLWidgets.getInstance(nodes[i]));
}
return results;
};
var postRenderHandlers = [];
function invokePostRenderHandlers() {
while (postRenderHandlers.length) {
var handler = postRenderHandlers.shift();
if (handler) {
handler();
}
}
}
// Register the given callback function to be invoked after the
// next time static widgets are rendered.
window.HTMLWidgets.addPostRenderHandler = function(callback) {
postRenderHandlers.push(callback);
};
// Takes a new-style instance-bound definition, and returns an
// old-style class-bound definition. This saves us from having
// to rewrite all the logic in this file to accomodate both
// types of definitions.
function createLegacyDefinitionAdapter(defn) {
var result = {
name: defn.name,
type: defn.type,
initialize: function(el, width, height) {
return defn.factory(el, width, height);
},
renderValue: function(el, x, instance) {
return instance.renderValue(x);
},
resize: function(el, width, height, instance) {
return instance.resize(width, height);
}
};
if (defn.find)
result.find = defn.find;
if (defn.renderError)
result.renderError = defn.renderError;
if (defn.clearError)
result.clearError = defn.clearError;
return result;
}
})();
</script>
<script>!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===da||n[0]===ma?ma+n:n}function l(n){return(n+="")[0]===ma?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object.create(null)}function d(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function m(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=ya.length;r>e;++e){var u=ya[e]+t;if(u in n)return u}}function y(){}function M(){}function x(n){function t(){for(var t,r=e,u=-1,i=r.length;++u<i;)(t=r[u].on)&&t.apply(this,arguments);return n}var e=[],r=new a;return t.on=function(t,u){var i,o=r.get(t);return arguments.length<2?o&&o.on:(o&&(o.on=null,e=e.slice(0,i=e.indexOf(o)).concat(e.slice(i+1)),r.remove(t)),u&&e.push(r.set(t,{on:u})),n)},t}function b(){ta.event.preventDefault()}function _(){for(var n,t=ta.event;n=t.sourceEvent;)t=n;return t}function w(n){for(var t=new M,e=0,r=arguments.length;++e<r;)t[arguments[e]]=x(t);return t.of=function(e,r){return function(u){try{var i=u.sourceEvent=ta.event;u.target=n,ta.event=u,t[u.type].apply(e,r)}finally{ta.event=i}}},t}function S(n){return xa(n,ka),n}function k(n){return"function"==typeof n?n:function(){return ba(n,this)}}function E(n){return"function"==typeof n?n:function(){return _a(n,this)}}function A(n,t){function e(){this.removeAttribute(n)}function r(){this.removeAttributeNS(n.space,n.local)}function u(){this.setAttribute(n,t)}function i(){this.setAttributeNS(n.space,n.local,t)}function o(){var e=t.apply(this,arguments);null==e?this.removeAttribute(n):this.setAttribute(n,e)}function a(){var e=t.apply(this,arguments);null==e?this.removeAttributeNS(n.space,n.local):this.setAttributeNS(n.space,n.local,e)}return n=ta.ns.qualify(n),null==t?n.local?r:e:"function"==typeof t?n.local?a:o:n.local?i:u}function N(n){return n.trim().replace(/\s+/g," ")}function C(n){return new RegExp("(?:^|\\s+)"+ta.requote(n)+"(?:\\s+|$)","g")}function z(n){return(n+"").trim().split(/^|\s+/)}function q(n,t){function e(){for(var e=-1;++e<u;)n[e](this,t)}function r(){for(var e=-1,r=t.apply(this,arguments);++e<u;)n[e](this,r)}n=z(n).map(L);var u=n.length;return"function"==typeof t?r:e}function L(n){var t=C(n);return function(e,r){if(u=e.classList)return r?u.add(n):u.remove(n);var u=e.getAttribute("class")||"";r?(t.lastIndex=0,t.test(u)||e.setAttribute("class",N(u+" "+n))):e.setAttribute("class",N(u.replace(t," ")))}}function T(n,t,e){function r(){this.style.removeProperty(n)}function u(){this.style.setProperty(n,t,e)}function i(){var r=t.apply(this,arguments);null==r?this.style.removeProperty(n):this.style.setProperty(n,r,e)}return null==t?r:"function"==typeof t?i:u}function R(n,t){function e(){delete this[n]}function r(){this[n]=t}function u(){var e=t.apply(this,arguments);null==e?delete this[n]:this[n]=e}return null==t?e:"function"==typeof t?u:r}function D(n){return"function"==typeof n?n:(n=ta.ns.qualify(n)).local?function(){return this.ownerDocument.createElementNS(n.space,n.local)}:function(){return this.ownerDocument.createElementNS(this.namespaceURI,n)}}function P(){var n=this.parentNode;n&&n.removeChild(this)}function U(n){return{__data__:n}}function j(n){return function(){return Sa(this,n)}}function F(t){return arguments.length||(t=n),function(n,e){re
(L*L/x>i||va((y*z+M*q)/x-.5)>.3||o>a*g+c*p+l*v)&&(u(t,e,r,a,c,l,N,C,E,b/=S,_/=S,w,d,m),m.point(N,C),u(N,C,E,b,_,w,s,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*Fa),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function tr(n){var t=nr(function(t,e){return n([t*Ha,e*Ha])});return function(n){return or(t(n))}}function er(n){this.stream=n}function rr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ur(n){return ir(function(){return n})()}function ir(n){function t(n){return n=a(n[0]*Fa,n[1]*Fa),[n[0]*h+c,l-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Ha,n[1]*Ha]}function r(){a=Ae(o=lr(m,y,M),i);var n=i(v,d);return c=g-n[0]*h,l=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,o,a,c,l,s,f=nr(function(n,t){return n=i(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,M=0,x=Pc,b=Et,_=null,w=null;return t.stream=function(n){return s&&(s.valid=!1),s=or(x(o,f(b(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(x=null==n?(_=n,Pc):He((_=+n)*Fa),u()):_},t.clipExtent=function(n){return arguments.length?(w=n,b=n?Ye(n[0][0],n[0][1],n[1][0],n[1][1]):Et,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Fa,d=n[1]%360*Fa,r()):[v*Ha,d*Ha]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Fa,y=n[1]%360*Fa,M=n.length>2?n[2]%360*Fa:0,r()):[m*Ha,y*Ha,M*Ha]},ta.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function or(n){return rr(n,function(t,e){n.point(t*Fa,e*Fa)})}function ar(n,t){return[n,t]}function cr(n,t){return[n>Da?n-Pa:-Da>n?n+Pa:n,t]}function lr(n,t,e){return n?t||e?Ae(fr(n),hr(t,e)):fr(n):t||e?hr(t,e):cr}function sr(n){return function(t,e){return t+=n,[t>Da?t-Pa:-Da>t?t+Pa:t,e]}}function fr(n){var t=sr(n);return t.invert=sr(-n),t}function hr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*r+a*u;return[Math.atan2(c*i-s*o,a*r-l*u),nt(s*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*i-c*o;return[Math.atan2(c*i+l*o,a*r+s*u),nt(s*r-a*u)]},e}function gr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=pr(e,u),i=pr(e,i),(o>0?i>u:u>i)&&(u+=o*Pa)):(u=n+o*Pa,i=n-.5*c);for(var l,s=u;o>0?s>i:i>s;s-=c)a.point((l=xe([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],l[1])}}function pr(n,t){var e=pe(t);e[0]-=n,Me(e);var r=Q(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Ta)%(2*Math.PI)}function vr(n,t,e){var r=ta.range(n,t-Ta,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function dr(n,t,e){var r=ta.range(n,t-Ta,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function mr(n){return n.source}function yr(n){return n.target}function Mr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),l=u*Math.sin(n),s=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(ut(r-t)+u*o*ut(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*s,u=e*l+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Ha,Math.atan2(o,Math.sqrt(r*r+u*u))*Ha]}:function(){return[n*Ha,t*Ha]};return p.distance=h,p}function xr(){function n(n,u){var i=Math.sin(u*=Fa),o=Math.cos(u),a=va((n*=Fa)-t),c=Math.cos(a);$c+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Bc.point=function(u,i){t=u*Fa,e=Math.sin(i*=Fa),r=Math.cos(i),Bc.point=n},Bc.lineEnd=function(){Bc.point=Bc.lineEnd=y}}function br(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asi
},t.tension=function(n){return arguments.length?(f=n,t):f},t}function Po(n){return n.radius}function Uo(n){return[n.x,n.y]}function jo(n){return function(){var t=n.apply(this,arguments),e=t[0],r=t[1]-ja;return[e*Math.cos(r),e*Math.sin(r)]}}function Fo(){return 64}function Ho(){return"circle"}function Oo(n){var t=Math.sqrt(n/Da);return"M0,"+t+"A"+t+","+t+" 0 1,1 0,"+-t+"A"+t+","+t+" 0 1,1 0,"+t+"Z"}function Yo(n){return function(){var t,e;(t=this[n])&&(e=t[t.active])&&(--t.count?(delete t[t.active],t.active+=.5):delete this[n],e.event&&e.event.interrupt.call(this,this.__data__,e.index))}}function Io(n,t,e){return xa(n,Hl),n.namespace=t,n.id=e,n}function Zo(n,t,e,r){var u=n.id,i=n.namespace;return H(n,"function"==typeof e?function(n,o,a){n[i][u].tween.set(t,r(e.call(n,n.__data__,o,a)))}:(e=r(e),function(n){n[i][u].tween.set(t,e)}))}function Vo(n){return null==n&&(n=""),function(){this.textContent=n}}function Xo(n){return null==n?"__transition__":"__transition_"+n+"__"}function $o(n,t,e,r,u){var i=n[e]||(n[e]={active:0,count:0}),o=i[r];if(!o){var c=u.time;o=i[r]={tween:new a,time:c,delay:u.delay,duration:u.duration,ease:u.ease,index:t},u=null,++i.count,ta.timer(function(u){function a(e){if(i.active>r)return s();var u=i[i.active];u&&(--i.count,delete i[i.active],u.event&&u.event.interrupt.call(n,n.__data__,u.index)),i.active=r,o.event&&o.event.start.call(n,n.__data__,t),o.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&v.push(r)}),h=o.ease,f=o.duration,ta.timer(function(){return p.c=l(e||1)?Ne:l,1},0,c)}function l(e){if(i.active!==r)return 1;for(var u=e/f,a=h(u),c=v.length;c>0;)v[--c].call(n,a);return u>=1?(o.event&&o.event.end.call(n,n.__data__,t),s()):void 0}function s(){return--i.count?delete i[r]:delete n[e],1}var f,h,g=o.delay,p=oc,v=[];return p.t=g+c,u>=g?a(u-g):(p.c=a,void 0)},0,c)}}function Bo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Wo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Jo(n){return n.toISOString()}function Go(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=ta.bisect(Wl,u);return i==Wl.length?[t.year,Vi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Wl[i-1]<Wl[i]/u?i-1:i]:[Kl,Vi(n,e)[2]]}return r.invert=function(t){return Ko(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain(t),r):n.domain().map(Ko)},r.nice=function(n,t){function e(e){return!isNaN(e)&&!n.range(e,Ko(+e+1),t).length}var i=r.domain(),o=Pi(i),a=null==n?u(o,10):"number"==typeof n&&u(o,n);return a&&(n=a[0],t=a[1]),r.domain(Fi(i,t>1?{floor:function(t){for(;e(t=n.floor(t));)t=Ko(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Ko(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Pi(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Ko(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Go(n.copy(),t,e)},Ii(r,n)}function Ko(n){return new Date(n)}function Qo(n){return JSON.parse(n.responseText)}function na(n){var t=ua.createRange();return t.selectNode(ua.body),t.createContextualFragment(n.responseText)}var ta={version:"3.5.2"};Date.now||(Date.now=function(){return+new Date});var ea=[].slice,ra=function(n){return ea.call(n)},ua=document,ia=ua.documentElement,oa=window;try{ra(ia.childNodes)[0].nodeType}catch(aa){ra=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{ua.createElement("div").style.setProperty("opacity",0,"")}catch(ca){var la=oa.Element.prototype,sa=la.setAttribute,fa=la.setAttributeNS,ha=oa.CSSStyleDeclaration.prototype,ga=ha.setProperty;la.setAttribute=function(n,t){sa.call(this,n,t+"")},la.setAttributeNS=function(n,t,e){fa.call(this,n,t,e+"")},ha.setProperty=function(n,t,e){ga.call(this,n,t+"",e)}}ta.ascending=n,ta.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},ta.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u<i;)if(null!=(r=n[u])&&r>=r){e=r;break}for(;++u<i;)null!=(r=n[u])&&e>r&&(e=r)}else{for(;++
},LineString:function(n,t){fe(n.coordinates,t,0)},MultiLineString:function(n,t){for(var e=n.coordinates,r=-1,u=e.length;++r<u;)fe(e[r],t,0)},Polygon:function(n,t){he(n.coordinates,t)},MultiPolygon:function(n,t){for(var e=n.coordinates,r=-1,u=e.length;++r<u;)he(e[r],t)},GeometryCollection:function(n,t){for(var e=n.geometries,r=-1,u=e.length;++r<u;)se(e[r],t)}};ta.geo.area=function(n){return bc=0,ta.geo.stream(n,wc),bc};var bc,_c=new ce,wc={sphere:function(){bc+=4*Da},point:y,lineStart:y,lineEnd:y,polygonStart:function(){_c.reset(),wc.lineStart=ge},polygonEnd:function(){var n=2*_c;bc+=0>n?4*Da+n:n,wc.lineStart=wc.lineEnd=wc.point=y}};ta.geo.bounds=function(){function n(n,t){M.push(x=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=pe([t*Fa,e*Fa]);if(m){var u=de(m,r),i=[u[1],-u[0],0],o=de(i,u);Me(o),o=xe(o);var c=t-p,l=c>0?1:-1,v=o[0]*Ha*l,d=va(c)>180;if(d^(v>l*p&&l*t>v)){var y=o[1]*Ha;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>l*p&&l*t>v)){var y=-o[1]*Ha;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){b.point=t}function r(){x[0]=s,x[1]=h,b.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=va(r)>180?r+(r>0?360:-360):r}else v=n,d=e;wc.point(n,e),t(n,e)}function i(){wc.lineStart()}function o(){u(v,d),wc.lineEnd(),va(y)>Ta&&(s=-(h=180)),x[0]=s,x[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:n<t[0]||t[1]<n}var s,f,h,g,p,v,d,m,y,M,x,b={point:n,lineStart:e,lineEnd:r,polygonStart:function(){b.point=u,b.lineStart=i,b.lineEnd=o,y=0,wc.polygonStart()},polygonEnd:function(){wc.polygonEnd(),b.point=n,b.lineStart=e,b.lineEnd=r,0>_c?(s=-(h=180),f=-(g=90)):y>Ta?g=90:-Ta>y&&(f=-90),x[0]=s,x[1]=h}};return function(n){g=h=-(s=f=1/0),M=[],ta.geo.stream(n,b);var t=M.length;if(t){M.sort(c);for(var e,r=1,u=M[0],i=[u];t>r;++r)e=M[r],l(e[0],u)||l(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,s=e[0],h=u[1])}return M=x=null,1/0===s||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[s,f],[h,g]]}}(),ta.geo.centroid=function(n){Sc=kc=Ec=Ac=Nc=Cc=zc=qc=Lc=Tc=Rc=0,ta.geo.stream(n,Dc);var t=Lc,e=Tc,r=Rc,u=t*t+e*e+r*r;return Ra>u&&(t=Cc,e=zc,r=qc,Ta>kc&&(t=Ec,e=Ac,r=Nc),u=t*t+e*e+r*r,Ra>u)?[0/0,0/0]:[Math.atan2(e,t)*Ha,nt(r/Math.sqrt(u))*Ha]};var Sc,kc,Ec,Ac,Nc,Cc,zc,qc,Lc,Tc,Rc,Dc={sphere:y,point:_e,lineStart:Se,lineEnd:ke,polygonStart:function(){Dc.lineStart=Ee},polygonEnd:function(){Dc.lineStart=Se}},Pc=Le(Ne,Pe,je,[-Da,-Da/2]),Uc=1e9;ta.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=Ye(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ta.geo.conicEqualArea=function(){return Ie(Ze)}).raw=Ze,ta.geo.albers=function(){return ta.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ta.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=ta.geo.albers(),o=ta.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ta.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.poly
},i.ratio=function(n){return arguments.length?(p=n,i):p},i.mode=function(n){return arguments.length?(g=n+"",i):g},Gu(i,a)},ta.random={normal:function(n,t){var e=arguments.length;return 2>e&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=ta.random.normal.apply(ta,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ta.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ta.scale={};var bl={floor:Et,ceil:Et};ta.scale.linear=function(){return Yi([0,1],[0,1],mu,!1)};var _l={s:1,g:1,p:1,r:1,e:1};ta.scale.log=function(){return Ji(ta.scale.linear().domain([0,1]),10,!0,[1,10])};var wl=ta.format(".0e"),Sl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ta.scale.pow=function(){return Gi(ta.scale.linear(),1,[0,1])},ta.scale.sqrt=function(){return ta.scale.pow().exponent(.5)},ta.scale.ordinal=function(){return Qi([],{t:"range",a:[[]]})},ta.scale.category10=function(){return ta.scale.ordinal().range(kl)},ta.scale.category20=function(){return ta.scale.ordinal().range(El)},ta.scale.category20b=function(){return ta.scale.ordinal().range(Al)},ta.scale.category20c=function(){return ta.scale.ordinal().range(Nl)};var kl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yt),El=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yt),Al=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yt),Nl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yt);ta.scale.quantile=function(){return no([],[])},ta.scale.quantize=function(){return to(0,1,[0,1])},ta.scale.threshold=function(){return eo([.5],[0,1])},ta.scale.identity=function(){return ro([0,1])},ta.svg={},ta.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),s=o.apply(this,arguments)-ja,f=a.apply(this,arguments)-ja,h=Math.abs(f-s),g=s>f?0:1;if(n>l&&(p=l,l=n,n=p),h>=Ua)return t(l,g)+(n?t(n,1-g):"")+"Z";var p,v,d,m,y,M,x,b,_,w,S,k,E=0,A=0,N=[];if((m=(+c.apply(this,arguments)||0)/2)&&(d=i===Cl?Math.sqrt(n*n+l*l):+i.apply(this,arguments),g||(A*=-1),l&&(A=nt(d/l*Math.sin(m))),n&&(E=nt(d/n*Math.sin(m)))),l){y=l*Math.cos(s+A),M=l*Math.sin(s+A),x=l*Math.cos(f-A),b=l*Math.sin(f-A);var C=Math.abs(f-s-2*A)<=Da?0:1;if(A&&so(y,M,x,b)===g^C){var z=(s+f)/2;y=l*Math.cos(z),M=l*Math.sin(z),x=b=null}}else y=M=0;if(n){_=n*Math.cos(f-E),w=n*Math.sin(f-E),S=n*Math.cos(s+E),k=n*Math.sin(s+E);var q=Math.abs(s-f+2*E)<=Da?0:1;if(E&&so(_,w,S,k)===1-g^q){var L=(s+f)/2;_=n*Math.cos(L),w=n*Math.sin(L),S=k=null}}else _=w=0;if((p=Math.min(Math.abs(l-n)/2,+u.apply(this,arguments)))>.001){v=l>n^g?0:1;var T=null==S?[_,w]:null==x?[y,M]:Lr([y,M],[S,k],[x,b],[_,w]),R=y-T[0],D=M-T[1],P=x-T[0],U=b-T[1],j=1/Math.sin(Math.acos((R*P+D*U)/(Math.sqrt(R*R+D*D)*Math.sqrt(P*P+U*U)))/2),F=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(null!=x){var H=Math.min(p,(l-F)/(j+1)),O=fo(null==S?[_,w]:[S,k],[y,M],l,H,g),Y=fo([x,b],[_,w],l,H,g);p===H?N.push("M",O[0],"A",H,",",H," 0 0,",v," ",O[1],"A",l,",",l," 0 ",1-g^so(O[1][0],O[1][1],Y[1][0],Y[1][1]),",",g," ",Y[1],"A",H,",",H," 0 0,",v," ",Y[0]):N.push("M",O[0],"A",H,",",H," 0 1,",v," ",Y[0])}else N.push("M",y,",",M);if(null!=S){var I=Math.min(p,(n-F)/(j-1)),Z=fo([y,M],[S,k],n,-I,g),V=fo([_,w],null==x?[y,M]:[x,b],n,-I,g);p===I?N.push("L",V[0],"A",I,",",I," 0 0,",v," ",V[1],"A",n,",",n," 0 ",g^so(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",I,",",I," 0 0,",v," ",Z[0]):N.push("L",V[0],"A",I,",",I," 0 0,",v," ",Z[0])}else N.push("L",_,",",w)}else N.push("M"
<script>!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.dagreD3=e()}}(function(){var define,module,exports;return 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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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":23,"./lib/util":25,"./lib/version":26}],2:[function(require,module,exports){var util=require("./util");module.exports={"default":normal,normal:normal,vee:vee};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"])}},{"./util":25}],3:[function(require,module,exports){var util=require("./util");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.enter().append("g").attr("class","cluster").style("opacity",0).append("rect");util.applyTransition(svgClusters.exit(),g).style("opacity",0).remove();util.applyTransition(svgClusters,g).style("opacity",1);util.applyTransition(svgClusters.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.x-node.width/2}).attr("y",function(v){var node=g.node(v);return node.y-node.height/2})}},{"./util":25}],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":20,"./util":25}],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);svgPaths.each(function(e){var edge=g.edge(e);edge.elem=this;if(edge.id){d3.select(this).attr("id",edge.id)}});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
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":28,"./add-border-segments":29,"./coordinate-system":30,"./graphlib":33,"./lodash":36,"./nesting-graph":37,"./normalize":38,"./order":43,"./parent-dummy-chains":48,"./position":50,"./rank":52,"./util":55}],36:[function(require,module,exports){module.exports=require(20)},{"/Users/cpettitt/projects/dagre-d3/lib/lodash.js":20,lodash:77}],37:[function(require,module,exports){var _=require("./lodash"),util=require("./util");module.exports={run:run,cleanup:cleanup};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;_.each(g.edges(),function(e){g.edge(e).minlen*=nodeSep});var weight=sumWeights(g)+1;_.each(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)});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.setParen
});_.each(g.nodes(),function(v){var node=g.node(v),rank=node.rank;if(!_.isUndefined(rank)){layering[rank][node.order]=v}});return layering}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){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}}))}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}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":33,"./lodash":36}],56:[function(require,module,exports){module.exports="0.7.1"},{}],57:[function(require,module,exports){var lib=require("./lib");module.exports={Graph:lib.Graph,json:require("./lib/json"),alg:require("./lib/alg"),version:lib.version}},{"./lib":73,"./lib/alg":64,"./lib/json":74}],58:[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":75}],59:[function(require,module,exports){var _=require("../lodash");module.exports=dfs;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":75}],60:[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":75,"./dijkstra":61}],61:[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":71,"../lodash":75}],62:[function(require,module,exports){var _=require("../lodash"),tarjan=require("./tarjan"
if(aWrapped||bWrapped){return baseIsEqual(aWrapped?a.__wrapped__:a,bWrapped?b.__wrapped__:b,callback,isWhere,stackA,stackB)}if(className!=objectClass){return false}var ctorA=a.constructor,ctorB=b.constructor;if(ctorA!=ctorB&&!(isFunction(ctorA)&&ctorA instanceof ctorA&&isFunction(ctorB)&&ctorB instanceof ctorB)&&("constructor"in a&&"constructor"in b)){return false}}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;stackA.push(a);stackB.push(b);if(isArr){length=a.length;size=b.length;result=size==length;if(result||isWhere){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{forIn(b,function(value,key,b){if(hasOwnProperty.call(b,key)){size++;return result=hasOwnProperty.call(a,key)&&baseIsEqual(a[key],value,callback,isWhere,stackA,stackB)}});if(result&&!isWhere){forIn(a,function(value,key,a){if(hasOwnProperty.call(a,key)){return result=--size>-1}})}}stackA.pop();stackB.pop();if(initedStack){releaseArray(stackA);releaseArray(stackB)}return result}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))){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:{}}stackA.push(source);stackB.push(value);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})}function baseRandom(min,max){return min+floor(nativeRandom()*(max-min+1))}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}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}}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){bindData=slice(bindData);if(bindData[2]){bindData[2]=slice(bindData[2])}if(bindData[3]){bindData[3]=slice(bindData[3])}if(isBind&&!(bindData[1]&1)){bindData[4]=thisArg}if(!isBind&&bindData[1]&1){bitmask|=8}if(isCurry&&!(bindData[1]&4)){bindData[5]=arity}if(isPartial){push.apply(bindData[2]||(bindData
return hasOwnProperty.call(cache,key)?cache[key]:cache[key]=func.apply(this,arguments)};memoized.cache={};return memoized}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);func=null;return result}}function partial(func){return createWrapper(func,16,slice(arguments,1))}function partialRight(func){return createWrapper(func,32,null,slice(arguments,1))}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)}function wrap(value,wrapper){return createWrapper(wrapper,16,[value])}function constant(value){return function(){return value}}function createCallback(func,thisArg,argCount){var type=typeof func;if(func==null||type=="function"){return baseCreateCallback(func,thisArg,argCount)}if(type!="object"){return property(func)}var props=keys(func),key=props[0],a=func[key];if(props.length==1&&a===a&&!isObject(a)){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}}function escape(string){return string==null?"":String(string).replace(reUnescapedHtml,escapeHtmlChar)}function identity(value){return value}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}}})}function noConflict(){context._=oldDash;return this}function noop(){}var now=isNative(now=Date.now)&&now||function(){return(new Date).getTime()};var parseInt=nativeParseInt(whitespace+"08")==8?nativeParseInt:function(value,radix){return nativeParseInt(isString(value)?value.replace(reLeadingSpacesAndZeros,""):value,radix||0)};function property(key){return function(object){return object[key]}}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)}function result(object,key){if(object){var value=object[key];return isFunction(value)?object[key]():value}}function template(text,data,options){var settings=lodash.templateSettings;text=String(text||"");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 += '";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);sourc
<style type="text/css">
.mermaid .label {
color: #333333;
font-weight: 400;
}
.mermaid .node rect,
.node circle,
.mermaid .node ellipse,
.mermaid .node polygon {
fill: #ECECFF;
stroke: #CCCCFF;
stroke-width: 1px;
}
.mermaid .edgePath .path {
stroke: #333333;
}
.mermaid g .edgeLabel {
background-color: white;
}
.mermaid .cluster rect {
fill: #ffffde !important;
rx: 4 !important;
stroke: #aaaa33 !important;
stroke-width: 1px !important;
}
.mermaid .cluster text {
fill: #333333;
}
.mermaid .actor {
stroke: #CCCCFF;
fill: #ECECFF;
}
.mermaid text.actor {
fill: black;
stroke: none;
}
.mermaid .actor-line {
stroke: grey;
}
.mermaid .messageLine0 {
stroke-width: 1.5;
stroke-dasharray: "2 2";
stroke: #333333;
}
.mermaid .messageLine1 {
stroke-width: 1.5;
stroke-dasharray: "2 2";
stroke: #333333;
}
.mermaid #arrowhead {
fill: #333333;
}
.mermaid #crosshead path {
fill: #333333 !important;
stroke: #333333 !important;
}
.mermaid .messageText {
fill: #333333;
stroke: none;
}
.mermaid .labelBox {
stroke: #CCCCFF;
fill: #ECECFF;
}
.mermaid .labelText {
fill: black;
stroke: none;
}
.mermaid .loopText {
fill: black;
stroke: none;
}
.mermaid .loopLine {
stroke-width: 2;
stroke-dasharray: "2 2";
stroke: #CCCCFF;
}
.mermaid .note {
stroke: #aaaa33;
fill: #fff5ad;
}
.mermaid .noteText {
fill: black;
stroke: none;
font-family: 'trebuchet ms', verdana, arial;
font-size: 14px;
}
.mermaid .section {
stroke: none;
opacity: 0.2;
}
.mermaid .section0 {
fill: rgba(102, 102, 255, 0.49);
}
.mermaid .section2 {
fill: #fff400;
}
.mermaid .section1,
.mermaid .section3 {
fill: white;
opacity: 0.2;
}
.mermaid .sectionTitle0 {
fill: #333333;
}
.mermaid .sectionTitle1 {
fill: #333333;
}
.mermaid .sectionTitle2 {
fill: #333333;
}
.mermaid .sectionTitle3 {
fill: #333333;
}
.mermaid .sectionTitle {
text-anchor: start;
font-size: 11px;
text-height: 14px;
}
.mermaid .grid .tick {
stroke: lightgrey;
opacity: 0.3;
shape-rendering: crispEdges;
}
.mermaid .grid path {
stroke-width: 0;
}
.mermaid .today {
fill: none;
stroke: red;
stroke-width: 2px;
}
.mermaid .task {
stroke-width: 2;
}
.mermaid .taskText {
text-anchor: middle;
font-size: 11px;
}
.mermaid .taskTextOutsideRight {
fill: black;
text-anchor: start;
font-size: 11px;
}
.mermaid .taskTextOutsideLeft {
fill: black;
text-anchor: end;
font-size: 11px;
}
.mermaid .taskText0,
.mermaid .taskText1,
.mermaid .taskText2,
.mermaid .taskText3 {
fill: white;
}
.mermaid .task0,
.mermaid .task1,
.mermaid .task2,
.mermaid .task3 {
fill: #8a90dd;
stroke: #534fbc;
}
.mermaid .taskTextOutside0,
.mermaid .taskTextOutside2 {
fill: black;
}
.mermaid .taskTextOutside1,
.mermaid .taskTextOutside3 {
fill: black;
}
.mermaid .active0,
.mermaid .active1,
.mermaid .active2,
.mermaid .active3 {
fill: #bfc7ff;
stroke: #534fbc;
}
.mermaid .activeText0,
.mermaid .activeText1,
.mermaid .activeText2,
.mermaid .activeText3 {
fill: black !important;
}
.mermaid .done0,
.mermaid .done1,
.mermaid .done2,
.mermaid .done3 {
stroke: grey;
fill: lightgrey;
stroke-width: 2;
}
.mermaid .doneText0,
.mermaid .doneText1,
.mermaid .doneText2,
.mermaid .doneText3 {
fill: black !important;
}
.mermaid .crit0,
.mermaid .crit1,
.mermaid .crit2,
.mermaid .crit3 {
stroke: #ff8888;
fill: red;
stroke-width: 2;
}
.mermaid .activeCrit0,
.mermaid .activeCrit1,
.mermaid .activeCrit2,
.mermaid .activeCrit3 {
stroke: #ff8888;
fill: #bfc7ff;
stroke-width: 2;
}
.mermaid .doneCrit0,
.mermaid .doneCrit1,
.mermaid .doneCrit2,
.mermaid .doneCrit3 {
stroke: #ff8888;
fill: lightgrey;
stroke-width: 2;
cursor: pointer;
shape-rendering: crispEdges;
}
.mermaid .doneCritText0,
.mermaid .doneCritText1,
.mermaid .doneCritText2,
.mermaid .doneCritText3 {
fill: black !important;
}
.mermaid .activeCritText0,
.mermaid .activeCritText1,
.mermaid .activeCritText2,
.mermaid .activeCritText3 {
fill: black !important;
}
.mermaid .titleText {
text-anchor: middle;
font-size: 18px;
fill: black;
}
.node text {
font-family: 'trebuchet ms', verdana, arial;
font-size: 14px;
}
div.mermaidTooltip {
position: absolute;
text-align: center;
max-width: 200px;
padding: 2px;
font-family: 'trebuchet ms', verdana, arial;
font-size: 12px;
background: #ffffde;
border: 1px solid #aaaa33;
border-radius: 2px;
pointer-events: none;
z-index: 100;
}
</style>
<script>!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.mermaid=t()}}(function(){var define,module,exports;return function t(e,r,n){function i(s,o){if(!r[s]){if(!e[s]){var u="function"==typeof require&&require;if(!o&&u)return u(s,!0);if(a)return a(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var l=r[s]={exports:{}};e[s][0].call(l.exports,function(t){var r=e[s][1][t];return i(r?r:t)},l,l.exports,t,e,r,n)}return r[s].exports}for(var a="function"==typeof require&&require,s=0;s<n.length;s++)i(n[s]);return i}({1:[function(t,e,r){},{}],2:[function(t,e,r){(function(t){function e(t,e){for(var r=0,n=t.length-1;n>=0;n--){var i=t[n];"."===i?t.splice(n,1):".."===i?(t.splice(n,1),r++):r&&(t.splice(n,1),r--)}if(e)for(;r--;r)t.unshift("..");return t}function n(t,e){if(t.filter)return t.filter(e);for(var r=[],n=0;n<t.length;n++)e(t[n],n,t)&&r.push(t[n]);return r}var i=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,a=function(t){return i.exec(t).slice(1)};r.resolve=function(){for(var r="",i=!1,a=arguments.length-1;a>=-1&&!i;a--){var s=a>=0?arguments[a]:t.cwd();if("string"!=typeof s)throw new TypeError("Arguments to path.resolve must be strings");s&&(r=s+"/"+r,i="/"===s.charAt(0))}return r=e(n(r.split("/"),function(t){return!!t}),!i).join("/"),(i?"/":"")+r||"."},r.normalize=function(t){var i=r.isAbsolute(t),a="/"===s(t,-1);return t=e(n(t.split("/"),function(t){return!!t}),!i).join("/"),t||i||(t="."),t&&a&&(t+="/"),(i?"/":"")+t},r.isAbsolute=function(t){return"/"===t.charAt(0)},r.join=function(){var t=Array.prototype.slice.call(arguments,0);return r.normalize(n(t,function(t,e){if("string"!=typeof t)throw new TypeError("Arguments to path.join must be strings");return t}).join("/"))},r.relative=function(t,e){function n(t){for(var e=0;e<t.length&&""===t[e];e++);for(var r=t.length-1;r>=0&&""===t[r];r--);return e>r?[]:t.slice(e,r-e+1)}t=r.resolve(t).substr(1),e=r.resolve(e).substr(1);for(var i=n(t.split("/")),a=n(e.split("/")),s=Math.min(i.length,a.length),o=s,u=0;s>u;u++)if(i[u]!==a[u]){o=u;break}for(var c=[],u=o;u<i.length;u++)c.push("..");return c=c.concat(a.slice(o)),c.join("/")},r.sep="/",r.delimiter=":",r.dirname=function(t){var e=a(t),r=e[0],n=e[1];return r||n?(n&&(n=n.substr(0,n.length-1)),r+n):"."},r.basename=function(t,e){var r=a(t)[2];return e&&r.substr(-1*e.length)===e&&(r=r.substr(0,r.length-e.length)),r},r.extname=function(t){return a(t)[3]};var s="b"==="ab".substr(-1)?function(t,e,r){return t.substr(e,r)}:function(t,e,r){return 0>e&&(e=t.length+e),t.substr(e,r)}}).call(this,t("_process"))},{_process:3}],3:[function(t,e,r){function n(){}var i=e.exports={};i.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,e="undefined"!=typeof window&&window.MutationObserver,r="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};var n=[];if(e){var i=document.createElement("div"),a=new MutationObserver(function(){var t=n.slice();n.length=0,t.forEach(function(t){t()})});return a.observe(i,{attributes:!0}),function(t){n.length||i.setAttribute("yes","no"),n.push(t)}}return r?(window.addEventListener("message",function(t){var e=t.source;if((e===window||null===e)&&"process-tick"===t.data&&(t.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(t){n.push(t),window.postMessage("process-tick","*")}):function(t){setTimeout(t,0)}}(),i.title="browser",i.browser=!0,i.env={},i.argv=[],i.on=n,i.addListener=n,i.once=n,i.off=n,i.removeListener=n,i.removeAllListeners=n,i.emit=n,i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")}},{}],4:[function(t,e,r){e.exports={graphlib:t("./lib/graphlib"),dagre:t("./lib/dagre"),intersect:t("./lib/intersect"),render:t("./lib/re
return t.v===e}):n}},n.prototype.outEdges=function(t,e){var r=this._out[t];if(r){var n=c.values(r);return e?c.filter(n,function(t){return t.w===e}):n}},n.prototype.nodeEdges=function(t,e){var r=this.inEdges(t,e);return r?r.concat(this.outEdges(t,e)):void 0}},{"./lodash":50}],48:[function(t,e,r){e.exports={Graph:t("./graph"),version:t("./version")}},{"./graph":47,"./version":51}],49:[function(t,e,r){function n(t){var e={options:{directed:t.isDirected(),multigraph:t.isMultigraph(),compound:t.isCompound()},nodes:i(t),edges:a(t)};return o.isUndefined(t.graph())||(e.value=o.clone(t.graph())),e}function i(t){return o.map(t.nodes(),function(e){var r=t.node(e),n=t.parent(e),i={v:e};return o.isUndefined(r)||(i.value=r),o.isUndefined(n)||(i.parent=n),i})}function a(t){return o.map(t.edges(),function(e){var r=t.edge(e),n={v:e.v,w:e.w};return o.isUndefined(e.name)||(n.name=e.name),o.isUndefined(r)||(n.value=r),n})}function s(t){var e=new u(t.options).setGraph(t.value);return o.each(t.nodes,function(t){e.setNode(t.v,t.value),t.parent&&e.setParent(t.v,t.parent)}),o.each(t.edges,function(t){e.setEdge({v:t.v,w:t.w,name:t.name},t.value)}),e}var o=t("./lodash"),u=t("./graph");e.exports={write:n,read:s}},{"./graph":47,"./lodash":50}],50:[function(t,e,r){var n;if("function"==typeof t)try{n=t("lodash")}catch(i){}n||(n=window._),e.exports=n},{lodash:52}],51:[function(t,e,r){e.exports="1.0.7"},{}],52:[function(t,e,r){(function(t){(function(){function n(t,e){if(t!==e){var r=null===t,n=t===k,i=t===t,a=null===e,s=e===k,o=e===e;if(t>e&&!a||!i||r&&!s&&o||n&&o)return 1;if(e>t&&!r||!o||a&&!n&&i||s&&i)return-1}return 0}function i(t,e,r){for(var n=t.length,i=r?n:-1;r?i--:++i<n;)if(e(t[i],i,t))return i;return-1}function a(t,e,r){if(e!==e)return m(t,r);for(var n=r-1,i=t.length;++n<i;)if(t[n]===e)return n;return-1}function s(t){return"function"==typeof t||!1}function o(t){return null==t?"":t+""}function u(t,e){for(var r=-1,n=t.length;++r<n&&e.indexOf(t.charAt(r))>-1;);return r}function c(t,e){for(var r=t.length;r--&&e.indexOf(t.charAt(r))>-1;);return r}function l(t,e){return n(t.criteria,e.criteria)||t.index-e.index}function h(t,e,r){for(var i=-1,a=t.criteria,s=e.criteria,o=a.length,u=r.length;++i<o;){var c=n(a[i],s[i]);if(c){if(i>=u)return c;var l=r[i];return c*("asc"===l||l===!0?1:-1)}}return t.index-e.index}function d(t){return Gt[t]}function f(t){return $t[t]}function p(t,e,r){return e?t=zt[t]:r&&(t=Zt[t]),"\\"+t}function g(t){return"\\"+Zt[t]}function m(t,e,r){for(var n=t.length,i=e+(r?0:-1);r?i--:++i<n;){var a=t[i];if(a!==a)return i}return-1}function y(t){return!!t&&"object"==typeof t}function v(t){return 160>=t&&t>=9&&13>=t||32==t||160==t||5760==t||6158==t||t>=8192&&(8202>=t||8232==t||8233==t||8239==t||8287==t||12288==t||65279==t)}function b(t,e){for(var r=-1,n=t.length,i=-1,a=[];++r<n;)t[r]===e&&(t[r]=G,a[++i]=r);return a}function _(t,e){for(var r,n=-1,i=t.length,a=-1,s=[];++n<i;){var o=t[n],u=e?e(o,n,t):o;n&&r===u||(r=u,s[++a]=o)}return s}function A(t){for(var e=-1,r=t.length;++e<r&&v(t.charCodeAt(e)););return e}function w(t){for(var e=t.length;e--&&v(t.charCodeAt(e)););return e}function x(t){return Ht[t]}function E(t){function e(t){if(y(t)&&!To(t)&&!(t instanceof K)){if(t instanceof v)return t;if(ts.call(t,"__chain__")&&ts.call(t,"__wrapped__"))return fn(t)}return new v(t)}function r(){}function v(t,e,r){this.__wrapped__=t,this.__actions__=r||[],this.__chain__=!!e}function K(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Cs,this.__views__=[]}function et(){var t=new K(this.__wrapped__);return t.__actions__=te(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=te(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=te(this.__views__),t}function nt(){if(this.__filtered__){var t=new K(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function Gt(){var t=this.__wrapped__.value(),e=this.__dir__,r=To(t),n=0>e,i=r?t.length:0,a=$r(0,i,this.__views__),s=a.start,o=a.end,u=o-s,c=n?o:s-1,l=this.__iteratee
for(var r=t.constructor,n=-1,i="function"==typeof r&&r.prototype===t,a=ja(e),s=e>0;++n<e;)a[n]=n+"";for(var o in t)s&&Kr(o,e)||"constructor"==o&&(i||!ts.call(t,o))||a.push(o);return a}function ea(t){t=hn(t);for(var e=-1,r=jo(t),n=r.length,i=ja(n);++e<n;){var a=r[e];i[e]=[a,t[a]]}return i}function ra(t,e,r){var n=null==t?k:t[e];return n===k&&(null==t||Qr(e,t)||(e=dn(e),t=1==e.length?t:Ie(t,ze(e,0,-1)),n=null==t?k:t[Dn(e)]),n=n===k?r:n),Oi(n)?n.call(t):n}function na(t,e,r){if(null==t)return t;var n=e+"";e=null!=t[n]||Qr(e,t)?[n]:dn(e);for(var i=-1,a=e.length,s=a-1,o=t;null!=o&&++i<a;){var u=e[i];Ii(o)&&(i==s?o[u]=r:null==o[u]&&(o[u]=Kr(e[i+1])?[]:{})),o=o[u]}return t}function ia(t,e,r,n){var i=To(t)||Vi(t);if(e=jr(e,n,4),null==r)if(i||Ii(t)){var a=t.constructor;r=i?To(t)?new a:[]:Is(Oi(a)?a.prototype:k)}else r={};return(i?ee:Be)(t,function(t,n,i){return e(r,t,n,i)}),r}function aa(t){return tr(t,jo(t))}function sa(t){return tr(t,ta(t))}function oa(t,e,r){return e=+e||0,r===k?(r=e,e=0):r=+r||0,t>=ws(e,r)&&t<As(e,r)}function ua(t,e,r){r&&Jr(t,e,r)&&(e=r=k);var n=null==t,i=null==e;if(null==r&&(i&&"boolean"==typeof t?(r=t,t=1):"boolean"==typeof e&&(r=e,i=!0)),n&&i&&(e=1,i=!1),t=+t||0,i?(e=t,t=0):e=+e||0,r||t%1||e%1){var a=ks();return ws(t+a*(e-t+os("1e-"+((a+"").length-1))),e)}return He(t,e)}function ca(t){return t=o(t),t&&t.charAt(0).toUpperCase()+t.slice(1)}function la(t){return t=o(t),t&&t.replace(Mt,d).replace(Tt,"")}function ha(t,e,r){t=o(t),e+="";var n=t.length;return r=r===k?n:ws(0>r?0:+r||0,n),r-=e.length,r>=0&&t.indexOf(e,r)==r}function da(t){return t=o(t),t&&_t.test(t)?t.replace(vt,f):t}function fa(t){return t=o(t),t&&Ft.test(t)?t.replace(Ct,p):t||"(?:)"}function pa(t,e,r){t=o(t),e=+e;var n=t.length;if(n>=e||!bs(e))return t;var i=(e-n)/2,a=ys(i),s=gs(i);return r=Lr("",s,r),r.slice(0,a)+t+r}function ga(t,e,r){return(r?Jr(t,e,r):null==e)?e=0:e&&(e=+e),t=ba(t),Es(t,e||(Ot.test(t)?16:10))}function ma(t,e){var r="";if(t=o(t),e=+e,1>e||!t||!bs(e))return r;do e%2&&(r+=t),e=ys(e/2),t+=t;while(e);return r}function ya(t,e,r){return t=o(t),r=null==r?0:ws(0>r?0:+r||0,t.length),t.lastIndexOf(e,r)==r}function va(t,r,n){var i=e.templateSettings;n&&Jr(t,r,n)&&(r=n=k),t=o(t),r=me(ye({},n||r),i,ge);var a,s,u=me(ye({},r.imports),i.imports,ge),c=jo(u),l=tr(u,c),h=0,d=r.interpolate||Rt,f="__p += '",p=Wa((r.escape||Rt).source+"|"+d.source+"|"+(d===xt?Bt:Rt).source+"|"+(r.evaluate||Rt).source+"|$","g"),m="//# sourceURL="+("sourceURL"in r?r.sourceURL:"lodash.templateSources["+ ++Ut+"]")+"\n";t.replace(p,function(e,r,n,i,o,u){return n||(n=i),f+=t.slice(h,u).replace(Pt,g),r&&(a=!0,f+="' +\n__e("+r+") +\n'"),o&&(s=!0,f+="';\n"+o+";\n__p += '"),n&&(f+="' +\n((__t = ("+n+")) == null ? '' : __t) +\n'"),h=u+e.length,e}),f+="';\n";var y=r.variable;y||(f="with (obj) {\n"+f+"\n}\n"),f=(s?f.replace(pt,""):f).replace(gt,"$1").replace(mt,"$1;"),f="function("+(y||"obj")+") {\n"+(y?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(a?", __e = _.escape":"")+(s?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+f+"return __p\n}";var v=Ko(function(){return Va(c,m+"return "+f).apply(k,l)});if(v.source=f,Bi(v))throw v;return v}function ba(t,e,r){var n=t;return(t=o(t))?(r?Jr(n,e,r):null==e)?t.slice(A(t),w(t)+1):(e+="",t.slice(u(t,e),c(t,e)+1)):t}function _a(t,e,r){var n=t;return t=o(t),t?(r?Jr(n,e,r):null==e)?t.slice(A(t)):t.slice(u(t,e+"")):t}function Aa(t,e,r){var n=t;return t=o(t),t?(r?Jr(n,e,r):null==e)?t.slice(0,w(t)+1):t.slice(0,c(t,e+"")+1):t}function wa(t,e,r){r&&Jr(t,e,r)&&(e=k);var n=M,i=R;if(null!=e)if(Ii(e)){var a="separator"in e?e.separator:a;n="length"in e?+e.length||0:n,i="omission"in e?o(e.omission):i}else n=+e||0;if(t=o(t),n>=t.length)return t;var s=n-i.length;if(1>s)return i;var u=t.slice(0,s);if(null==a)return u+i;if(Ui(a)){if(t.slice(s).search(a)){var c,l,h=t.slice(0,s);for(a.global||(a=Wa(a.source,(Lt.exec(a)||"")+"g")),a.lastIndex=0;c=a.exec(h);)l=c.index;u=u.slice(0,null==l?s:l)}}else if(t.indexOf(a,s)!=s){var d=u.lastIndexOf(a);d>-1&&(u=u.slice(0,d))}return u+i}function xa(t){return t=o(t),t&&bt.te
i(t,e,o,l,n,r,a)}),t.graph().nodeRankFactor=o}function i(t,e,r,n,a,s,o){var l=t.children(o);if(!l.length)return void(o!==e&&t.setEdge(e,o,{weight:0,minlen:r}));var h=c.addBorderNode(t,"_bt"),d=c.addBorderNode(t,"_bb"),f=t.node(o);t.setParent(h,o),f.borderTop=h,t.setParent(d,o),f.borderBottom=d,u.each(l,function(u){i(t,e,r,n,a,s,u);var c=t.node(u),l=c.borderTop?c.borderTop:u,f=c.borderBottom?c.borderBottom:u,p=c.borderTop?n:2*n,g=l!==f?1:a-s[o]+1;t.setEdge(h,l,{weight:p,minlen:g,nestingEdge:!0}),t.setEdge(f,d,{weight:p,minlen:g,nestingEdge:!0})}),t.parent(o)||t.setEdge(e,h,{weight:0,minlen:a+s[o]})}function a(t){function e(n,i){var a=t.children(n);a&&a.length&&u.each(a,function(t){e(t,i+1)}),r[n]=i}var r={};return u.each(t.children(),function(t){e(t,1)}),r}function s(t){return u.reduce(t.edges(),function(e,r){return e+t.edge(r).weight},0)}function o(t){var e=t.graph();t.removeNode(e.nestingRoot),delete e.nestingRoot,u.each(t.edges(),function(e){var r=t.edge(e);r.nestingEdge&&t.removeEdge(e)})}var u=t("./lodash"),c=t("./util");e.exports={run:n,cleanup:o}},{"./lodash":62,"./util":81}],64:[function(t,e,r){"use strict";function n(t){t.graph().dummyChains=[],s.each(t.edges(),function(e){i(t,e)})}function i(t,e){var r=e.v,n=t.node(r).rank,i=e.w,a=t.node(i).rank,s=e.name,u=t.edge(e),c=u.labelRank;if(a!==n+1){t.removeEdge(e);var l,h,d;for(d=0,++n;a>n;++d,++n)u.points=[],h={width:0,height:0,edgeLabel:u,edgeObj:e,rank:n},l=o.addDummyNode(t,"edge",h,"_d"),n===c&&(h.width=u.width,h.height=u.height,h.dummy="edge-label",h.labelpos=u.labelpos),t.setEdge(r,l,{weight:u.weight},s),0===d&&t.graph().dummyChains.push(l),r=l;t.setEdge(r,i,{weight:u.weight},s)}}function a(t){s.each(t.graph().dummyChains,function(e){var r,n=t.node(e),i=n.edgeLabel;for(t.setEdge(n.edgeObj,i);n.dummy;)r=t.successors(e)[0],t.removeNode(e),i.points.push({x:n.x,y:n.y}),"edge-label"===n.dummy&&(i.x=n.x,i.y=n.y,i.width=n.width,i.height=n.height),e=r,n=t.node(e)})}var s=t("./lodash"),o=t("./util");e.exports={run:n,undo:a}},{"./lodash":62,"./util":81}],65:[function(t,e,r){function n(t,e,r){var n,a={};i.each(r,function(r){for(var i,s,o=t.parent(r);o;){if(i=t.parent(o),i?(s=a[i],a[i]=o):(s=n,n=o),s&&s!==o)return void e.setEdge(s,o);o=i}})}var i=t("../lodash");e.exports=n},{"../lodash":62}],66:[function(t,e,r){function n(t,e){return i.map(e,function(e){var r=t.inEdges(e);if(r.length){var n=i.reduce(r,function(e,r){var n=t.edge(r),i=t.node(r.v);return{sum:e.sum+n.weight*i.order,weight:e.weight+n.weight}},{sum:0,weight:0});return{v:e,barycenter:n.sum/n.weight,weight:n.weight}}return{v:e}})}var i=t("../lodash");e.exports=n},{"../lodash":62}],67:[function(t,e,r){function n(t,e,r){var n=i(t),o=new s({compound:!0}).setGraph({root:n}).setDefaultNodeLabel(function(e){return t.node(e)});return a.each(t.nodes(),function(i){var s=t.node(i),u=t.parent(i);(s.rank===e||s.minRank<=e&&e<=s.maxRank)&&(o.setNode(i),o.setParent(i,u||n),a.each(t[r](i),function(e){var r=e.v===i?e.w:e.v,n=o.edge(r,i),s=a.isUndefined(n)?0:n.weight;o.setEdge(r,i,{weight:t.edge(e).weight+s})}),a.has(s,"minRank")&&o.setNode(i,{borderLeft:s.borderLeft[e],borderRight:s.borderRight[e]}))}),o}function i(t){for(var e;t.hasNode(e=a.uniqueId("_root")););return e}var a=t("../lodash"),s=t("../graphlib").Graph;e.exports=n},{"../graphlib":59,"../lodash":62}],68:[function(t,e,r){"use strict";function n(t,e){for(var r=0,n=1;n<e.length;++n)r+=i(t,e[n-1],e[n]);return r}function i(t,e,r){for(var n=a.zipObject(r,a.map(r,function(t,e){return e})),i=a.flatten(a.map(e,function(e){return a.chain(t.outEdges(e)).map(function(e){return{pos:n[e.w],weight:t.edge(e).weight}}).sortBy("pos").value()}),!0),s=1;s<r.length;)s<<=1;var o=2*s-1;s-=1;var u=a.map(new Array(o),function(){return 0}),c=0;return a.each(i.forEach(function(t){var e=t.pos+s;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),e=e-1>>1,u[e]+=t.weight;c+=t.weight*r})),c}var a=t("../lodash");e.exports=n},{"../lodash":62}],69:[function(t,e,r){"use strict";function n(t){var e=p.maxRank(t),r=i(t,o.range(1,e+1),"inEdges"),n=i(t,o.range(e-1,-1,-1),"outEdges"),l=u(t);s(t,l);for(var h,d=N
"Ë":"Euml","ë":"euml","€":"euro","!":"excl","∃":"exist","Ф":"Fcy","ф":"fcy","♀":"female","ffi":"ffilig","ff":"fflig","ffl":"ffllig","𝔉":"Ffr","𝔣":"ffr","fi":"filig","◼":"FilledSmallSquare",fj:"fjlig","♭":"flat","fl":"fllig","▱":"fltns","ƒ":"fnof","𝔽":"Fopf","𝕗":"fopf","∀":"forall","⋔":"fork","⫙":"forkv","":"Fscr","⨍":"fpartint","½":"half","⅓":"frac13","¼":"frac14","⅕":"frac15","⅙":"frac16","⅛":"frac18","⅔":"frac23","⅖":"frac25","¾":"frac34","⅗":"frac35","⅜":"frac38","⅘":"frac45","⅚":"frac56","⅝":"frac58","⅞":"frac78","":"frasl","⌢":"frown","𝒻":"fscr","ǵ":"gacute","Γ":"Gamma","γ":"gamma","Ϝ":"Gammad","⪆":"gap","Ğ":"Gbreve","ğ":"gbreve","Ģ":"Gcedil","Ĝ":"Gcirc","ĝ":"gcirc","Г":"Gcy","г":"gcy","Ġ":"Gdot","ġ":"gdot","≥":"ge","≧":"gE","⪌":"gEl","⋛":"gel","⩾":"ges","⪩":"gescc","⪀":"gesdot","⪂":"gesdoto","⪄":"gesdotol","⋛︀":"gesl","⪔":"gesles","𝔊":"Gfr","𝔤":"gfr","≫":"gg","⋙":"Gg","ℷ":"gimel","Ѓ":"GJcy","ѓ":"gjcy","⪥":"gla","≷":"gl","⪒":"glE","⪤":"glj","⪊":"gnap","⪈":"gne","≩":"gnE","⋧":"gnsim","𝔾":"Gopf","𝕘":"gopf","⪢":"GreaterGreater","≳":"gsim","𝒢":"Gscr","":"gscr","⪎":"gsime","⪐":"gsiml","⪧":"gtcc","⩺":"gtcir",">":"gt","⋗":"gtdot","⦕":"gtlPar","⩼":"gtquest","⥸":"gtrarr","≩︀":"gvnE","":"hairsp","":"Hscr","Ъ":"HARDcy","ъ":"hardcy","⥈":"harrcir","↔":"harr","↭":"harrw","^":"Hat","ℏ":"hbar","Ĥ":"Hcirc","ĥ":"hcirc","♥":"hearts","…":"mldr","⊹":"hercon","𝔥":"hfr","":"Hfr","⤥":"searhk","⤦":"swarhk","⇿":"hoarr","∻":"homtht","↩":"larrhk","↪":"rarrhk","𝕙":"hopf","":"Hopf","―":"horbar","𝒽":"hscr","Ħ":"Hstrok","ħ":"hstrok","":"hybull","Í":"Iacute","í":"iacute","":"ic","Î":"Icirc","î":"icirc","И":"Icy","и":"icy","İ":"Idot","Е":"IEcy","е":"iecy","¡":"iexcl","𝔦":"ifr","":"Im","Ì":"Igrave","ì":"igrave","":"ii","⨌":"qint","∭":"tint","⧜":"iinfin","℩":"iiota","IJ":"IJlig","ij":"ijlig","Ī":"Imacr","ī":"imacr","":"Iscr","ı":"imath","⊷":"imof","Ƶ":"imped","℅":"incare","∞":"infin","⧝":"infintie","⊺":"intcal","∫":"int","∬":"Int","":"Zopf","⨗":"intlarhk","⨼":"iprod","":"it","Ё":"IOcy","ё":"iocy","Į":"Iogon","į":"iogon","𝕀":"Iopf","𝕚":"iopf","Ι":"Iota","ι":"iota","¿":"iquest","𝒾":"iscr","⋵":"isindot","⋹":"isinE","⋴":"isins","⋳":"isinsv","Ĩ":"Itilde","ĩ":"itilde","І":"Iukcy","і":"iukcy","Ï":"Iuml","ï":"iuml","Ĵ":"Jcirc","ĵ":"jcirc","Й":"Jcy","й":"jcy","𝔍":"Jfr","𝔧":"jfr","ȷ":"jmath","𝕁":"Jopf","𝕛":"jopf","𝒥":"Jscr","𝒿":"jscr","Ј":"Jsercy","ј":"jsercy","Є":"Jukcy","є":"jukcy","Κ":"Kappa","κ":"kappa","ϰ":"kappav","Ķ":"Kcedil","ķ":"kcedil","К":"Kcy","к":"kcy","𝔎":"Kfr","𝔨":"kfr","ĸ":"kgreen","Х":"KHcy","х":"khcy","Ќ":"KJcy","ќ":"kjcy","𝕂":"Kopf","𝕜":"kopf","𝒦":"Kscr","𝓀":"kscr","⇚":"lAarr","Ĺ":"Lacute","ĺ":"lacute","⦴":"laemptyv","":"Lscr","Λ":"Lambda","λ":"lambda","⟨":"lang","⟪":"Lang","⦑":"langd","⪅":"lap","«":"laquo","⇤":"larrb","⤟":"larrbfs","←":"larr","↞":"Larr","⤝":"larrfs","↫":"larrlp","⤹":"larrpl","⥳":"larrsim","↢":"larrtl","⤙":"latail","⤛":"lAtail","⪫":"lat","⪭":"late","⪭︀":"lates","⤌":"lbarr","⤎":"lBarr","":"lbbrk","{":"lcub","[":"lsqb","⦋":"lbrke","⦏":"lbrksld","⦍":"lbrkslu","Ľ":"Lcaron","ľ":"lcaron","Ļ":"Lcedil","ļ":"lcedil","⌈":"lceil","Л":"Lcy","л":"lcy","⤶":"ldca","“":"ldquo","⥧":"ldrdhar","⥋":"ldrushar","↲":"ldsh","≤":"le","≦":"lE","⇆":"lrarr","⟦":"lobrk","⥡":"LeftDownTeeVector","⥙":"LeftDownVectorBar","⌊":"lfloor","↼":"lharu","⇇":"llarr","⇋":"lrhar","⥎":"LeftRightVector","↤":"mapstoleft","⥚":"LeftTeeVector","⋋":"lthree","⧏":"LeftTriangleBar","⊲":"vltri","⊴":"ltrie","⥑":"LeftUpDownVector","⥠":"LeftUpTeeVector","⥘":"LeftUpVectorBar","↿":"uharl","⥒":"LeftVectorBar","⪋":"lEg","⋚":"leg","⩽":"les","⪨":"lescc","⩿":"lesdot","⪁"
rceil:"⌉",rcub:"}",Rcy:"Р",rcy:"р",rdca:"⤷",rdldhar:"⥩",rdquo:"”",rdquor:"”",rdsh:"↳",real:"",realine:"",realpart:"",reals:"",Re:"",rect:"▭",reg:"®",REG:"®",ReverseElement:"∋",ReverseEquilibrium:"⇋",ReverseUpEquilibrium:"⥯",rfisht:"⥽",rfloor:"⌋",rfr:"𝔯",Rfr:"",rHar:"⥤",rhard:"⇁",rharu:"⇀",rharul:"⥬",Rho:"Ρ",rho:"ρ",rhov:"ϱ",RightAngleBracket:"⟩",RightArrowBar:"⇥",rightarrow:"→",RightArrow:"→",Rightarrow:"⇒",RightArrowLeftArrow:"⇄",rightarrowtail:"↣",RightCeiling:"⌉",RightDoubleBracket:"⟧",RightDownTeeVector:"⥝",RightDownVectorBar:"⥕",RightDownVector:"⇂",RightFloor:"⌋",rightharpoondown:"⇁",rightharpoonup:"⇀",rightleftarrows:"⇄",rightleftharpoons:"⇌",rightrightarrows:"⇉",rightsquigarrow:"↝",RightTeeArrow:"↦",RightTee:"⊢",RightTeeVector:"⥛",rightthreetimes:"⋌",RightTriangleBar:"⧐",RightTriangle:"⊳",RightTriangleEqual:"⊵",RightUpDownVector:"⥏",RightUpTeeVector:"⥜",RightUpVectorBar:"⥔",RightUpVector:"↾",RightVectorBar:"⥓",RightVector:"⇀",ring:"˚",risingdotseq:"≓",rlarr:"⇄",rlhar:"⇌",rlm:"",rmoustache:"⎱",rmoust:"⎱",rnmid:"⫮",roang:"⟭",roarr:"⇾",robrk:"⟧",ropar:"⦆",ropf:"𝕣",Ropf:"",roplus:"⨮",rotimes:"⨵",RoundImplies:"⥰",rpar:")",rpargt:"⦔",rppolint:"⨒",rrarr:"⇉",Rrightarrow:"⇛",rsaquo:"",rscr:"𝓇",Rscr:"",rsh:"↱",Rsh:"↱",rsqb:"]",rsquo:"",rsquor:"",rthree:"⋌",rtimes:"⋊",rtri:"▹",rtrie:"⊵",rtrif:"▸",rtriltri:"⧎",RuleDelayed:"⧴",ruluhar:"⥨",rx:"℞",Sacute:"Ś",sacute:"ś",sbquo:"",scap:"⪸",Scaron:"Š",scaron:"š",Sc:"⪼",sc:"≻",sccue:"≽",sce:"⪰",scE:"⪴",Scedil:"Ş",scedil:"ş",Scirc:"Ŝ",scirc:"ŝ",scnap:"⪺",scnE:"⪶",scnsim:"⋩",scpolint:"⨓",scsim:"≿",Scy:"С",scy:"с",sdotb:"⊡",sdot:"⋅",sdote:"⩦",searhk:"⤥",searr:"↘",seArr:"⇘",searrow:"↘",sect:"§",semi:";",seswar:"⤩",setminus:"",setmn:"",sext:"✶",Sfr:"𝔖",sfr:"𝔰",sfrown:"⌢",sharp:"♯",SHCHcy:"Щ",shchcy:"щ",SHcy:"Ш",shcy:"ш",ShortDownArrow:"↓",ShortLeftArrow:"←",shortmid:"",shortparallel:"∥",ShortRightArrow:"→",ShortUpArrow:"↑",shy:"­",Sigma:"Σ",sigma:"σ",sigmaf:"ς",sigmav:"ς",sim:"",simdot:"⩪",sime:"≃",simeq:"≃",simg:"⪞",simgE:"⪠",siml:"⪝",simlE:"⪟",simne:"≆",simplus:"⨤",simrarr:"⥲",slarr:"←",SmallCircle:"∘",smallsetminus:"",smashp:"⨳",smeparsl:"⧤",smid:"",smile:"⌣",smt:"⪪",smte:"⪬",smtes:"⪬︀",SOFTcy:"Ь",softcy:"ь",solbar:"⌿",solb:"⧄",sol:"/",Sopf:"𝕊",sopf:"𝕤",spades:"♠",spadesuit:"♠",spar:"∥",sqcap:"⊓",sqcaps:"⊓︀",sqcup:"⊔",sqcups:"⊔︀",Sqrt:"√",sqsub:"⊏",sqsube:"⊑",sqsubset:"⊏",sqsubseteq:"⊑",sqsup:"⊐",sqsupe:"⊒",sqsupset:"⊐",sqsupseteq:"⊒",square:"□",Square:"□",SquareIntersection:"⊓",SquareSubset:"⊏",SquareSubsetEqual:"⊑",SquareSuperset:"⊐",SquareSupersetEqual:"⊒",SquareUnion:"⊔",squarf:"▪",squ:"□",squf:"▪",srarr:"→",Sscr:"𝒮",sscr:"𝓈",ssetmn:"",ssmile:"⌣",sstarf:"⋆",Star:"⋆",star:"☆",starf:"★",straightepsilon:"ϵ",straightphi:"ϕ",strns:"¯",sub:"⊂",Sub:"⋐",subdot:"⪽",subE:"⫅",sube:"⊆",subedot:"⫃",submult:"⫁",subnE:"⫋",subne:"⊊",subplus:"⪿",subrarr:"⥹",subset:"⊂",Subset:"⋐",subseteq:"⊆",subseteqq:"⫅",SubsetEqual:"⊆",subsetneq:"⊊",subsetneqq:"⫋",subsim:"⫇",subsub:"⫕",subsup:"⫓",succapprox:"⪸",succ:"≻",succcurlyeq:"≽",Succeeds:"≻",SucceedsEqual:"⪰",SucceedsSlantEqual:"≽",SucceedsTilde:"≿",succeq:"⪰",succnapprox:"⪺",succneqq:"⪶",succnsim:"⋩",succsim:"≿",SuchThat:"∋",sum:"∑",Sum:"∑",sung:"♪",sup1:"¹",sup2:"²",sup3:"³",sup:"⊃",Sup:"⋑",supdot:"⪾",supdsub:"⫘",supE:"⫆",supe:"⊇",supedot:"⫄",Superset:"⊃",SupersetEqual:"⊇",suphsol:"⟉",suphsub:"⫗",suplarr:"⥻",supmult:"⫂",supnE:"⫌",supne:"⊋",supplus:"⫀",supset:"⊃",Supset:"⋑",supseteq:"⊇",supseteqq:"⫆",supsetneq:"⊋",supsetneqq:"⫌",supsim:"⫈",supsub:"⫔",supsup:"⫖",swarhk:"⤦",swarr:"↙",swArr:"⇙",sw
}function Le(){return d(this)}function Oe(){return u({},h(this))}function Ie(){return h(this).overflow}function Ne(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Me(t,e){R(0,[t,t.length],0,e)}function Re(t){return Ue.call(this,t,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Pe(t){return Ue.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)}function qe(){return bt(this.year(),1,4)}function je(){var t=this.localeData()._week;return bt(this.year(),t.dow,t.doy)}function Ue(t,e,r,n,i){var a;return null==t?vt(this,n,i).year:(a=bt(t,n,i),e>a&&(e=a),Ye.call(this,t,e,r,n,i))}function Ye(t,e,r,n,i){var a=yt(t,e,r,n,i),s=dt(a.year,0,a.dayOfYear);return this.year(s.getUTCFullYear()),this.month(s.getUTCMonth()),this.date(s.getUTCDate()),this}function Ve(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)}function Ge(t){return vt(t,this._week.dow,this._week.doy).week}function $e(){return this._week.dow}function He(){return this._week.doy}function We(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function ze(t){var e=vt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function Ze(t,e){return"string"!=typeof t?t:isNaN(t)?(t=e.weekdaysParse(t),"number"==typeof t?t:null):parseInt(t,10)}function Xe(t,e){return i(this._weekdays)?this._weekdays[t.day()]:this._weekdays[this._weekdays.isFormat.test(e)?"format":"standalone"][t.day()]}function Ke(t){return this._weekdaysShort[t.day()]}function Je(t){return this._weekdaysMin[t.day()]}function Qe(t,e,r){var n,i,a;for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),n=0;7>n;n++){if(i=Lt([2e3,1]).day(n),r&&!this._fullWeekdaysParse[n]&&(this._fullWeekdaysParse[n]=new RegExp("^"+this.weekdays(i,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[n]=new RegExp("^"+this.weekdaysShort(i,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[n]=new RegExp("^"+this.weekdaysMin(i,"").replace(".",".?")+"$","i")),this._weekdaysParse[n]||(a="^"+this.weekdays(i,"")+"|^"+this.weekdaysShort(i,"")+"|^"+this.weekdaysMin(i,""),this._weekdaysParse[n]=new RegExp(a.replace(".",""),"i")),r&&"dddd"===e&&this._fullWeekdaysParse[n].test(t))return n;if(r&&"ddd"===e&&this._shortWeekdaysParse[n].test(t))return n;if(r&&"dd"===e&&this._minWeekdaysParse[n].test(t))return n;if(!r&&this._weekdaysParse[n].test(t))return n}}function tr(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=Ze(t,this.localeData()),this.add(t-e,"d")):e}function er(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")}function rr(t){return this.isValid()?null==t?this.day()||7:this.day(this.day()%7?t:t-7):null!=t?this:NaN}function nr(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}function ir(){return this.hours()%12||12}function ar(t,e){R(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}function sr(t,e){return e._meridiemParse}function or(t){return"p"===(t+"").toLowerCase().charAt(0)}function ur(t,e,r){return t>11?r?"pm":"PM":r?"am":"AM"}function cr(t,e){e[Sn]=b(1e3*("0."+t))}function lr(){return this._isUTC?"UTC":""}function hr(){return this._isUTC?"Coordinated Universal Time":""}function dr(t){return Lt(1e3*t)}function fr(){return Lt.apply(null,arguments).parseZone()}function pr(t,e,r){var n=this._calendar[t];return B(n)?n.call(e,r):n}function gr(t){var e=this._longDateFormat[t],r=this._longDateFormat[t.toUpperCase()];return e||!r?e:(this._longDateFormat[t]=r.replace(/MMMM|MM|DD|dddd/g,function(t){return t.slice(1)}),this._longDateFormat[t])}function mr(){return this._invalidDate}function yr(t){return this._ordinal.replace("%d",t)}function vr(t){return t}function br(t,e,r,n){var i=this._relativeTime[r];return B(i)?i(t,e,r,n):i.replace(/%d/i,t)}function _r
p=!0,e.methods.forEach(function(t){r(y,t,p),p=!1});var v=s.node().getBBox();return s.insert("rect",":first-child").attr("x",0).attr("y",0).attr("width",v.width+2*h.padding).attr("height",v.height+h.padding+.5*h.dividerMargin),d.attr("x2",v.width+2*h.padding),m.attr("x2",v.width+2*h.padding),i.width=v.width+2*h.padding,i.height=v.height+h.padding+.5*h.dividerMargin,a[n]=i,l++,i};e.exports.setConf=function(t){var e=Object.keys(t);e.forEach(function(e){h[e]=t[e]})},e.exports.draw=function(t,e){n.yy.clear(),n.parse(t),c.info("Rendering diagram "+t);var r=s.select("#"+e);f(r);var a=new u.graphlib.Graph({multigraph:!0});a.setGraph({isMultiGraph:!0}),a.setDefaultEdgeLabel(function(){return{}});var o,l=i.getClasses(),h=Object.keys(l);for(o=0;o<h.length;o++){var p=l[h[o]],y=m(r,p);a.setNode(y.id,y),c.info("Org height: "+y.height)}var v=i.getRelations(),o=0;v.forEach(function(t){o+=1,c.info("tjoho"+d(t.id1)+d(t.id2)+JSON.stringify(t)),a.setEdge(d(t.id1),d(t.id2),{relation:t})}),u.layout(a),a.nodes().forEach(function(t){"undefined"!=typeof t&&(c.debug("Node "+t+": "+JSON.stringify(a.node(t))),s.select("#"+t).attr("transform","translate("+(a.node(t).x-a.node(t).width/2)+","+(a.node(t).y-a.node(t).height/2)+" )"))}),a.edges().forEach(function(t){c.debug("Edge "+t.v+" -> "+t.w+": "+JSON.stringify(a.edge(t))),g(r,a.edge(t),a.edge(t).relation)}),r.attr("height","100%"),r.attr("width","100%")}},{"../../d3":107,"../../logger":126,"./classDb":108,"./parser/classDiagram":110,dagre:53}],110:[function(t,e,r){(function(n){"use strict";var i=function(){function t(){this.yy={}}var e=function(t,e,r,n){for(r=r||{},n=t.length;n--;r[t[n]]=e);return r},r=[1,11],n=[1,12],i=[1,13],a=[1,15],s=[1,16],o=[1,17],u=[6,8],c=[1,26],l=[1,27],h=[1,28],d=[1,29],f=[1,30],p=[1,31],g=[6,8,13,17,23,26,27,28,29,30,31],m=[6,8,13,17,23,26,27,28,29,30,31,45,46,47],y=[23,45,46,47],v=[23,30,31,45,46,47],b=[23,26,27,28,29,45,46,47],_=[6,8,13],A=[1,46],w={trace:function(){},yy:{},symbols_:{error:2,mermaidDoc:3,graphConfig:4,CLASS_DIAGRAM:5,NEWLINE:6,statements:7,EOF:8,statement:9,className:10,alphaNumToken:11,relationStatement:12,LABEL:13,classStatement:14,methodStatement:15,CLASS:16,STRUCT_START:17,members:18,STRUCT_STOP:19,MEMBER:20,SEPARATOR:21,relation:22,STR:23,relationType:24,lineType:25,AGGREGATION:26,EXTENSION:27,COMPOSITION:28,DEPENDENCY:29,LINE:30,DOTTED_LINE:31,commentToken:32,textToken:33,graphCodeTokens:34,textNoTagsToken:35,TAGSTART:36,TAGEND:37,"==":38,"--":39,PCT:40,DEFAULT:41,SPACE:42,MINUS:43,keywords:44,UNICODE_TEXT:45,NUM:46,ALPHA:47,$accept:0,$end:1},terminals_:{2:"error",5:"CLASS_DIAGRAM",6:"NEWLINE",8:"EOF",13:"LABEL",16:"CLASS",17:"STRUCT_START",19:"STRUCT_STOP",20:"MEMBER",21:"SEPARATOR",23:"STR",26:"AGGREGATION",27:"EXTENSION",28:"COMPOSITION",29:"DEPENDENCY",30:"LINE",31:"DOTTED_LINE",34:"graphCodeTokens",36:"TAGSTART",37:"TAGEND",38:"==",39:"--",40:"PCT",41:"DEFAULT",42:"SPACE",43:"MINUS",44:"keywords",45:"UNICODE_TEXT",46:"NUM",47:"ALPHA"},productions_:[0,[3,1],[4,4],[7,1],[7,3],[10,2],[10,1],[9,1],[9,2],[9,1],[9,1],[14,2],[14,5],[18,1],[18,2],[15,1],[15,2],[15,1],[15,1],[12,3],[12,4],[12,4],[12,5],[22,3],[22,2],[22,2],[22,1],[24,1],[24,1],[24,1],[24,1],[25,1],[25,1],[32,1],[32,1],[33,1],[33,1],[33,1],[33,1],[33,1],[33,1],[33,1],[35,1],[35,1],[35,1],[35,1],[11,1],[11,1],[11,1]],performAction:function(t,e,r,n,i,a,s){var o=a.length-1;switch(i){case 5:this.$=a[o-1]+a[o];break;case 6:this.$=a[o];break;case 7:n.addRelation(a[o]);break;case 8:a[o-1].title=n.cleanupLabel(a[o]),n.addRelation(a[o-1]);break;case 12:n.addMembers(a[o-3],a[o-1]);break;case 13:this.$=[a[o]];break;case 14:a[o].push(a[o-1]),this.$=a[o];break;case 15:break;case 16:n.addMembers(a[o-1],n.cleanupLabel(a[o]));break;case 17:console.warn("Member",a[o]);break;case 18:break;case 19:this.$={id1:a[o-2],id2:a[o],relation:a[o-1],relationTitle1:"none",relationTitle2:"none"};break;case 20:this.$={id1:a[o-3],id2:a[o],relation:a[o-1],relationTitle1:a[o-2],relationTitle2:"none"};break;case 21:this.$={id1:a[o-3],id2:a[o],relation:a[o-2],relationTitle1:"none",relationTitle2:a[o-1]};break;case 22:t
s},r.draw=function(t,e,u){c.debug("Drawing flowchart");var h;n.clear(),h=u?a.parser:i.parser,h.yy=n;try{h.parse(t)}catch(d){c.debug("Parsing failed")}var f;f=n.getDirection(),"undefined"==typeof f&&(f="TD");var p,g=new o.graphlib.Graph({multigraph:!0,compound:!0}).setGraph({rankdir:f,marginx:20,marginy:20}).setDefaultEdgeLabel(function(){return{}}),m=n.getSubGraphs(),y=0;for(y=m.length-1;y>=0;y--)p=m[y],n.addVertex(p.id,p.title,"group",void 0);var v=n.getVertices(),b=n.getEdges();y=0;var _;for(y=m.length-1;y>=0;y--)for(p=m[y],s.selectAll("cluster").append("text"),_=0;_<p.nodes.length;_++)g.setParent(p.nodes[_],p.id);r.addVertices(v,g),r.addEdges(b,g);var A=new o.render;A.shapes().question=function(t,e,r){var n=e.width,i=e.height,a=.8*(n+i),s=[{x:a/2,y:0},{x:a,y:-a/2},{x:a/2,y:-a},{x:0,y:-a/2}],u=t.insert("polygon",":first-child").attr("points",s.map(function(t){return t.x+","+t.y}).join(" ")).attr("rx",5).attr("ry",5).attr("transform","translate("+-a/2+","+2*a/4+")");return r.intersect=function(t){return o.intersect.polygon(r,s,t)},u},A.shapes().rect_left_inv_arrow=function(t,e,r){var n=e.width,i=e.height,a=[{x:-i/2,y:0},{x:n,y:0},{x:n,y:-i},{x:-i/2,y:-i},{x:0,y:-i/2}],s=t.insert("polygon",":first-child").attr("points",a.map(function(t){return t.x+","+t.y}).join(" ")).attr("transform","translate("+-n/2+","+2*i/4+")");return r.intersect=function(t){return o.intersect.polygon(r,a,t)},s},A.shapes().rect_right_inv_arrow=function(t,e,r){var n=e.width,i=e.height,a=[{x:0,y:0},{x:n+i/2,y:0},{x:n,y:-i/2},{x:n+i/2,y:-i},{x:0,y:-i}],s=t.insert("polygon",":first-child").attr("points",a.map(function(t){return t.x+","+t.y}).join(" ")).attr("transform","translate("+-n/2+","+2*i/4+")");return r.intersect=function(t){return o.intersect.polygon(r,a,t)},s},A.arrows().none=function(t,e,r,n){var i=t.append("marker").attr("id",e).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerUnits","strokeWidth").attr("markerWidth",8).attr("markerHeight",6).attr("orient","auto"),a=i.append("path").attr("d","M 0 0 L 0 0 L 0 0 z");o.util.applyStyle(a,r[n+"Style"])};var w=s.select("#"+e),x=s.select("#"+e+" g");for(A(x,g),x.selectAll("g.node").attr("title",function(){return n.getTooltip(this.id)}),l.useMaxWidth?(w.attr("height","100%"),w.attr("width",l.width),w.attr("viewBox","0 0 "+(g.graph().width+20)+" "+(g.graph().height+20)),w.attr("style","max-width:"+(g.graph().width+20)+"px;")):(w.attr("height",g.graph().height),"undefined"==typeof l.width?w.attr("width",g.graph().width):w.attr("width",l.width),w.attr("viewBox","0 0 "+(g.graph().width+20)+" "+(g.graph().height+20))),n.indexNodes("subGraph"+y),y=0;y<m.length;y++)if(p=m[y],"undefined"!==p.title){var E=document.querySelectorAll("#"+e+" #"+p.id+" rect"),k=document.querySelectorAll("#"+e+" #"+p.id),D=E[0].x.baseVal.value,C=E[0].y.baseVal.value,F=E[0].width.baseVal.value,T=s.select(k[0]),S=T.append("text");S.attr("x",D+F/2),S.attr("y",C+14),S.attr("fill","black"),S.attr("stroke","none"),S.attr("id",e+"Text"),S.style("text-anchor","middle"),"undefined"==typeof p.title?S.text("Undef"):S.text(p.title)}}},{"../../d3":107,"../../logger":126,"./dagre-d3":114,"./graphDb":116,"./parser/dot":117,"./parser/flow":118}],116:[function(require,module,exports){(function(global){"use strict";var Logger=require("../../logger"),log=new Logger.Log,d3=require("../../d3"),vertices={},edges=[],classes=[],subGraphs=[],tooltips={},subCount=0,direction,funs=[];exports.addVertex=function(t,e,r,n){var i;"undefined"!=typeof t&&0!==t.trim().length&&("undefined"==typeof vertices[t]&&(vertices[t]={id:t,styles:[],classes:[]}),"undefined"!=typeof e&&(i=e.trim(),'"'===i[0]&&'"'===i[i.length-1]&&(i=i.substring(1,i.length-1)),vertices[t].text=i),"undefined"!=typeof r&&(vertices[t].type=r),"undefined"!=typeof r&&(vertices[t].type=r),"undefined"!=typeof n&&null!==n&&n.forEach(function(e){vertices[t].styles.push(e)}))},exports.addLink=function(t,e,r,n){log.debug("Got edge",t,e);var i={start:t,end:e,type:void 0,text:""};n=r.text,"undefined"!=typeof n&&(i.text=n.trim(),'"'===i.text[0]&&'"'===i.text[i.text.length-1]&&(i.text=i.
performAction:function(t,e,r,n,i,a,s){var o=a.length-1;switch(i){case 2:this.$=[];break;case 3:a[o]!==[]&&a[o-1].push(a[o]),this.$=a[o-1];break;case 4:case 57:case 59:case 60:case 92:case 94:case 95:case 108:this.$=a[o];break;case 11:n.setDirection(a[o-1]),this.$=a[o-1];break;case 12:n.setDirection("LR"),this.$=a[o-1];break;case 13:n.setDirection("RL"),this.$=a[o-1];break;case 14:n.setDirection("BT"),this.$=a[o-1];break;case 15:n.setDirection("TB"),this.$=a[o-1];break;case 30:this.$=a[o-1];break;case 31:case 32:case 33:case 34:case 35:this.$=[];break;case 36:this.$=n.addSubGraph(a[o-1],a[o-3]);break;case 37:this.$=n.addSubGraph(a[o-1],void 0);break;case 41:n.addLink(a[o-2],a[o],a[o-1]),this.$=[a[o-2],a[o]];break;case 42:this.$=[a[o]];break;case 43:this.$=a[o-3],n.addVertex(a[o-3],a[o-1],"square");break;case 44:this.$=a[o-4],n.addVertex(a[o-4],a[o-2],"square");break;case 45:this.$=a[o-5],n.addVertex(a[o-5],a[o-2],"circle");break;case 46:this.$=a[o-6],n.addVertex(a[o-6],a[o-3],"circle");break;case 47:this.$=a[o-3],n.addVertex(a[o-3],a[o-1],"ellipse");break;case 48:this.$=a[o-4],n.addVertex(a[o-4],a[o-2],"ellipse");break;case 49:this.$=a[o-3],n.addVertex(a[o-3],a[o-1],"round");break;case 50:this.$=a[o-4],n.addVertex(a[o-4],a[o-2],"round");break;case 51:this.$=a[o-3],n.addVertex(a[o-3],a[o-1],"diamond");break;case 52:this.$=a[o-4],n.addVertex(a[o-4],a[o-2],"diamond");break;case 53:this.$=a[o-3],n.addVertex(a[o-3],a[o-1],"odd");break;case 54:this.$=a[o-4],n.addVertex(a[o-4],a[o-2],"odd");break;case 55:this.$=a[o],n.addVertex(a[o]);break;case 56:this.$=a[o-1],n.addVertex(a[o-1]);break;case 58:case 93:case 96:case 109:this.$=a[o-1]+""+a[o];break;case 61:this.$="v";break;case 62:this.$="-";break;case 63:a[o-1].text=a[o],this.$=a[o-1];break;case 64:case 65:a[o-2].text=a[o-1],this.$=a[o-2];break;case 66:this.$=a[o];break;case 67:this.$={type:"arrow",stroke:"normal",text:a[o-1]};break;case 68:this.$={type:"arrow_circle",stroke:"normal",text:a[o-1]};break;case 69:this.$={type:"arrow_cross",stroke:"normal",text:a[o-1]};break;case 70:this.$={type:"arrow_open",stroke:"normal",text:a[o-1]};break;case 71:this.$={type:"arrow",stroke:"dotted",text:a[o-1]};break;case 72:this.$={type:"arrow_circle",stroke:"dotted",text:a[o-1]};break;case 73:this.$={type:"arrow_cross",stroke:"dotted",text:a[o-1]};break;case 74:this.$={type:"arrow_open",stroke:"dotted",text:a[o-1]};break;case 75:this.$={type:"arrow",stroke:"thick",text:a[o-1]};break;case 76:this.$={type:"arrow_circle",stroke:"thick",text:a[o-1]};break;case 77:this.$={type:"arrow_cross",stroke:"thick",text:a[o-1]};break;case 78:this.$={type:"arrow_open",stroke:"thick",text:a[o-1]};break;case 79:this.$={type:"arrow",stroke:"normal"};break;case 80:this.$={type:"arrow_circle",stroke:"normal"};break;case 81:this.$={type:"arrow_cross",stroke:"normal"};break;case 82:this.$={type:"arrow_open",stroke:"normal"};break;case 83:this.$={type:"arrow",stroke:"dotted"};break;case 84:this.$={type:"arrow_circle",stroke:"dotted"};break;case 85:this.$={type:"arrow_cross",stroke:"dotted"};break;case 86:this.$={type:"arrow_open",stroke:"dotted"};break;case 87:this.$={type:"arrow",stroke:"thick"};break;case 88:this.$={type:"arrow_circle",stroke:"thick"};break;case 89:this.$={type:"arrow_cross",stroke:"thick"};break;case 90:this.$={type:"arrow_open",stroke:"thick"};break;case 91:this.$=a[o-1];break;case 110:case 111:this.$=a[o-4],n.addClass(a[o-2],a[o]);break;case 112:this.$=a[o-4],n.setClass(a[o-2],a[o]);break;case 113:this.$=a[o-4],n.setClickEvent(a[o-2],a[o],void 0,void 0);break;case 114:this.$=a[o-6],n.setClickEvent(a[o-4],a[o-2],void 0,a[o]);break;case 115:this.$=a[o-4],n.setClickEvent(a[o-2],void 0,a[o],void 0);break;case 116:this.$=a[o-6],n.setClickEvent(a[o-4],void 0,a[o-2],a[o]);break;case 117:this.$=a[o-4],n.addVertex(a[o-2],void 0,void 0,a[o]);break;case 118:case 119:case 120:this.$=a[o-4],n.updateLink(a[o-2],a[o]);break;case 122:this.$=[a[o]];break;case 123:a[o-2].push(a[o]),this.$=a[o-2];break;case 125:this.$=a[o-1]+a[o]}},table:[{3:1,4:2,9:r,10:n,12:i},{1:[3]},e(a,s,{5:6}),{4:7,9:r,10:n,12:i},{4:8,9:r,1
return i};r.parseError=function(t,r){e.mermaidAPI.parseError(t,r)}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"../../logger":126,moment:105}],120:[function(t,e,r){"use strict";var n=t("./parser/gantt").parser;n.yy=t("./ganttDb");var i,a=t("../../d3"),s=t("moment"),o={titleTopMargin:25,barHeight:20,barGap:4,topPadding:50,sidePadding:75,gridLineStartPadding:35,fontSize:11,fontFamily:'"Open-Sans", "sans-serif"'};e.exports.setConf=function(t){var e=Object.keys(t);e.forEach(function(e){o[e]=t[e]})};var u;e.exports.draw=function(t,e){function r(t,e,r){var n=o.barHeight,i=n+o.barGap,s=o.topPadding,u=o.sidePadding,f=a.scale.linear().domain([0,x.length]).range(["#00B9FA","#F95002"]).interpolate(a.interpolateHcl);l(u,s,e,r),c(t,i,s,u,n,f,e,r),h(i,s,u,n,f),d(u,s,e,r)}function c(t,e,r,n,i,a,s,u){b.append("g").selectAll("rect").data(t).enter().append("rect").attr("x",0).attr("y",function(t,n){return n*e+r-2}).attr("width",function(){return s-n/2}).attr("height",e).attr("class",function(t){for(var e=0;e<x.length;e++)if(t.type===x[e])return"section section"+e%o.numberSectionStyles;return"section section0"});var c=b.append("g").selectAll("rect").data(t).enter();c.append("rect").attr("rx",3).attr("ry",3).attr("x",function(t){return w(t.startTime)+n}).attr("y",function(t,n){return n*e+r}).attr("width",function(t){return w(t.endTime)-w(t.startTime)}).attr("height",i).attr("class",function(t){for(var e="task ",r=0,n=0;n<x.length;n++)t.type===x[n]&&(r=n%o.numberSectionStyles);return t.active?t.crit?e+" activeCrit"+r:e+" active"+r:t.done?t.crit?e+" doneCrit"+r:e+" done"+r:t.crit?e+" crit"+r:e+" task"+r}),c.append("text").text(function(t){return t.task}).attr("font-size",o.fontSize).attr("x",function(t){var e=w(t.startTime),r=w(t.endTime),i=this.getBBox().width;return i>r-e?r+i+1.5*o.sidePadding>s?e+n-5:r+n+5:(r-e)/2+e+n}).attr("y",function(t,n){return n*e+o.barHeight/2+(o.fontSize/2-2)+r}).attr("text-height",i).attr("class",function(t){for(var e=w(t.startTime),r=w(t.endTime),n=this.getBBox().width,i=0,a=0;a<x.length;a++)t.type===x[a]&&(i=a%o.numberSectionStyles);var u="";return t.active&&(u=t.crit?"activeCritText"+i:"activeText"+i),t.done?u=t.crit?u+" doneCritText"+i:u+" doneText"+i:t.crit&&(u=u+" critText"+i),n>r-e?r+n+1.5*o.sidePadding>s?"taskTextOutsideLeft taskTextOutside"+i+" "+u:"taskTextOutsideRight taskTextOutside"+i+" "+u:"taskText taskText"+i+" "+u})}function l(t,e,r,n){var s,u=[[".%L",function(t){return t.getMilliseconds()}],[":%S",function(t){return t.getSeconds()}],["h1 %I:%M",function(t){return t.getMinutes()}]],c=[["%Y",function(){return!0}]],l=[["%I:%M",function(t){return t.getHours()}],["%a %d",function(t){return t.getDay()&&1!=t.getDate()}],["%b %d",function(t){return 1!=t.getDate()}],["%B",function(t){return t.getMonth()}]];"undefined"!=typeof o.axisFormatter&&(l=[],o.axisFormatter.forEach(function(t){var e=[];e[0]=t[0],e[1]=t[1],l.push(e)})),s=u.concat(l).concat(c);var h=a.svg.axis().scale(w).orient("bottom").tickSize(-n+e+o.gridLineStartPadding,0,0).tickFormat(a.time.format.multi(s));i>7&&230>i&&(h=h.ticks(a.time.monday.range)),b.append("g").attr("class","grid").attr("transform","translate("+t+", "+(n-50)+")").call(h).selectAll("text").style("text-anchor","middle").attr("fill","#000").attr("stroke","none").attr("font-size",10).attr("dy","1em")}function h(t,e){for(var r=[],n=0,i=0;i<x.length;i++)r[i]=[x[i],g(x[i],k)];b.append("g").selectAll("text").data(r).enter().append("text").text(function(t){return t[0]}).attr("x",10).attr("y",function(i,a){if(!(a>0))return i[1]*t/2+e;for(var s=0;a>s;s++)return n+=r[a-1][1],i[1]*t/2+n*t+e}).attr("class",function(t){for(var e=0;e<x.length;e++)if(t[0]===x[e])return"sectionTitle sectionTitle"+e%o.numberSectionStyles;return"sectionTitle"})}function d(t,e,r,n){var i=b.append("g").attr("class","today"),a=new Date;i.append("line").attr("x1",w(a)+t).attr("x2",w(a)+t).attr("y1",o.titleTopMargin).attr("y2",n-o.titleTopMargin).attr("class","today")}function f(t){for(var e={},r=[],n=0,i=t.length;i>n;++n)e.hasOwnProperty(t[n]
this.updateVal(r.bounds.data,"stopy",u,Math.max),this.updateLoops(a,s,o,u)},newLoop:function(t){this.list.push({startx:void 0,starty:this.verticalPos,stopx:void 0,stopy:void 0,title:t})},endLoop:function(){var t=this.list.pop();return t},addElseToLoop:function(t){var e=this.list.pop();e.elsey=r.bounds.getVerticalPos(),e.elseText=t,this.list.push(e)},bumpVerticalPos:function(t){this.verticalPos=this.verticalPos+t,this.data.stopy=this.verticalPos},getVerticalPos:function(){return this.verticalPos},getBounds:function(){return this.data}};var c=function(t,e,n,a,s){var o=i.getNoteRect();o.x=e,o.y=n,o.width=s||u.width,o["class"]="note";var c=t.append("g"),l=i.drawRect(c,o),h=i.getTextObj();h.x=e-4,h.y=n-13,h.textMargin=u.noteMargin,h.dy="1em",h.text=a.message,h["class"]="noteText";var d=i.drawText(c,h,o.width-u.noteMargin),f=d[0][0].getBBox().height;!s&&f>u.width?(d.remove(),c=t.append("g"),d=i.drawText(c,h,2*o.width-u.noteMargin),f=d[0][0].getBBox().height,l.attr("width",2*o.width),r.bounds.insert(e,n,e+2*o.width,n+2*u.noteMargin+f)):r.bounds.insert(e,n,e+o.width,n+2*u.noteMargin+f),l.attr("height",f+2*u.noteMargin),r.bounds.bumpVerticalPos(f+2*u.noteMargin)},l=function(t,e,i,a,s){var o,c=t.append("g"),l=e+(i-e)/2,h=c.append("text").attr("x",l).attr("y",a-7).style("text-anchor","middle").attr("class","messageText").text(s.message);o="undefined"!=typeof h[0][0].getBBox?h[0][0].getBBox().width:h[0][0].getBoundingClientRect();var d;if(e===i){d=c.append("path").attr("d","M "+e+","+a+" C "+(e+60)+","+(a-10)+" "+(e+60)+","+(a+30)+" "+e+","+(a+20)),r.bounds.bumpVerticalPos(30);var f=Math.max(o/2,100);r.bounds.insert(e-f,r.bounds.getVerticalPos()-10,i+f,r.bounds.getVerticalPos())}else d=c.append("line"),d.attr("x1",e),d.attr("y1",a),d.attr("x2",i),d.attr("y2",a),r.bounds.insert(e,r.bounds.getVerticalPos()-10,i,r.bounds.getVerticalPos());s.type===n.yy.LINETYPE.DOTTED||s.type===n.yy.LINETYPE.DOTTED_CROSS||s.type===n.yy.LINETYPE.DOTTED_OPEN?(d.style("stroke-dasharray","3, 3"),d.attr("class","messageLine1")):d.attr("class","messageLine0");var p="";u.arrowMarkerAbsolute&&(p=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,p=p.replace(/\(/g,"\\("),p=p.replace(/\)/g,"\\)")),d.attr("stroke-width",2),d.attr("stroke","black"),d.style("fill","none"),(s.type===n.yy.LINETYPE.SOLID||s.type===n.yy.LINETYPE.DOTTED)&&d.attr("marker-end","url("+p+"#arrowhead)"),(s.type===n.yy.LINETYPE.SOLID_CROSS||s.type===n.yy.LINETYPE.DOTTED_CROSS)&&d.attr("marker-end","url("+p+"#crosshead)")};e.exports.drawActors=function(t,e,n,a){var s;for(s=0;s<n.length;s++){var o=n[s];e[o].x=s*u.actorMargin+s*u.width,e[o].y=a,e[o].width=u.diagramMarginY,e[o].height=u.diagramMarginY,i.drawActor(t,e[o].x,a,e[o].description,u),r.bounds.insert(e[o].x,a,e[o].x+u.width,u.height)}r.bounds.bumpVerticalPos(u.height)},e.exports.setConf=function(t){var e=Object.keys(t);e.forEach(function(e){u[e]=t[e]})},e.exports.draw=function(t,s){n.yy.clear(),n.parse(t+"\n"),r.bounds.init();var h,d,f,p=a.select("#"+s),g=n.yy.getActors(),m=n.yy.getActorKeys(),y=n.yy.getMessages();e.exports.drawActors(p,g,m,0),i.insertArrowHead(p),i.insertArrowCrossHead(p),y.forEach(function(t){var e;switch(t.type){case n.yy.LINETYPE.NOTE:r.bounds.bumpVerticalPos(u.boxMargin),h=g[t.from].x,d=g[t.to].x,t.placement===n.yy.PLACEMENT.RIGHTOF?c(p,h+(u.width+u.actorMargin)/2,r.bounds.getVerticalPos(),t):t.placement===n.yy.PLACEMENT.LEFTOF?c(p,h-(u.width+u.actorMargin)/2,r.bounds.getVerticalPos(),t):t.to===t.from?c(p,h,r.bounds.getVerticalPos(),t):(f=Math.abs(h-d)+u.actorMargin,c(p,(h+d+u.width-f)/2,r.bounds.getVerticalPos(),t,f));break;case n.yy.LINETYPE.LOOP_START:r.bounds.bumpVerticalPos(u.boxMargin),r.bounds.newLoop(t.message),r.bounds.bumpVerticalPos(u.boxMargin+u.boxTextMargin);break;case n.yy.LINETYPE.LOOP_END:e=r.bounds.endLoop(),i.drawLoop(p,e,"loop",u),r.bounds.bumpVerticalPos(u.boxMargin);break;case n.yy.LINETYPE.OPT_START:r.bounds.bumpVerticalPos(u.boxMargin),r.bounds.newLoop(t.message),r.bounds.bumpVerticalPos(u.boxMargin+u.boxTextMargin);break;case n.yy.LINETYPE.OPT
</script>
<style type="text/css">.DiagrammeR,.grViz pre {
white-space: pre-wrap;
white-space: -moz-pre-wrap;
white-space: -pre-wrap;
white-space: -o-pre-wrap;
word-wrap: break-word;
}
.DiagrammeR g .label {
font-family: Helvetica;
font-size: 14px;
color: #333333;
}
</style>
<script>(function () {
var Categories, Color, ColorScale, chromato, CSSColors, Ramp, root, type, _ref, _ref2, _ref3;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
root = typeof exports !== 'undefined' && exports !== null ? exports : this;
chromato = (_ref = root.chromato) != null ? _ref : root.chromato = {};
if (typeof module !== 'undefined' && module !== null) module.exports = chromato;
Color = (function() {
function Color(x, y, z, m) {
var me, _ref2;
me = this;
if (!(x != null) && !(y != null) && !(z != null) && !(m != null)) {
x = [255, 0, 255];
}
if (type(x) === 'array' && x.length === 3) {
if (m == null) m = y;
_ref2 = x, x = _ref2[0], y = _ref2[1], z = _ref2[2];
}
if (type(x) === 'string') {
m = 'hex';
} else {
if (m == null) m = 'rgb';
}
if (m === 'rgb') {
me.rgb = [x, y, z];
} else if (m === 'hsl') {
me.rgb = Color.hsl2rgb(x, y, z);
} else if (m === 'hsv') {
me.rgb = Color.hsv2rgb(x, y, z);
} else if (m === 'hex') {
me.rgb = Color.hex2rgb(x);
} else if (m === 'lab') {
me.rgb = Color.lab2rgb(x, y, z);
} else if (m === 'hcl') {
me.rgb = Color.hcl2rgb(x, y, z);
} else if (m === 'hsi') {
me.rgb = Color.hsi2rgb(x, y, z);
}
}
Color.prototype.hex = function() {
return Color.rgb2hex(this.rgb);
};
Color.prototype.toString = function() {
return this.hex();
};
Color.prototype.hsl = function() {
return Color.rgb2hsl(this.rgb);
};
Color.prototype.hsv = function() {
return Color.rgb2hsv(this.rgb);
};
Color.prototype.lab = function() {
return Color.rgb2lab(this.rgb);
};
Color.prototype.hcl = function() {
return Color.rgb2hcl(this.rgb);
};
Color.prototype.hsi = function() {
return Color.rgb2hsi(this.rgb);
};
Color.prototype.interpolate = function(f, col, m) {
var dh, hue, hue0, hue1, lbv, lbv0, lbv1, me, sat, sat0, sat1, xyz0, xyz1;
me = this;
if (m == null) m = 'rgb';
if (type(col) === 'string') col = new Color(col);
if (m === 'hsl' || m === 'hsv' || m === 'hcl' || m === 'hsi') {
if (m === 'hsl') {
xyz0 = me.hsl();
xyz1 = col.hsl();
} else if (m === 'hsv') {
xyz0 = me.hsv();
xyz1 = col.hsv();
} else if (m === 'hcl') {
xyz0 = me.hcl();
xyz1 = col.hcl();
} else if (m === 'hsi') {
xyz0 = me.hsi();
xyz1 = col.hsi();
}
hue0 = xyz0[0], sat0 = xyz0[1], lbv0 = xyz0[2];
hue1 = xyz1[0], sat1 = xyz1[1], lbv1 = xyz1[2];
if (!isNaN(hue0) && !isNaN(hue1)) {
if (hue1 > hue0 && hue1 - hue0 > 180) {
dh = hue1 - (hue0 + 360);
} else if (hue1 < hue0 && hue0 - hue1 > 180) {
dh = hue1 + 360 - hue0;
} else {
dh = hue1 - hue0;
}
hue = hue0 + f * dh;
} else if (!isNaN(hue0)) {
hue = hue0;
if (lbv1 === 1 || lbv1 === 0) sat = sat0;
} else if (!isNaN(hue1)) {
hue = hue1;
if (lbv0 === 1 || lbv0 === 0) sat = sat1;
} else {
hue = void 0;
}
if (sat == null) sat = sat0 + f * (sat1 - sat0);
lbv = lbv0 + f * (lbv1 - lbv0);
return new Color(hue, sat, lbv, m);
} else if (m === 'rgb') {
xyz0 = me.rgb;
xyz1 = col.rgb;
return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);
} else if (m === 'lab') {
xyz0 = me.lab();
xyz1 = col.lab();
return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);
} else {
throw m + ' is not supported as a color mode';
}
};
return Color;
})();
Color.hex2rgb = function(hex) {
var b, g, r, u;
if (!hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {
if ((chromato.colors != null) && chromato.colors[hex]) {
hex = chromato.colors[hex];
} else {
throw 'This color format is unknown: ' + hex;
}
}
if (hex.length === 4 || hex.length === 7) hex = hex.substr(1);
if (hex.length === 3) {
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
}
u = parseInt(hex, 16);
r = u >> 16;
g = u >> 8 & 0xFF;
b = u & 0xFF;
return [r, g, b];
};
Color.rgb2hex = function(r, g, b) {
var str, u, _ref2;
if (r !== void 0 && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
u = r << 16 | g << 8 | b;
str = '000000' + u.toString(16).toUpperCase();
return '#' + str.substr(str.length - 6);
};
Color.hsv2rgb = function(h, s, v) {
var b, f, g, i, l, p, q, r, t, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
if (type(h) === 'array' && h.length === 3) {
_ref2 = h, h = _ref2[0], s = _ref2[1], l = _ref2[2];
}
v *= 255;
if (s === 0 && isNaN(h)) {
r = g = b = v;
} else {
if (h === 360) h = 0;
if (h > 360) h -= 360;
if (h < 0) h += 360;
h /= 60;
i = Math.floor(h);
f = h - i;
p = v * (1 - s);
q = v * (1 - s * f);
t = v * (1 - s * (1 - f));
switch (i) {
case 0:
_ref3 = [v, t, p], r = _ref3[0], g = _ref3[1], b = _ref3[2];
break;
case 1:
_ref4 = [q, v, p], r = _ref4[0], g = _ref4[1], b = _ref4[2];
break;
case 2:
_ref5 = [p, v, t], r = _ref5[0], g = _ref5[1], b = _ref5[2];
break;
case 3:
_ref6 = [p, q, v], r = _ref6[0], g = _ref6[1], b = _ref6[2];
break;
case 4:
_ref7 = [t, p, v], r = _ref7[0], g = _ref7[1], b = _ref7[2];
break;
case 5:
_ref8 = [v, p, q], r = _ref8[0], g = _ref8[1], b = _ref8[2];
}
}
r = Math.round(r);
g = Math.round(g);
b = Math.round(b);
return [r, g, b];
};
Color.rgb2hsv = function(r, g, b) {
var delta, h, max, min, s, v, _ref2;
if (r !== void 0 && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
min = Math.min(r, g, b);
max = Math.max(r, g, b);
delta = max - min;
v = max / 255.0;
s = delta / max;
if (s === 0) {
h = void 0;
s = 0;
} else {
if (r === max) h = (g - b) / delta;
if (g === max) h = 2 + (b - r) / delta;
if (b === max) h = 4 + (r - g) / delta;
h *= 60;
if (h < 0) h += 360;
}
return [h, s, v];
};
Color.hsl2rgb = function(h, s, l) {
var b, c, g, i, r, t1, t2, t3, _ref2, _ref3;
if (h !== void 0 && h.length === 3) {
_ref2 = h, h = _ref2[0], s = _ref2[1], l = _ref2[2];
}
if (s === 0) {
r = g = b = l * 255;
} else {
t3 = [0, 0, 0];
c = [0, 0, 0];
t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
t1 = 2 * l - t2;
h /= 360;
t3[0] = h + 1 / 3;
t3[1] = h;
t3[2] = h - 1 / 3;
for (i = 0; i <= 2; i++) {
if (t3[i] < 0) t3[i] += 1;
if (t3[i] > 1) t3[i] -= 1;
if (6 * t3[i] < 1) {
c[i] = t1 + (t2 - t1) * 6 * t3[i];
} else if (2 * t3[i] < 1) {
c[i] = t2;
} else if (3 * t3[i] < 2) {
c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6;
} else {
c[i] = t1;
}
}
_ref3 = [Math.round(c[0] * 255), Math.round(c[1] * 255), Math.round(c[2] * 255)], r = _ref3[0], g = _ref3[1], b = _ref3[2];
}
return [r, g, b];
};
Color.rgb2hsl = function(r, g, b) {
var h, l, max, min, s, _ref2;
if (r !== void 0 && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
r /= 255;
g /= 255;
b /= 255;
min = Math.min(r, g, b);
max = Math.max(r, g, b);
l = (max + min) / 2;
if (max === min) {
s = 0;
h = void 0;
} else {
s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);
}
if (r === max) {
h = (g - b) / (max - min);
} else if (g === max) {
h = 2 + (b - r) / (max - min);
} else if (b === max) {
h = 4 + (r - g) / (max - min);
}
h *= 60;
if (h < 0) h += 360;
return [h, s, l];
};
Color.lab2xyz = function(l, a, b) {
var finv, ill, sl, x, y, z, _ref2;
if (type(l) === 'array' && l.length === 3) {
_ref2 = l, l = _ref2[0], a = _ref2[1], b = _ref2[2];
}
finv = function(t) {
if (t > (6.0 / 29.0)) {
return t * t * t;
} else {
return 3 * (6.0 / 29.0) * (6.0 / 29.0) * (t - 4.0 / 29.0);
}
};
sl = (l + 0.16) / 1.16;
ill = [0.96421, 1.00000, 0.82519];
y = ill[1] * finv(sl);
x = ill[0] * finv(sl + (a / 5.0));
z = ill[2] * finv(sl - (b / 2.0));
return [x, y, z];
};
Color.xyz2rgb = function(x, y, z) {
var b, bl, clip, correct, g, gl, r, rl, _ref2, _ref3;
if (type(x) === 'array' && x.length === 3) {
_ref2 = x, x = _ref2[0], y = _ref2[1], z = _ref2[2];
}
rl = 3.2406 * x - 1.5372 * y - 0.4986 * z;
gl = -0.9689 * x + 1.8758 * y + 0.0415 * z;
bl = 0.0557 * x - 0.2040 * y + 1.0570 * z;
clip = Math.min(rl, gl, bl) < -0.001 || Math.max(rl, gl, bl) > 1.001;
if (clip) {
rl = rl < 0.0 ? 0.0 : rl > 1.0 ? 1.0 : rl;
gl = gl < 0.0 ? 0.0 : gl > 1.0 ? 1.0 : gl;
bl = bl < 0.0 ? 0.0 : bl > 1.0 ? 1.0 : bl;
}
if (clip) {
_ref3 = [void 0, void 0, void 0], rl = _ref3[0], gl = _ref3[1], bl = _ref3[2];
}
correct = function(cl) {
var a;
a = 0.055;
if (cl <= 0.0031308) {
return 12.92 * cl;
} else {
return (1 + a) * Math.pow(cl, 1 / 2.4) - a;
}
};
r = Math.round(255.0 * correct(rl));
g = Math.round(255.0 * correct(gl));
b = Math.round(255.0 * correct(bl));
return [r, g, b];
};
Color.lab2rgb = function(l, a, b) {
var x, y, z, _ref2, _ref3, _ref4;
if (l !== void 0 && l.length === 3) {
_ref2 = l, l = _ref2[0], a = _ref2[1], b = _ref2[2];
}
if (l !== void 0 && l.length === 3) {
_ref3 = l, l = _ref3[0], a = _ref3[1], b = _ref3[2];
}
_ref4 = Color.lab2xyz(l, a, b), x = _ref4[0], y = _ref4[1], z = _ref4[2];
return Color.xyz2rgb(x, y, z);
};
Color.hcl2lab = function(c, s, l) {
var L, tau_const, a, angle, b, r, _ref2;
if (type(c) === 'array' && c.length === 3) {
_ref2 = c, c = _ref2[0], s = _ref2[1], l = _ref2[2];
}
c /= 360.0;
tau_const = 6.283185307179586476925287;
L = l * 0.61 + 0.09;
angle = tau_const / 6.0 - c * tau_const;
r = (l * 0.311 + 0.125) * s;
a = Math.sin(angle) * r;
b = Math.cos(angle) * r;
return [L, a, b];
};
Color.hcl2rgb = function(c, s, l) {
var L, a, b, _ref2;
_ref2 = Color.hcl2lab(c, s, l), L = _ref2[0], a = _ref2[1], b = _ref2[2];
return Color.lab2rgb(L, a, b);
};
Color.rgb2xyz = function(r, g, b) {
var bl, correct, gl, rl, x, y, z, _ref2;
if (r !== void 0 && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
correct = function(c) {
var a;
a = 0.055;
if (c <= 0.04045) {
return c / 12.92;
} else {
return Math.pow((c + a) / (1 + a), 2.4);
}
};
rl = correct(r / 255.0);
gl = correct(g / 255.0);
bl = correct(b / 255.0);
x = 0.4124 * rl + 0.3576 * gl + 0.1805 * bl;
y = 0.2126 * rl + 0.7152 * gl + 0.0722 * bl;
z = 0.0193 * rl + 0.1192 * gl + 0.9505 * bl;
return [x, y, z];
};
Color.xyz2lab = function(x, y, z) {
var a, b, f, ill, l, _ref2;
if (x !== void 0 && x.length === 3) {
_ref2 = x, x = _ref2[0], y = _ref2[1], z = _ref2[2];
}
ill = [0.96421, 1.00000, 0.82519];
f = function(t) {
if (t > Math.pow(6.0 / 29.0, 3)) {
return Math.pow(t, 1 / 3);
} else {
return (1 / 3) * (29 / 6) * (29 / 6) * t + 4.0 / 29.0;
}
};
l = 1.16 * f(y / ill[1]) - 0.16;
a = 5 * (f(x / ill[0]) - f(y / ill[1]));
b = 2 * (f(y / ill[1]) - f(z / ill[2]));
return [l, a, b];
};
Color.rgb2lab = function(r, g, b) {
var x, y, z, _ref2, _ref3;
if (r !== void 0 && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
_ref3 = Color.rgb2xyz(r, g, b), x = _ref3[0], y = _ref3[1], z = _ref3[2];
return Color.xyz2lab(x, y, z);
};
Color.lab2hcl = function(l, a, b) {
var L, tau_const, angle, c, r, s, _ref2;
if (type(l) === 'array' && l.length === 3) {
_ref2 = l, l = _ref2[0], a = _ref2[1], b = _ref2[2];
}
L = l;
l = (l - 0.09) / 0.61;
r = Math.sqrt(a * a + b * b);
s = r / (l * 0.311 + 0.125);
tau_const = 6.283185307179586476925287;
angle = Math.atan2(a, b);
c = (tau_const / 6 - angle) / tau_const;
c *= 360;
if (c < 0) c += 360;
return [c, s, l];
};
Color.rgb2hcl = function(r, g, b) {
var a, l, _ref2, _ref3;
if (type(r) === 'array' && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
_ref3 = Color.rgb2lab(r, g, b), l = _ref3[0], a = _ref3[1], b = _ref3[2];
return Color.lab2hcl(l, a, b);
};
Color.rgb2hsi = function(r, g, b) {
var pi_const_x2, h, i, min, s, _ref2;
if (type(r) === 'array' && r.length === 3) {
_ref2 = r, r = _ref2[0], g = _ref2[1], b = _ref2[2];
}
pi_const_x2 = Math.PI * 2;
r /= 255;
g /= 255;
b /= 255;
min = Math.min(r, g, b);
i = (r + g + b) / 3;
s = 1 - min / i;
if (s === 0) {
h = 0;
} else {
h = ((r - g) + (r - b)) / 2;
h /= Math.sqrt((r - g) * (r - g) + (r - b) * (g - b));
h = Math.acos(h);
if (b > g) h = pi_const_x2 - h;
h /= pi_const_x2;
}
return [h * 360, s, i];
};
Color.hsi2rgb = function(h, s, i) {
var pi_const_div3, pi_const_x2, b, cos, g, r, _ref2;
if (type(h) === 'array' && h.length === 3) {
_ref2 = h, h = _ref2[0], s = _ref2[1], i = _ref2[2];
}
pi_const_x2 = Math.PI * 2;
pi_const_div3 = Math.PI / 3;
cos = Math.cos;
if (h < 0) h += 360;
if (h > 360) h -= 360;
h /= 360;
if (h < 1 / 3) {
b = (1 - s) / 3;
r = (1 + s * cos(pi_const_x2 * h) / cos(pi_const_div3 - pi_const_x2 * h)) / 3;
g = 1 - (b + r);
} else if (h < 2 / 3) {
h -= 1 / 3;
r = (1 - s) / 3;
g = (1 + s * cos(pi_const_x2 * h) / cos(pi_const_div3 - pi_const_x2 * h)) / 3;
b = 1 - (r + g);
} else {
h -= 2 / 3;
g = (1 - s) / 3;
b = (1 + s * cos(pi_const_x2 * h) / cos(pi_const_div3 - pi_const_x2 * h)) / 3;
r = 1 - (g + b);
}
r = i * r * 3;
g = i * g * 3;
b = i * b * 3;
return [r * 255, g * 255, b * 255];
};
chromato.Color = Color;
chromato.hsl = function(h, s, l) {
return new Color(h, s, l, 'hsl');
};
chromato.hsv = function(h, s, v) {
return new Color(h, s, v, 'hsv');
};
chromato.rgb = function(r, g, b) {
return new Color(r, g, b, 'rgb');
};
chromato.hex = function(x) {
return new Color(x);
};
chromato.lab = function(l, a, b) {
return new Color(l, a, b, 'lab');
};
chromato.hcl = function(c, s, l) {
return new Color(c, s, l, 'hcl');
};
chromato.hsi = function(h, s, i) {
return new Color(h, s, i, 'hsi');
};
chromato.interpolate = function(a, b, f, m) {
if (type(a) === 'string') a = new Color(a);
if (type(b) === 'string') b = new Color(b);
return a.interpolate(f, b, m);
};
ColorScale = (function() {
function ColorScale(opts) {
var c, col, cols, me, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
me = this;
me.colors = cols = (_ref2 = opts.colors) != null ? _ref2 : ['#ddd', '#222'];
for (c = 0, _ref3 = cols.length - 1; 0 <= _ref3 ? c <= _ref3 : c >= _ref3; 0 <= _ref3 ? c++ : c--) {
col = cols[c];
if (type(col) === 'string') cols[c] = new Color(col);
}
if (opts.positions != null) {
me.pos = opts.positions;
} else {
me.pos = [];
for (c = 0, _ref4 = cols.length - 1; 0 <= _ref4 ? c <= _ref4 : c >= _ref4; 0 <= _ref4 ? c++ : c--) {
me.pos.push(c / (cols.length - 1));
}
}
me.mode = (_ref5 = opts.mode) != null ? _ref5 : 'hsv';
me.nacol = (_ref6 = opts.nacol) != null ? _ref6 : '#ccc';
me.setClasses((_ref7 = opts.limits) != null ? _ref7 : [0, 1]);
me;
}
ColorScale.prototype.getColor = function(value) {
var c, f, f0, me;
me = this;
if (isNaN(value)) return me.nacol;
if (me.classLimits.length > 2) {
c = me.getClass(value);
f = c / (me.numClasses - 1);
} else {
f = f0 = (value - me.min) / (me.max - me.min);
f = Math.min(1, Math.max(0, f));
}
return me.fColor(f);
};
ColorScale.prototype.fColor = function(f) {
var col, cols, i, me, p, _ref2;
me = this;
cols = me.colors;
for (i = 0, _ref2 = me.pos.length - 1; 0 <= _ref2 ? i <= _ref2 : i >= _ref2; 0 <= _ref2 ? i++ : i--) {
p = me.pos[i];
if (f <= p) {
col = cols[i];
break;
}
if (f >= p && i === me.pos.length - 1) {
col = cols[i];
break;
}
if (f > p && f < me.pos[i + 1]) {
f = (f - p) / (me.pos[i + 1] - p);
col = chromato.interpolate(cols[i], cols[i + 1], f, me.mode);
break;
}
}
return col;
};
ColorScale.prototype.classifyValue = function(value) {
var i, limits, maxc, minc, n, self;
self = this;
limits = self.classLimits;
if (limits.length > 2) {
n = limits.length - 1;
i = self.getClass(value);
value = limits[i] + (limits[i + 1] - limits[i]) * 0.5;
minc = limits[0];
maxc = limits[n - 1];
value = self.min + ((value - minc) / (maxc - minc)) * (self.max - self.min);
}
return value;
};
ColorScale.prototype.setClasses = function(limits) {
var me;
if (limits == null) limits = [];
me = this;
me.classLimits = limits;
me.min = limits[0];
me.max = limits[limits.length - 1];
if (limits.length === 2) {
return me.numClasses = 0;
} else {
return me.numClasses = limits.length - 1;
}
};
ColorScale.prototype.getClass = function(value) {
var i, limits, n, self;
self = this;
limits = self.classLimits;
if (limits != null) {
n = limits.length - 1;
i = 0;
while (i < n && value >= limits[i]) {
i++;
}
return i - 1;
}
};
ColorScale.prototype.validValue = function(value) {
return !isNaN(value);
};
return ColorScale;
})();
chromato.ColorScale = ColorScale;
Ramp = (function() {
__extends(Ramp, ColorScale);
function Ramp(col0, col1, mode) {
if (col0 == null) col0 = '#fe0000';
if (col1 == null) col1 = '#feeeee';
if (mode == null) mode = 'hsl';
Ramp.__super__.constructor.call(this, [col0, col1], [0, 1], mode);
}
return Ramp;
})();
chromato.Ramp = Ramp;
Categories = (function() {
__extends(Categories, ColorScale);
function Categories(colors) {
var me;
me = this;
me.colors = colors;
}
Categories.prototype.parseData = function(data, data_col) {};
Categories.prototype.getColor = function(value) {
var me;
me = this;
if (me.colors.hasOwnProperty(value)) {
return me.colors[value];
} else {
return '#cccccc';
}
};
Categories.prototype.validValue = function(value) {
return this.colors.hasOwnProperty(value);
};
return Categories;
})();
chromato.Categories = Categories;
CSSColors = (function() {
__extends(CSSColors, ColorScale);
function CSSColors(name) {
var me;
me = this;
me.name = name;
me.setClasses(7);
me;
}
CSSColors.prototype.getColor = function(value) {
var c, me;
me = this;
c = me.getClass(value);
return me.name + ' l' + me.numClasses + ' c' + c;
};
return CSSColors;
})();
chromato.CSSColors = CSSColors;
if ((_ref2 = chromato.scales) == null) chromato.scales = {};
chromato.limits = function(data, mode, num, prop) {
var assignments, best, centroids, cluster, clusterSizes, dist, i, j, k, kClusters, limits, max, min, mindist, n, nb_iters, newCentroids, p, pb, pr, repeat, row, sum, tmpKMeansBreaks, val, value, values, _i, _j, _k, _len, _len2, _len3, _ref10, _ref11, _ref12, _ref13, _ref14, _ref15, _ref16, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9;
if (mode == null) mode = 'equal';
if (num == null) num = 7;
if (prop == null) prop = null;
min = Number.MAX_VALUE;
max = Number.MAX_VALUE * -1;
sum = 0;
values = [];
if (type(data) === 'array') {
if (type(data[0]) !== 'object' && type(data[0]) !== 'array') {
for (_i = 0, _len = data.length; _i < _len; _i++) {
val = data[_i];
if (!isNaN(val)) values.push(Number(val));
}
} else {
for (_j = 0, _len2 = data.length; _j < _len2; _j++) {
row = data[_j];
values.push(Number(row[prop]));
}
}
} else if (type(data) === 'object') {
for (k in data) {
val = data[k];
if (type(val) === 'object' && type(prop) === 'string') {
if (!isNaN(val[prop])) values.push(Number(val[prop]));
} else if (type(val) === 'array' && type(prop) === 'number') {
if (!isNaN(val[prop])) values.push(Number(val[prop]));
} else if (type(val) === 'number') {
if (!isNaN(val)) values.push(Number(val));
}
}
}
for (_k = 0, _len3 = values.length; _k < _len3; _k++) {
val = values[_k];
if (!!isNaN(val)) continue;
if (val < min) min = val;
if (val > max) max = val;
sum += val;
}
values = values.sort(function(a, b) {
return a - b;
});
limits = [];
if (mode.substr(0, 1) === 'c') {
limits.push(min);
limits.push(max);
}
if (mode.substr(0, 1) === 'e') {
limits.push(min);
for (i = 1, _ref3 = num - 1; 1 <= _ref3 ? i <= _ref3 : i >= _ref3; 1 <= _ref3 ? i++ : i--) {
limits.push(min + (i / num) * (max - min));
}
limits.push(max);
} else if (mode.substr(0, 1) === 'q') {
limits.push(min);
for (i = 1, _ref4 = num - 1; 1 <= _ref4 ? i <= _ref4 : i >= _ref4; 1 <= _ref4 ? i++ : i--) {
p = values.length * i / num;
pb = Math.floor(p);
if (pb === p) {
limits.push(values[pb]);
} else {
pr = p - pb;
limits.push(values[pb] * pr + values[pb + 1] * (1 - pr));
}
}
limits.push(max);
} else if (mode.substr(0, 1) === 'k') {
n = values.length;
assignments = new Array(n);
clusterSizes = new Array(num);
repeat = true;
nb_iters = 0;
centroids = null;
centroids = [];
centroids.push(min);
for (i = 1, _ref5 = num - 1; 1 <= _ref5 ? i <= _ref5 : i >= _ref5; 1 <= _ref5 ? i++ : i--) {
centroids.push(min + (i / num) * (max - min));
}
centroids.push(max);
while (repeat) {
for (j = 0, _ref6 = num - 1; 0 <= _ref6 ? j <= _ref6 : j >= _ref6; 0 <= _ref6 ? j++ : j--) {
clusterSizes[j] = 0;
}
for (i = 0, _ref7 = n - 1; 0 <= _ref7 ? i <= _ref7 : i >= _ref7; 0 <= _ref7 ? i++ : i--) {
value = values[i];
mindist = Number.MAX_VALUE;
for (j = 0, _ref8 = num - 1; 0 <= _ref8 ? j <= _ref8 : j >= _ref8; 0 <= _ref8 ? j++ : j--) {
dist = Math.abs(centroids[j] - value);
if (dist < mindist) {
mindist = dist;
best = j;
}
}
clusterSizes[best]++;
assignments[i] = best;
}
newCentroids = new Array(num);
for (j = 0, _ref9 = num - 1; 0 <= _ref9 ? j <= _ref9 : j >= _ref9; 0 <= _ref9 ? j++ : j--) {
newCentroids[j] = null;
}
for (i = 0, _ref10 = n - 1; 0 <= _ref10 ? i <= _ref10 : i >= _ref10; 0 <= _ref10 ? i++ : i--) {
cluster = assignments[i];
if (newCentroids[cluster] === null) {
newCentroids[cluster] = values[i];
} else {
newCentroids[cluster] += values[i];
}
}
for (j = 0, _ref11 = num - 1; 0 <= _ref11 ? j <= _ref11 : j >= _ref11; 0 <= _ref11 ? j++ : j--) {
newCentroids[j] *= 1 / clusterSizes[j];
}
repeat = false;
for (j = 0, _ref12 = num - 1; 0 <= _ref12 ? j <= _ref12 : j >= _ref12; 0 <= _ref12 ? j++ : j--) {
if (newCentroids[j] !== centroids[i]) {
repeat = true;
break;
}
}
centroids = newCentroids;
nb_iters++;
if (nb_iters > 200) repeat = false;
}
kClusters = {};
for (j = 0, _ref13 = num - 1; 0 <= _ref13 ? j <= _ref13 : j >= _ref13; 0 <= _ref13 ? j++ : j--) {
kClusters[j] = [];
}
for (i = 0, _ref14 = n - 1; 0 <= _ref14 ? i <= _ref14 : i >= _ref14; 0 <= _ref14 ? i++ : i--) {
cluster = assignments[i];
kClusters[cluster].push(values[i]);
}
tmpKMeansBreaks = [];
for (j = 0, _ref15 = num - 1; 0 <= _ref15 ? j <= _ref15 : j >= _ref15; 0 <= _ref15 ? j++ : j--) {
tmpKMeansBreaks.push(kClusters[j][0]);
tmpKMeansBreaks.push(kClusters[j][kClusters[j].length - 1]);
}
tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) {
return a - b;
});
limits.push(tmpKMeansBreaks[0]);
for (i = 1, _ref16 = tmpKMeansBreaks.length - 1; i <= _ref16; i += 2) {
if (!isNaN(tmpKMeansBreaks[i])) limits.push(tmpKMeansBreaks[i]);
}
}
return limits;
};
root = typeof exports !== 'undefined' && exports !== null ? exports : this;
type = (function() {
var classToType, name, _i, _len, _ref3;
classToType = {};
_ref3 = 'Boolean Number String Function Array Date RegExp Undefined Null'.split(' ');
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
name = _ref3[_i];
classToType['[object ' + name + ']'] = name.toLowerCase();
}
return function(obj) {
var strType;
strType = Object.prototype.toString.call(obj);
return classToType[strType] || 'object';
};
})();
if ((_ref3 = root.type) == null) root.type = type;
Array.max = function(array) {
return Math.max.apply(Math, array);
};
Array.min = function(array) {
return Math.min.apply(Math, array);
};
}).call(this);
var createPalette = {
generate: function(colorsCount, checkColor, forceMode, quality, ultra_precision){
if(colorsCount === undefined)
colorsCount = 8;
if(checkColor === undefined)
checkColor = function(x){return true;};
if(forceMode === undefined)
forceMode = false;
if(quality === undefined)
quality = 50;
ultra_precision = ultra_precision || false
if(forceMode){
var colors = [];
function checkLab(lab){
var color = chromato.lab(lab[0], lab[1], lab[2]);
return !isNaN(color.rgb[0]) && color.rgb[0] >= 0 && color.rgb[1] >= 0 && color.rgb[2] >= 0 && color.rgb[0] < 256 && color.rgb[1] < 256 && color.rgb[2] < 256 && checkColor(color);
}
var vectors = {};
for(i = 0; i < colorsCount; i++){
var color = [Math.random(), 2 * Math.random() - 1, 2 * Math.random() - 1];
while(!checkLab(color)){
color = [Math.random(), 2 * Math.random() - 1, 2 * Math.random() - 1];
}
colors.push(color);
}
var repulsion = 0.3;
var speed = 0.05;
var steps = quality * 20;
while(steps-- > 0){
for(i = 0; i < colors.length; i++){
vectors[i] = {dl:0, da:0, db:0};
}
for(i = 0; i < colors.length; i++){
var color_a = colors[i];
for(j = 0; j < i; j++){
var color_b = colors[j];
var dl = color_a[0] - color_b[0];
var da = color_a[1] - color_b[1];
var db = color_a[2] - color_b[2];
var d = Math.sqrt(Math.pow(dl, 2) + Math.pow(da, 2) + Math.pow(db, 2));
if(d > 0){
var force = repulsion / Math.pow(d, 2);
vectors[i].dl += dl * force / d;
vectors[i].da += da * force / d;
vectors[i].db += db * force / d;
vectors[j].dl -= dl * force / d;
vectors[j].da -= da * force / d;
vectors[j].db -= db * force / d;
} else {
vectors[j].dl += 0.02 - 0.04 * Math.random();
vectors[j].da += 0.02 - 0.04 * Math.random();
vectors[j].db += 0.02 - 0.04 * Math.random();
}
}
}
for(i = 0; i < colors.length; i++){
var color = colors[i];
var displacement = speed * Math.sqrt(Math.pow(vectors[i].dl, 2) + Math.pow(vectors[i].da, 2) + Math.pow(vectors[i].db, 2));
if(displacement>0){
var ratio = speed * Math.min(0.1, displacement)/displacement;
candidateLab = [color[0] + vectors[i].dl * ratio, color[1] + vectors[i].da * ratio, color[2] + vectors[i].db * ratio];
if(checkLab(candidateLab)){
colors[i] = candidateLab;
}
}
}
}
return colors.map(function(lab){return chromato.lab(lab[0], lab[1], lab[2]);});
} else {
function checkColor2(color){
var lab = color.lab();
var hcl = color.hcl();
return !isNaN(color.rgb[0]) && color.rgb[0] >= 0 && color.rgb[1] >= 0 && color.rgb[2] >= 0 && color.rgb[0]<256 && color.rgb[1]<256 && color.rgb[2]<256 && checkColor(color);
}
var kMeans = [];
for(i = 0; i < colorsCount; i++){
var lab = [Math.random(), 2 * Math.random() - 1, 2 * Math.random() - 1];
while(!checkColor2(chromato.lab(lab))){
lab = [Math.random(), 2 * Math.random() - 1, 2 * Math.random() - 1];
}
kMeans.push(lab);
}
var colorSamples = [];
var samplesClosest = [];
if(ultra_precision){
for(l = 0; l <= 1; l += 0.01){
for(a =- 1; a <= 1; a += 0.05){
for(b =- 1; b <= 1; b += 0.05){
if(checkColor2(chromato.lab(l, a, b))){
colorSamples.push([l, a, b]);
samplesClosest.push(null);
}
}
}
}
} else {
for(l = 0; l <= 1; l += 0.05){
for(a =- 1; a <= 1; a += 0.1){
for(b =- 1; b <= 1; b += 0.1){
if(checkColor2(chromato.lab(l, a, b))){
colorSamples.push([l, a, b]);
samplesClosest.push(null);
}
}
}
}
}
var steps = quality;
while(steps-- > 0){
for(i = 0; i < colorSamples.length; i++){
var lab = colorSamples[i];
var min_dist = 1000000;
for(j = 0; j < kMeans.length; j++){
var kMean = kMeans[j];
var distance = Math.sqrt(Math.pow(lab[0] - kMean[0], 2) + Math.pow(lab[1]-kMean[1], 2) + Math.pow(lab[2] - kMean[2], 2));
if(distance < min_dist){
min_dist = distance;
samplesClosest[i] = j;
}
}
}
var freeColorSamples = colorSamples.slice(0);
for(j = 0; j < kMeans.length; j++){
var count = 0;
var candidateKMean = [0, 0, 0];
for(i = 0; i < colorSamples.length; i++){
if(samplesClosest[i] == j){
count++;
candidateKMean[0] += colorSamples[i][0];
candidateKMean[1] += colorSamples[i][1];
candidateKMean[2] += colorSamples[i][2];
}
}
if(count != 0){
candidateKMean[0] /= count;
candidateKMean[1] /= count;
candidateKMean[2] /= count;
}
if(count != 0 && checkColor2(chromato.lab(candidateKMean[0], candidateKMean[1], candidateKMean[2])) && candidateKMean){
kMeans[j] = candidateKMean;
} else {
if(freeColorSamples.length>0){
var min_dist = 10000000000;
var closest = -1;
for(i = 0; i<freeColorSamples.length; i++){
var distance = Math.sqrt(Math.pow(freeColorSamples[i][0] - candidateKMean[0], 2) + Math.pow(freeColorSamples[i][1] - candidateKMean[1], 2) + Math.pow(freeColorSamples[i][2] - candidateKMean[2], 2));
if(distance < min_dist){
min_dist = distance;
closest = i;
}
}
kMeans[j] = colorSamples[closest];
} else {
var min_dist = 10000000000;
var closest = -1;
for(i = 0; i < colorSamples.length; i++){
var distance = Math.sqrt(Math.pow(colorSamples[i][0] - candidateKMean[0], 2) + Math.pow(colorSamples[i][1]-candidateKMean[1], 2) + Math.pow(colorSamples[i][2] - candidateKMean[2], 2));
if(distance < min_dist){
min_dist = distance;
closest = i;
}
}
kMeans[j] = colorSamples[closest];
}
}
freeColorSamples = freeColorSamples.filter(function(color){
return color[0] != kMeans[j][0]
|| color[1] != kMeans[j][1]
|| color[2] != kMeans[j][2];
});
}
}
return kMeans.map(function(lab){return chromato.lab(lab[0], lab[1], lab[2]);});
}
},
diffSort: function(colorsToSort){
var diffColors = [colorsToSort.shift()];
while(colorsToSort.length > 0){
var index = -1;
var maxDistance = -1;
for(candidate_index = 0; candidate_index < colorsToSort.length; candidate_index++){
var d = 1000000000;
for(i = 0; i < diffColors.length; i++){
var color_a = colorsToSort[candidate_index].lab();
var color_b = diffColors[i].lab();
var dl = color_a[0] - color_b[0];
var da = color_a[1] - color_b[1];
var db = color_a[2] - color_b[2];
d = Math.min(d, Math.sqrt(Math.pow(dl, 2)+Math.pow(da, 2)+Math.pow(db, 2)));
}
if(d > maxDistance){
maxDistance = d;
index = candidate_index;
}
}
var color = colorsToSort[index];
diffColors.push(color);
colorsToSort = colorsToSort.filter(function(c,i){return i != index;});
}
return diffColors;
}
}
</script>
<script>HTMLWidgets.widget({
name: 'DiagrammeR',
type: 'output',
initialize: function(el, width, height) {
/* wait to initialize until renderValue
since x not provided until then
and mermaid will try to build the diagram
as soon as class of the div is set to "mermaid"
*/
/* to prevent auto init() by mermaid
not documented but
see lines https://github.com/knsv/mermaid/blob/master/src/main.js#L100-L109
mermaid_config in global with mermaid_config.startOnLoad = false
appears to turn off the auto init behavior
allowing us to callback after manually init and then callback
after complete
*/
window.mermaid.startOnLoad = false;
// set config options for Gantt
// undocumented but these can be provided
// so from R
// m1 <- mermaid(spec)
// m1$x$config = list(ganttConfig = list( barHeight = 100 ) )
mermaid.ganttConfig = {
titleTopMargin:25,
barHeight:20,
barGap:4,
topPadding:50,
sidePadding:100,
gridLineStartPadding:35,
fontSize:11,
numberSectionStyles:4,
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();
}]
]
};
return {
// TODO: add instance fields as required
}
},
renderValue: function(el, x, instance) {
// if no diagram provided then assume
// that the diagrams are provided through htmltools tags
// and DiagrammeR was just used for dependencies
if ( x.diagram != "" ) {
el.innerHTML = x.diagram;
//if dynamic such as shiny remove data-processed
// so mermaid will reprocess and redraw
el.removeAttribute("data-processed");
el.classList.add('mermaid');
//make sure if shiny that we turn display back on
el.style.display = "";
//again if dynamic such as shiny
// explicitly run mermaid.init()
} else {
// set display to none
// should we remove instead??
el.style.display = "none";
}
// check for undocumented ganttConfig
// to override the defaults manually entered
// in initialize above
// note this is really sloppy and will not
// work well if multiple gantt charts
// with custom configs here
if( typeof x.config !== "undefined" &&
typeof x.config.ganttConfig !== "undefined" ){
Object.keys(x.config.ganttConfig).map(function(k){
window.mermaid.ganttConfig[k] = x.config.ganttConfig[k];
})
}
// use this to sort of make our diagram responsive
// or at a minimum fit within the bounds set by htmlwidgets
// for the parent container
function makeResponsive(el){
var svg = el.getElementsByTagName("svg")[0];
if(svg){
if(svg.width) {svg.removeAttribute("width")};
if(svg.height) {svg.removeAttribute("height")};
svg.style.width = "100%";
svg.style.height = "100%";
}
};
// get all DiagrammeR mermaids widgets
dg = document.getElementsByClassName("DiagrammeR");
// run mermaid.init
// but use try catch block
// to send error to the htmlwidget for display
try{
mermaid.init( el );
// sort of make our diagram responsive
// should we make this an option?
// if so, then could easily add to list of post process tasks
makeResponsive( el );
if (HTMLWidgets.shinyMode) {
// Get widget id
var id = el.id;
$("#" + id + " .node").click(function(e) {
// Build return object *obj* with node-id and node textContent
var obj = {
id: e.currentTarget.id,
nodeValues: e.currentTarget.textContent
};
// Send *obj* to Shiny's inputs (input$[id]+_click e.g.: input$vtree_click))
Shiny.setInputValue(id + "_click", obj, {priority: "event"});
});
}
/*
// change the id of our SVG assigned by mermaid to prevent conflict
// mermaid.init has a counter that will reset to 0
// and cause duplication of SVG id if multiple
d3.select(el).select("svg")
.attr("id", "mermaidChart-" + el.id);
// now we have to change the styling assigned by mermaid
// to point to our new id that we have assigned
// will add if since sequence diagrams do not have stylesheet
if(d3.select(el).select("svg").select("style")[0][0]){
d3.select(el).select("svg").select("style")[0][0].innerHTML = d3.select(el).select("svg")
.select("style")[0][0].innerHTML
*/
/// sep comment for / in regex .replace(/mermaidChart[0-9]*/gi, "mermaidChart-" + el.id);
/*}
*/
// set up a container for tasks to perform after completion
// one example would be add callbacks for event handling
// styling
if (!(typeof x.tasks === "undefined") ){
if ( (typeof x.tasks.length === "undefined") ||
(typeof x.tasks === "function" ) ) {
// handle a function not enclosed in array
// should be able to remove once using jsonlite
x.tasks = [x.tasks];
}
x.tasks.map(function(t){
// for each tasks add it to the mermaid.tasks with el
t.call(el);
})
}
} catch(e) {
// if error look for last processed DiagrammeR
// and send error to the container div
// with pre containing the errors
var processedDg = d3.selectAll(".DiagrammeR[data-processed=true]");
// select the last
processedDg = d3.select(processedDg[0][processedDg[0].length - 1])
// remove the svg
processedDg.select("svg").remove();
//if dynamic such as shiny remove data-processed
// so mermaid will reprocess and redraw
if (HTMLWidgets.shinyMode) {
el.removeAttribute("data-processed")
}
processedDg.append("pre").html( ["parse error with " + x.diagram, e.message].join("\n") )
}
},
resize: function(el, width, height, instance) {
}
});
</script>
<style type="text/css">
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
</style>
<style type="text/css">
code {
white-space: pre;
}
.sourceCode {
overflow: visible;
}
</style>
<style type="text/css" data-origin="pandoc">
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { display: inline-block; text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; }
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.at { color: #7d9029; }
code span.bn { color: #40a070; }
code span.bu { color: #008000; }
code span.cf { color: #007020; font-weight: bold; }
code span.ch { color: #4070a0; }
code span.cn { color: #880000; }
code span.co { color: #60a0b0; font-style: italic; }
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.do { color: #ba2121; font-style: italic; }
code span.dt { color: #902000; }
code span.dv { color: #40a070; }
code span.er { color: #ff0000; font-weight: bold; }
code span.ex { }
code span.fl { color: #40a070; }
code span.fu { color: #06287e; }
code span.im { color: #008000; font-weight: bold; }
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; }
code span.kw { color: #007020; font-weight: bold; }
code span.op { color: #666666; }
code span.ot { color: #007020; }
code span.pp { color: #bc7a00; }
code span.sc { color: #4070a0; }
code span.ss { color: #bb6688; }
code span.st { color: #4070a0; }
code span.va { color: #19177c; }
code span.vs { color: #4070a0; }
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; }
</style>
<script>
// apply pandoc div.sourceCode style to pre.sourceCode instead
(function() {
var sheets = document.styleSheets;
for (var i = 0; i < sheets.length; i++) {
if (sheets[i].ownerNode.dataset["origin"] !== "pandoc") continue;
try { var rules = sheets[i].cssRules; } catch (e) { continue; }
var j = 0;
while (j < rules.length) {
var rule = rules[j];
// check if there is a div.sourceCode rule
if (rule.type !== rule.STYLE_RULE || rule.selectorText !== "div.sourceCode") {
j++;
continue;
}
var style = rule.style.cssText;
// check if color or background-color is set
if (rule.style.color === '' && rule.style.backgroundColor === '') {
j++;
continue;
}
// replace div.sourceCode by a pre.sourceCode rule
sheets[i].deleteRule(j);
sheets[i].insertRule('pre.sourceCode{' + style + '}', j);
}
}
})();
</script>
<style type="text/css">body {
background-color: #fff;
margin: 1em auto;
max-width: 700px;
overflow: visible;
padding-left: 2em;
padding-right: 2em;
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
font-size: 14px;
line-height: 1.35;
}
#TOC {
clear: both;
margin: 0 0 10px 10px;
padding: 4px;
width: 400px;
border: 1px solid #CCCCCC;
border-radius: 5px;
background-color: #f6f6f6;
font-size: 13px;
line-height: 1.3;
}
#TOC .toctitle {
font-weight: bold;
font-size: 15px;
margin-left: 5px;
}
#TOC ul {
padding-left: 40px;
margin-left: -1.5em;
margin-top: 5px;
margin-bottom: 5px;
}
#TOC ul ul {
margin-left: -2em;
}
#TOC li {
line-height: 16px;
}
table {
margin: 1em auto;
border-width: 1px;
border-color: #DDDDDD;
border-style: outset;
border-collapse: collapse;
}
table th {
border-width: 2px;
padding: 5px;
border-style: inset;
}
table td {
border-width: 1px;
border-style: inset;
line-height: 18px;
padding: 5px 5px;
}
table, table th, table td {
border-left-style: none;
border-right-style: none;
}
table thead, table tr.even {
background-color: #f7f7f7;
}
p {
margin: 0.5em 0;
}
blockquote {
background-color: #f6f6f6;
padding: 0.25em 0.75em;
}
hr {
border-style: solid;
border: none;
border-top: 1px solid #777;
margin: 28px 0;
}
dl {
margin-left: 0;
}
dl dd {
margin-bottom: 13px;
margin-left: 13px;
}
dl dt {
font-weight: bold;
}
ul {
margin-top: 0;
}
ul li {
list-style: circle outside;
}
ul ul {
margin-bottom: 0;
}
pre, code {
background-color: #f7f7f7;
border-radius: 3px;
color: #333;
white-space: pre-wrap;
}
pre {
border-radius: 3px;
margin: 5px 0px 10px 0px;
padding: 10px;
}
pre:not([class]) {
background-color: #f7f7f7;
}
code {
font-family: Consolas, Monaco, 'Courier New', monospace;
font-size: 85%;
}
p > code, li > code {
padding: 2px 0px;
}
div.figure {
text-align: center;
}
img {
background-color: #FFFFFF;
padding: 2px;
border: 1px solid #DDDDDD;
border-radius: 3px;
border: 1px solid #CCCCCC;
margin: 0 5px;
}
h1 {
margin-top: 0;
font-size: 35px;
line-height: 40px;
}
h2 {
border-bottom: 4px solid #f7f7f7;
padding-top: 10px;
padding-bottom: 2px;
font-size: 145%;
}
h3 {
border-bottom: 2px solid #f7f7f7;
padding-top: 10px;
font-size: 120%;
}
h4 {
border-bottom: 1px solid #f7f7f7;
margin-left: 8px;
font-size: 105%;
}
h5, h6 {
border-bottom: 1px solid #ccc;
font-size: 105%;
}
a {
color: #0033dd;
text-decoration: none;
}
a:hover {
color: #6666ff; }
a:visited {
color: #800080; }
a:visited:hover {
color: #BB00BB; }
a[href^="http:"] {
text-decoration: underline; }
a[href^="https:"] {
text-decoration: underline; }
code > span.kw { color: #555; font-weight: bold; }
code > span.dt { color: #902000; }
code > span.dv { color: #40a070; }
code > span.bn { color: #d14; }
code > span.fl { color: #d14; }
code > span.ch { color: #d14; }
code > span.st { color: #d14; }
code > span.co { color: #888888; font-style: italic; }
code > span.ot { color: #007020; }
code > span.al { color: #ff0000; font-weight: bold; }
code > span.fu { color: #900; font-weight: bold; }
code > span.er { color: #a61717; background-color: #e3d2d2; }
</style>
</head>
<body>
<h1 class="title toc-ignore">Printing a tibble: Control and data
flow</h1>
<div class="sourceCode" id="cb1"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" tabindex="-1"></a><span class="fu">library</span>(pillar)</span></code></pre></div>
<p>What happens when a tibble is printed? This vignette documents the
control flow and the data flow, explains the design choices, and shows
the default implementation for the <code>&quot;tbl&quot;</code> class. It is
mainly of interest for implementers of table subclasses. Customizing the
formatting of a vector class in a tibble is described in
<code>vignette(&quot;pillar&quot;, package = &quot;vctrs&quot;)</code>. The different
customization options are showcased in
<code>vignette(&quot;extending&quot;)</code>.</p>
<div id="requirements" class="section level2">
<h2>Requirements</h2>
<ul>
<li><p>Fit into pre-specified width, distributing across multiple tiers
if necessary</p></li>
<li><p>Optionally shrink and stretch individual columns</p></li>
<li><p>Header, body and footer for the tibble</p>
<ul>
<li>Avoid recomputation of information</li>
</ul></li>
<li><p>Custom components for the pillars in a tibble, top-aligned</p>
<ul>
<li>The container, not the column vectors, determine the appearance</li>
</ul></li>
<li><p>Customization of the entire output and of the pillars</p></li>
<li><p>Support for data frame columns (packed data frames) and
matrix/array columns</p></li>
<li><p>Pillars are always shown from left to right, no “holes” in the
colonnade</p>
<ul>
<li>If the first column consumes all available space, the remaining
columns are not shown, even if they all would fit if the first column is
omitted.</li>
</ul></li>
<li><p>Printing pillars should take time proportional to the number of
characters printed, and be “fast enough”.</p></li>
</ul>
</div>
<div id="overview" class="section level2">
<h2>Overview</h2>
<p>The overall control and data flow are illustrated in the diagram
below. Boxes are functions and methods. Solid lines are function calls.
Dotted lines represent information that a function obtains via argument
or (in the case of options) queries actively.</p>
<div class="DiagrammeR html-widget html-fill-item" id="htmlwidget-7f92e75415d0eb9ec18a" style="width:288px;height:288px;"></div>
<script type="application/json" data-for="htmlwidget-7f92e75415d0eb9ec18a">{"x":{"diagram":"graph TD\n print.tbl[\"print.tbl()\"] --> format.tbl[\"format.tbl()\"]\n format.tbl --> tbl_format_setup[\"tbl_format_setup()\"]\n options(Options: n and n_extra) -.-> tbl_format_setup\n format.tbl --> tbl_format_header[\"tbl_format_header()\"]\n format.tbl --> tbl_format_body[\"tbl_format_body()\"]\n format.tbl --> tbl_format_footer[\"tbl_format_footer()\"]\n tbl_format_setup -.-> tbl_sum[\"tbl_sum()\"]\n tbl_sum -.-> setup(Setup object)\n tbl_format_setup -.-> ctl_new_compound_pillar[\"ctl_new_compound_pillar()\"]\n ctl_new_compound_pillar -.-> ctl_new_pillar[\"ctl_new_pillar()\"]\n ctl_new_pillar -.-> setup(Setup object)\n setup -.-> tbl_format_header\n setup -.-> tbl_format_body\n setup -.-> tbl_format_footer\n tbl_format_header -.-> print(Printed output)\n tbl_format_body -.-> print\n tbl_format_footer -.-> print"},"evals":[],"jsHooks":[]}</script>
<p>The pillar package uses debugme for debugging. Activating debugging
for pillar is another way to track the control flow, see
<code>vignette(&quot;debugme&quot;)</code> for details.</p>
</div>
<div id="initialization" class="section level2">
<h2>Initialization</h2>
<p>A tibble is a list of columns of class <code>&quot;tbl_df&quot;</code> and
<code>&quot;tbl&quot;</code>. Printing is designed to work for non-data-frame
table-like objects such as lazy tables. The <code>print.tbl()</code>
method calls <code>format()</code> for the object and prints the
output.</p>
<div class="sourceCode" id="cb2"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" tabindex="-1"></a>tbl <span class="ot">&lt;-</span> tibble<span class="sc">::</span><span class="fu">tibble</span>(<span class="at">a =</span> <span class="dv">1</span><span class="sc">:</span><span class="dv">3</span>, <span class="at">b =</span> tibble<span class="sc">::</span><span class="fu">tibble</span>(<span class="at">c =</span> <span class="dv">4</span><span class="sc">:</span><span class="dv">6</span>, <span class="at">d =</span> <span class="dv">7</span><span class="sc">:</span><span class="dv">9</span>), <span class="at">e =</span> <span class="dv">10</span><span class="sc">:</span><span class="dv">12</span>)</span>
<span id="cb2-2"><a href="#cb2-2" tabindex="-1"></a><span class="fu">print</span>(tbl, <span class="at">width =</span> <span class="dv">23</span>)</span>
<span id="cb2-3"><a href="#cb2-3" tabindex="-1"></a><span class="co">#&gt; # A tibble: 3 × 3</span></span>
<span id="cb2-4"><a href="#cb2-4" tabindex="-1"></a><span class="co">#&gt; a b$c e</span></span>
<span id="cb2-5"><a href="#cb2-5" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;</span></span>
<span id="cb2-6"><a href="#cb2-6" tabindex="-1"></a><span class="co">#&gt; 1 1 4 10</span></span>
<span id="cb2-7"><a href="#cb2-7" tabindex="-1"></a><span class="co">#&gt; 2 2 5 11</span></span>
<span id="cb2-8"><a href="#cb2-8" tabindex="-1"></a><span class="co">#&gt; 3 3 6 12</span></span>
<span id="cb2-9"><a href="#cb2-9" tabindex="-1"></a><span class="co">#&gt; # 1 more variable:</span></span>
<span id="cb2-10"><a href="#cb2-10" tabindex="-1"></a><span class="co">#&gt; # b$d &lt;int&gt;</span></span>
<span id="cb2-11"><a href="#cb2-11" tabindex="-1"></a><span class="fu">str</span>(tbl)</span>
<span id="cb2-12"><a href="#cb2-12" tabindex="-1"></a><span class="co">#&gt; tibble [3 × 3] (S3: tbl_df/tbl/data.frame)</span></span>
<span id="cb2-13"><a href="#cb2-13" tabindex="-1"></a><span class="co">#&gt; $ a: int [1:3] 1 2 3</span></span>
<span id="cb2-14"><a href="#cb2-14" tabindex="-1"></a><span class="co">#&gt; $ b: tibble [3 × 2] (S3: tbl_df/tbl/data.frame)</span></span>
<span id="cb2-15"><a href="#cb2-15" tabindex="-1"></a><span class="co">#&gt; ..$ c: int [1:3] 4 5 6</span></span>
<span id="cb2-16"><a href="#cb2-16" tabindex="-1"></a><span class="co">#&gt; ..$ d: int [1:3] 7 8 9</span></span>
<span id="cb2-17"><a href="#cb2-17" tabindex="-1"></a><span class="co">#&gt; $ e: int [1:3] 10 11 12</span></span></code></pre></div>
<details>
<summary>
Source code of <code>pillar:::print.tbl()</code>
</summary>
<div class="sourceCode" id="cb3"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" tabindex="-1"></a>print.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (x, <span class="at">width =</span> <span class="cn">NULL</span>, ..., <span class="at">n =</span> <span class="cn">NULL</span>, <span class="at">max_extra_cols =</span> <span class="cn">NULL</span>, </span>
<span id="cb3-2"><a href="#cb3-2" tabindex="-1"></a> <span class="at">max_footer_lines =</span> <span class="cn">NULL</span>) </span>
<span id="cb3-3"><a href="#cb3-3" tabindex="-1"></a>{</span>
<span id="cb3-4"><a href="#cb3-4" tabindex="-1"></a> <span class="fu">print_tbl</span>(x, width, ..., <span class="at">n =</span> n, <span class="at">max_extra_cols =</span> max_extra_cols, </span>
<span id="cb3-5"><a href="#cb3-5" tabindex="-1"></a> <span class="at">max_footer_lines =</span> max_footer_lines)</span>
<span id="cb3-6"><a href="#cb3-6" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>The <code>format.tbl()</code> method creates a setup object, and uses
that object to format header, body and footer.</p>
<details>
<summary>
Source code of <code>pillar:::format.tbl()</code>
</summary>
<div class="sourceCode" id="cb4"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" tabindex="-1"></a>format.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (x, <span class="at">width =</span> <span class="cn">NULL</span>, ..., <span class="at">n =</span> <span class="cn">NULL</span>, <span class="at">max_extra_cols =</span> <span class="cn">NULL</span>, </span>
<span id="cb4-2"><a href="#cb4-2" tabindex="-1"></a> <span class="at">max_footer_lines =</span> <span class="cn">NULL</span>) </span>
<span id="cb4-3"><a href="#cb4-3" tabindex="-1"></a>{</span>
<span id="cb4-4"><a href="#cb4-4" tabindex="-1"></a> <span class="fu">format_tbl</span>(x, width, ..., <span class="at">n =</span> n, <span class="at">max_extra_cols =</span> max_extra_cols, </span>
<span id="cb4-5"><a href="#cb4-5" tabindex="-1"></a> <span class="at">max_footer_lines =</span> max_footer_lines)</span>
<span id="cb4-6"><a href="#cb4-6" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>While its possible to extend or override these methods for your
<code>&quot;tbl&quot;</code> subclass, often overriding the more specialized
methods shown below is sufficient.</p>
</div>
<div id="setup" class="section level2">
<h2>Setup</h2>
<p>Most of the work for formatting actually happens in
<code>tbl_format_setup()</code>. The desired output width is baked into
the setup object and must be available when calling. Setup objects print
like a tibble but with a clear separation of header, body, and
footer.</p>
<div class="sourceCode" id="cb5"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb5-1"><a href="#cb5-1" tabindex="-1"></a>setup <span class="ot">&lt;-</span> <span class="fu">tbl_format_setup</span>(tbl, <span class="at">width =</span> <span class="dv">24</span>)</span>
<span id="cb5-2"><a href="#cb5-2" tabindex="-1"></a>setup</span>
<span id="cb5-3"><a href="#cb5-3" tabindex="-1"></a><span class="co">#&gt; &lt;pillar_tbl_format_setup&gt;</span></span>
<span id="cb5-4"><a href="#cb5-4" tabindex="-1"></a><span class="co">#&gt; &lt;tbl_format_header(setup)&gt;</span></span>
<span id="cb5-5"><a href="#cb5-5" tabindex="-1"></a><span class="co">#&gt; # A tibble: 3 × 3</span></span>
<span id="cb5-6"><a href="#cb5-6" tabindex="-1"></a><span class="co">#&gt; &lt;tbl_format_body(setup)&gt;</span></span>
<span id="cb5-7"><a href="#cb5-7" tabindex="-1"></a><span class="co">#&gt; a b$c e</span></span>
<span id="cb5-8"><a href="#cb5-8" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;</span></span>
<span id="cb5-9"><a href="#cb5-9" tabindex="-1"></a><span class="co">#&gt; 1 1 4 10</span></span>
<span id="cb5-10"><a href="#cb5-10" tabindex="-1"></a><span class="co">#&gt; 2 2 5 11</span></span>
<span id="cb5-11"><a href="#cb5-11" tabindex="-1"></a><span class="co">#&gt; 3 3 6 12</span></span>
<span id="cb5-12"><a href="#cb5-12" tabindex="-1"></a><span class="co">#&gt; &lt;tbl_format_footer(setup)&gt;</span></span>
<span id="cb5-13"><a href="#cb5-13" tabindex="-1"></a><span class="co">#&gt; # 1 more variable:</span></span>
<span id="cb5-14"><a href="#cb5-14" tabindex="-1"></a><span class="co">#&gt; # b$d &lt;int&gt;</span></span></code></pre></div>
<p>A setup object is required here to avoid computing information twice.
For instance, the dimensions shown in the header or the extra columns
displayed in the footer are available only after the body has been
computed.</p>
<p>The generic dispatches over the container, so that you can override
it if necessary. It is responsible for assigning default values to
arguments before passing them on to the method.</p>
<details>
<summary>
Source code of <code>tbl_format_setup()</code>
</summary>
<div class="sourceCode" id="cb6"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" tabindex="-1"></a>tbl_format_setup <span class="ot">&lt;-</span> <span class="cf">function</span> (x, <span class="at">width =</span> <span class="cn">NULL</span>, ..., <span class="at">setup =</span> <span class="fu">list</span>(<span class="at">tbl_sum =</span> <span class="fu">tbl_sum</span>(x)), </span>
<span id="cb6-2"><a href="#cb6-2" tabindex="-1"></a> <span class="at">n =</span> <span class="cn">NULL</span>, <span class="at">max_extra_cols =</span> <span class="cn">NULL</span>, <span class="at">max_footer_lines =</span> <span class="cn">NULL</span>, </span>
<span id="cb6-3"><a href="#cb6-3" tabindex="-1"></a> <span class="at">focus =</span> <span class="cn">NULL</span>) </span>
<span id="cb6-4"><a href="#cb6-4" tabindex="-1"></a>{</span>
<span id="cb6-5"><a href="#cb6-5" tabindex="-1"></a> <span class="st">&quot;!!!!DEBUG tbl_format_setup()&quot;</span></span>
<span id="cb6-6"><a href="#cb6-6" tabindex="-1"></a> width <span class="ot">&lt;-</span> <span class="fu">get_width_print</span>(width)</span>
<span id="cb6-7"><a href="#cb6-7" tabindex="-1"></a> n <span class="ot">&lt;-</span> <span class="fu">get_n_print</span>(n, <span class="fu">tbl_nrow</span>(x))</span>
<span id="cb6-8"><a href="#cb6-8" tabindex="-1"></a> max_extra_cols <span class="ot">&lt;-</span> <span class="fu">get_max_extra_cols</span>(max_extra_cols)</span>
<span id="cb6-9"><a href="#cb6-9" tabindex="-1"></a> max_footer_lines <span class="ot">&lt;-</span> <span class="fu">get_max_footer_lines</span>(max_footer_lines)</span>
<span id="cb6-10"><a href="#cb6-10" tabindex="-1"></a> out <span class="ot">&lt;-</span> <span class="fu">tbl_format_setup_dispatch</span>(x, width, ..., <span class="at">setup =</span> setup, </span>
<span id="cb6-11"><a href="#cb6-11" tabindex="-1"></a> <span class="at">n =</span> n, <span class="at">max_extra_cols =</span> max_extra_cols, <span class="at">max_footer_lines =</span> max_footer_lines, </span>
<span id="cb6-12"><a href="#cb6-12" tabindex="-1"></a> <span class="at">focus =</span> focus)</span>
<span id="cb6-13"><a href="#cb6-13" tabindex="-1"></a> <span class="fu">return</span>(out)</span>
<span id="cb6-14"><a href="#cb6-14" tabindex="-1"></a> <span class="fu">UseMethod</span>(<span class="st">&quot;tbl_format_setup&quot;</span>)</span>
<span id="cb6-15"><a href="#cb6-15" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>The default implementation converts the input to a data frame via
<code>as.data.frame(head(x))</code>, and returns an object constructed
with <code>new_tbl_format_setup()</code> that contains the data frame
and additional information. If you override this method, e.g. to
incorporate more information, you can add new items to the default setup
object, but you should not overwrite existing items.</p>
<details>
<summary>
Source code of <code>pillar:::tbl_format_setup.tbl()</code>
</summary>
<div class="sourceCode" id="cb7"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" tabindex="-1"></a>tbl_format_setup.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (x, width, ..., setup, n, max_extra_cols, max_footer_lines, </span>
<span id="cb7-2"><a href="#cb7-2" tabindex="-1"></a> focus) </span>
<span id="cb7-3"><a href="#cb7-3" tabindex="-1"></a>{</span>
<span id="cb7-4"><a href="#cb7-4" tabindex="-1"></a> <span class="st">&quot;!!!!DEBUG tbl_format_setup.tbl()&quot;</span></span>
<span id="cb7-5"><a href="#cb7-5" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is.null</span>(setup)) {</span>
<span id="cb7-6"><a href="#cb7-6" tabindex="-1"></a> tbl_sum <span class="ot">&lt;-</span> <span class="fu">tbl_sum</span>(x)</span>
<span id="cb7-7"><a href="#cb7-7" tabindex="-1"></a> <span class="fu">return</span>(<span class="fu">new_tbl_format_setup</span>(width, tbl_sum, <span class="at">rows_total =</span> <span class="cn">NA</span>))</span>
<span id="cb7-8"><a href="#cb7-8" tabindex="-1"></a> }</span>
<span id="cb7-9"><a href="#cb7-9" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb7-10"><a href="#cb7-10" tabindex="-1"></a> tbl_sum <span class="ot">&lt;-</span> setup<span class="sc">$</span>tbl_sum</span>
<span id="cb7-11"><a href="#cb7-11" tabindex="-1"></a> }</span>
<span id="cb7-12"><a href="#cb7-12" tabindex="-1"></a> rows <span class="ot">&lt;-</span> <span class="fu">tbl_nrow</span>(x)</span>
<span id="cb7-13"><a href="#cb7-13" tabindex="-1"></a> lazy <span class="ot">&lt;-</span> <span class="fu">is.na</span>(rows)</span>
<span id="cb7-14"><a href="#cb7-14" tabindex="-1"></a> <span class="cf">if</span> (lazy) {</span>
<span id="cb7-15"><a href="#cb7-15" tabindex="-1"></a> df <span class="ot">&lt;-</span> <span class="fu">as.data.frame</span>(<span class="fu">head</span>(x, n <span class="sc">+</span> <span class="dv">1</span>))</span>
<span id="cb7-16"><a href="#cb7-16" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">nrow</span>(df) <span class="sc">&lt;=</span> n) {</span>
<span id="cb7-17"><a href="#cb7-17" tabindex="-1"></a> rows <span class="ot">&lt;-</span> <span class="fu">nrow</span>(df)</span>
<span id="cb7-18"><a href="#cb7-18" tabindex="-1"></a> }</span>
<span id="cb7-19"><a href="#cb7-19" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb7-20"><a href="#cb7-20" tabindex="-1"></a> df <span class="ot">&lt;-</span> <span class="fu">vec_head</span>(df, n)</span>
<span id="cb7-21"><a href="#cb7-21" tabindex="-1"></a> }</span>
<span id="cb7-22"><a href="#cb7-22" tabindex="-1"></a> }</span>
<span id="cb7-23"><a href="#cb7-23" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb7-24"><a href="#cb7-24" tabindex="-1"></a> df <span class="ot">&lt;-</span> <span class="fu">df_head</span>(x, n)</span>
<span id="cb7-25"><a href="#cb7-25" tabindex="-1"></a> }</span>
<span id="cb7-26"><a href="#cb7-26" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is.na</span>(rows)) {</span>
<span id="cb7-27"><a href="#cb7-27" tabindex="-1"></a> needs_dots <span class="ot">&lt;-</span> (<span class="fu">nrow</span>(df) <span class="sc">&gt;=</span> n)</span>
<span id="cb7-28"><a href="#cb7-28" tabindex="-1"></a> }</span>
<span id="cb7-29"><a href="#cb7-29" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb7-30"><a href="#cb7-30" tabindex="-1"></a> needs_dots <span class="ot">&lt;-</span> (rows <span class="sc">&gt;</span> n)</span>
<span id="cb7-31"><a href="#cb7-31" tabindex="-1"></a> }</span>
<span id="cb7-32"><a href="#cb7-32" tabindex="-1"></a> <span class="cf">if</span> (needs_dots) {</span>
<span id="cb7-33"><a href="#cb7-33" tabindex="-1"></a> rows_missing <span class="ot">&lt;-</span> rows <span class="sc">-</span> n</span>
<span id="cb7-34"><a href="#cb7-34" tabindex="-1"></a> }</span>
<span id="cb7-35"><a href="#cb7-35" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb7-36"><a href="#cb7-36" tabindex="-1"></a> rows_missing <span class="ot">&lt;-</span> <span class="dv">0</span></span>
<span id="cb7-37"><a href="#cb7-37" tabindex="-1"></a> }</span>
<span id="cb7-38"><a href="#cb7-38" tabindex="-1"></a> <span class="fu">rownames</span>(df) <span class="ot">&lt;-</span> <span class="cn">NULL</span></span>
<span id="cb7-39"><a href="#cb7-39" tabindex="-1"></a> colonnade <span class="ot">&lt;-</span> <span class="fu">ctl_colonnade</span>(df, <span class="at">has_row_id =</span> <span class="cf">if</span> (<span class="sc">!</span>lazy <span class="sc">&amp;&amp;</span> </span>
<span id="cb7-40"><a href="#cb7-40" tabindex="-1"></a> <span class="fu">.row_names_info</span>(x) <span class="sc">&gt;</span> <span class="dv">0</span>) </span>
<span id="cb7-41"><a href="#cb7-41" tabindex="-1"></a> <span class="st">&quot;*&quot;</span></span>
<span id="cb7-42"><a href="#cb7-42" tabindex="-1"></a> <span class="cf">else</span> <span class="cn">TRUE</span>, <span class="at">width =</span> width, <span class="at">controller =</span> x, <span class="at">focus =</span> focus)</span>
<span id="cb7-43"><a href="#cb7-43" tabindex="-1"></a> body <span class="ot">&lt;-</span> colonnade<span class="sc">$</span>body</span>
<span id="cb7-44"><a href="#cb7-44" tabindex="-1"></a> extra_cols <span class="ot">&lt;-</span> colonnade<span class="sc">$</span>extra_cols</span>
<span id="cb7-45"><a href="#cb7-45" tabindex="-1"></a> extra_cols_total <span class="ot">&lt;-</span> <span class="fu">length</span>(extra_cols)</span>
<span id="cb7-46"><a href="#cb7-46" tabindex="-1"></a> <span class="cf">if</span> (extra_cols_total <span class="sc">&gt;</span> max_extra_cols) {</span>
<span id="cb7-47"><a href="#cb7-47" tabindex="-1"></a> <span class="fu">length</span>(extra_cols) <span class="ot">&lt;-</span> max_extra_cols</span>
<span id="cb7-48"><a href="#cb7-48" tabindex="-1"></a> }</span>
<span id="cb7-49"><a href="#cb7-49" tabindex="-1"></a> abbrev_cols <span class="ot">&lt;-</span> colonnade<span class="sc">$</span>abbrev_cols</span>
<span id="cb7-50"><a href="#cb7-50" tabindex="-1"></a> <span class="fu">new_tbl_format_setup</span>(<span class="at">x =</span> x, <span class="at">df =</span> df, <span class="at">width =</span> width, <span class="at">tbl_sum =</span> tbl_sum, </span>
<span id="cb7-51"><a href="#cb7-51" tabindex="-1"></a> <span class="at">body =</span> body, <span class="at">rows_missing =</span> rows_missing, <span class="at">rows_total =</span> rows, </span>
<span id="cb7-52"><a href="#cb7-52" tabindex="-1"></a> <span class="at">extra_cols =</span> extra_cols, <span class="at">extra_cols_total =</span> extra_cols_total, </span>
<span id="cb7-53"><a href="#cb7-53" tabindex="-1"></a> <span class="at">max_footer_lines =</span> max_footer_lines, <span class="at">abbrev_cols =</span> abbrev_cols)</span>
<span id="cb7-54"><a href="#cb7-54" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>At the core, the internal function <code>ctl_colonnade()</code>
composes the body. Its functionality and the customization points it
offers are detailed in the “Colonnade” section below.</p>
</div>
<div id="header-body-footer" class="section level2">
<h2>Header, body, footer</h2>
<p>The components of a tibble are formatted with
<code>tbl_format_*()</code> generics, which also dispatch on the
container to allow extension or overrides. They return a character
vector, with one element per line printed. The setup object is
required.</p>
<div class="sourceCode" id="cb8"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" tabindex="-1"></a><span class="fu">tbl_format_header</span>(tbl, setup)</span>
<span id="cb8-2"><a href="#cb8-2" tabindex="-1"></a><span class="co">#&gt; [1] &quot;# A tibble: 3 × 3&quot;</span></span>
<span id="cb8-3"><a href="#cb8-3" tabindex="-1"></a><span class="fu">tbl_format_body</span>(tbl, setup)</span>
<span id="cb8-4"><a href="#cb8-4" tabindex="-1"></a><span class="co">#&gt; a b$c e</span></span>
<span id="cb8-5"><a href="#cb8-5" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt; &lt;int&gt; &lt;int&gt;</span></span>
<span id="cb8-6"><a href="#cb8-6" tabindex="-1"></a><span class="co">#&gt; 1 1 4 10</span></span>
<span id="cb8-7"><a href="#cb8-7" tabindex="-1"></a><span class="co">#&gt; 2 2 5 11</span></span>
<span id="cb8-8"><a href="#cb8-8" tabindex="-1"></a><span class="co">#&gt; 3 3 6 12</span></span>
<span id="cb8-9"><a href="#cb8-9" tabindex="-1"></a><span class="fu">tbl_format_footer</span>(tbl, setup)</span>
<span id="cb8-10"><a href="#cb8-10" tabindex="-1"></a><span class="co">#&gt; [1] &quot;# 1 more variable:&quot; &quot;# b$d &lt;int&gt;&quot;</span></span></code></pre></div>
<p>(The body is returned as a classed object with a <code>print()</code>
method, it is still a <code>character()</code> under the hood.)</p>
<div class="sourceCode" id="cb9"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" tabindex="-1"></a><span class="fu">class</span>(<span class="fu">tbl_format_body</span>(tbl, setup))</span>
<span id="cb9-2"><a href="#cb9-2" tabindex="-1"></a><span class="co">#&gt; [1] &quot;glue&quot; &quot;character&quot;</span></span>
<span id="cb9-3"><a href="#cb9-3" tabindex="-1"></a><span class="fu">typeof</span>(<span class="fu">tbl_format_body</span>(tbl, setup))</span>
<span id="cb9-4"><a href="#cb9-4" tabindex="-1"></a><span class="co">#&gt; [1] &quot;character&quot;</span></span></code></pre></div>
<p>Since most of the work already has been carried out in
<code>tbl_format_setup()</code>, the default implementations mostly
consist of code that styles and wraps the output.</p>
<details>
<summary>
Source code of <code>pillar:::tbl_format_header.tbl()</code>
</summary>
<div class="sourceCode" id="cb10"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" tabindex="-1"></a>tbl_format_header.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (x, setup, ...) </span>
<span id="cb10-2"><a href="#cb10-2" tabindex="-1"></a>{</span>
<span id="cb10-3"><a href="#cb10-3" tabindex="-1"></a> named_header <span class="ot">&lt;-</span> setup<span class="sc">$</span>tbl_sum</span>
<span id="cb10-4"><a href="#cb10-4" tabindex="-1"></a> focus <span class="ot">&lt;-</span> <span class="fu">attr</span>(x, <span class="st">&quot;pillar_focus&quot;</span>)</span>
<span id="cb10-5"><a href="#cb10-5" tabindex="-1"></a> <span class="cf">if</span> (<span class="sc">!</span><span class="fu">is.null</span>(focus)) {</span>
<span id="cb10-6"><a href="#cb10-6" tabindex="-1"></a> named_header <span class="ot">&lt;-</span> <span class="fu">c</span>(named_header, <span class="st">`</span><span class="at">Focus columns</span><span class="st">`</span> <span class="ot">=</span> <span class="fu">collapse</span>(<span class="fu">tick_if_needed</span>(focus)))</span>
<span id="cb10-7"><a href="#cb10-7" tabindex="-1"></a> }</span>
<span id="cb10-8"><a href="#cb10-8" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">all</span>(<span class="fu">names2</span>(named_header) <span class="sc">==</span> <span class="st">&quot;&quot;</span>)) {</span>
<span id="cb10-9"><a href="#cb10-9" tabindex="-1"></a> header <span class="ot">&lt;-</span> named_header</span>
<span id="cb10-10"><a href="#cb10-10" tabindex="-1"></a> }</span>
<span id="cb10-11"><a href="#cb10-11" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb10-12"><a href="#cb10-12" tabindex="-1"></a> header <span class="ot">&lt;-</span> <span class="fu">paste0</span>(<span class="fu">align</span>(<span class="fu">paste0</span>(<span class="fu">names2</span>(named_header), <span class="st">&quot;:&quot;</span>), </span>
<span id="cb10-13"><a href="#cb10-13" tabindex="-1"></a> <span class="at">space =</span> NBSP), <span class="st">&quot; &quot;</span>, named_header)</span>
<span id="cb10-14"><a href="#cb10-14" tabindex="-1"></a> }</span>
<span id="cb10-15"><a href="#cb10-15" tabindex="-1"></a> <span class="fu">style_subtle</span>(<span class="fu">format_comment</span>(header, <span class="at">width =</span> setup<span class="sc">$</span>width))</span>
<span id="cb10-16"><a href="#cb10-16" tabindex="-1"></a>}</span></code></pre></div>
</details>
<details>
<summary>
Source code of <code>pillar:::tbl_format_body.tbl()</code>
</summary>
<div class="sourceCode" id="cb11"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" tabindex="-1"></a>tbl_format_body.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (x, setup, ...) </span>
<span id="cb11-2"><a href="#cb11-2" tabindex="-1"></a>{</span>
<span id="cb11-3"><a href="#cb11-3" tabindex="-1"></a> <span class="fu">force</span>(setup)</span>
<span id="cb11-4"><a href="#cb11-4" tabindex="-1"></a> setup<span class="sc">$</span>body</span>
<span id="cb11-5"><a href="#cb11-5" tabindex="-1"></a>}</span></code></pre></div>
</details>
<details>
<summary>
Source code of <code>pillar:::tbl_format_footer.tbl()</code>
</summary>
<div class="sourceCode" id="cb12"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" tabindex="-1"></a>tbl_format_footer.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (x, setup, ...) </span>
<span id="cb12-2"><a href="#cb12-2" tabindex="-1"></a>{</span>
<span id="cb12-3"><a href="#cb12-3" tabindex="-1"></a> footer <span class="ot">&lt;-</span> <span class="fu">format_footer</span>(x, setup)</span>
<span id="cb12-4"><a href="#cb12-4" tabindex="-1"></a> footer_comment <span class="ot">&lt;-</span> <span class="fu">wrap_footer_bullet</span>(footer, setup)</span>
<span id="cb12-5"><a href="#cb12-5" tabindex="-1"></a> footer_advice <span class="ot">&lt;-</span> <span class="fu">format_footer_advice</span>(x, setup)</span>
<span id="cb12-6"><a href="#cb12-6" tabindex="-1"></a> footer_advice_comment <span class="ot">&lt;-</span> <span class="fu">wrap_footer_bullet</span>(footer_advice, </span>
<span id="cb12-7"><a href="#cb12-7" tabindex="-1"></a> setup, <span class="at">lines =</span> <span class="dv">1</span>, <span class="at">ellipsis =</span> <span class="cn">FALSE</span>, <span class="at">bullet =</span> symbol<span class="sc">$</span>info)</span>
<span id="cb12-8"><a href="#cb12-8" tabindex="-1"></a> <span class="fu">style_subtle</span>(<span class="fu">c</span>(footer_comment, footer_advice_comment))</span>
<span id="cb12-9"><a href="#cb12-9" tabindex="-1"></a>}</span></code></pre></div>
</details>
</div>
<div id="colonnade" class="section level2">
<h2>Colonnade</h2>
<p>The internal function <code>ctl_colonnade()</code> composes the body.
It performs the following tasks:</p>
<ol style="list-style-type: decimal">
<li>Create a pillar object for every top-level column that fits, using
the minimum width, via <code>ctl_new_pillar_list()</code>,
<code>ctl_new_pillar()</code> and ultimately <code>pillar()</code> and
<code>pillar_shaft()</code></li>
<li>Determine the number of tiers and the width for each tier</li>
<li>Distribute the pillars across the tiers, assigning a width to each
pillar.</li>
<li>Format each pillar via its <code>format()</code> function, passing
the now known width.</li>
<li>Combine the formatted pillars horizontally.</li>
<li>Combine the tiers vertically.</li>
<li>Return the formatted body, and the columns that could not fit.</li>
</ol>
<p>In the following, the first and the fourth steps are discussed.</p>
</div>
<div id="creating-pillar-objects" class="section level2">
<h2>Creating pillar objects</h2>
<p>The initial tibble is passed to <code>ctl_new_pillar_list()</code>,
which eventually calls <code>ctl_new_pillar()</code> once or several
times. For each top-level column, one pillar object is constructed. The
loop is terminated when the available width is exhausted even
considering the minimum width.</p>
<div id="pillar-lists" class="section level3">
<h3>Pillar lists</h3>
<p>The <code>ctl_new_pillar_list()</code> generic dispatches on the
container:</p>
<div class="sourceCode" id="cb13"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" tabindex="-1"></a><span class="fu">ctl_new_pillar_list</span>(tbl, tbl<span class="sc">$</span>a, <span class="at">width =</span> <span class="dv">20</span>)</span>
<span id="cb13-2"><a href="#cb13-2" tabindex="-1"></a><span class="co">#&gt; [[1]]</span></span>
<span id="cb13-3"><a href="#cb13-3" tabindex="-1"></a><span class="co">#&gt; &lt;pillar&gt;</span></span>
<span id="cb13-4"><a href="#cb13-4" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt;</span></span>
<span id="cb13-5"><a href="#cb13-5" tabindex="-1"></a><span class="co">#&gt; 1</span></span>
<span id="cb13-6"><a href="#cb13-6" tabindex="-1"></a><span class="co">#&gt; 2</span></span>
<span id="cb13-7"><a href="#cb13-7" tabindex="-1"></a><span class="co">#&gt; 3</span></span>
<span id="cb13-8"><a href="#cb13-8" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb13-9"><a href="#cb13-9" tabindex="-1"></a><span class="co">#&gt; attr(,&quot;remaining_width&quot;)</span></span>
<span id="cb13-10"><a href="#cb13-10" tabindex="-1"></a><span class="co">#&gt; [1] 14</span></span>
<span id="cb13-11"><a href="#cb13-11" tabindex="-1"></a><span class="co">#&gt; attr(,&quot;simple&quot;)</span></span>
<span id="cb13-12"><a href="#cb13-12" tabindex="-1"></a><span class="co">#&gt; [1] TRUE</span></span>
<span id="cb13-13"><a href="#cb13-13" tabindex="-1"></a><span class="fu">ctl_new_pillar_list</span>(tbl, tbl<span class="sc">$</span>b, <span class="at">width =</span> <span class="dv">20</span>)</span>
<span id="cb13-14"><a href="#cb13-14" tabindex="-1"></a><span class="co">#&gt; [[1]]</span></span>
<span id="cb13-15"><a href="#cb13-15" tabindex="-1"></a><span class="co">#&gt; &lt;pillar&gt;</span></span>
<span id="cb13-16"><a href="#cb13-16" tabindex="-1"></a><span class="co">#&gt; c</span></span>
<span id="cb13-17"><a href="#cb13-17" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt;</span></span>
<span id="cb13-18"><a href="#cb13-18" tabindex="-1"></a><span class="co">#&gt; 4</span></span>
<span id="cb13-19"><a href="#cb13-19" tabindex="-1"></a><span class="co">#&gt; 5</span></span>
<span id="cb13-20"><a href="#cb13-20" tabindex="-1"></a><span class="co">#&gt; 6</span></span>
<span id="cb13-21"><a href="#cb13-21" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb13-22"><a href="#cb13-22" tabindex="-1"></a><span class="co">#&gt; [[2]]</span></span>
<span id="cb13-23"><a href="#cb13-23" tabindex="-1"></a><span class="co">#&gt; &lt;pillar&gt;</span></span>
<span id="cb13-24"><a href="#cb13-24" tabindex="-1"></a><span class="co">#&gt; d</span></span>
<span id="cb13-25"><a href="#cb13-25" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt;</span></span>
<span id="cb13-26"><a href="#cb13-26" tabindex="-1"></a><span class="co">#&gt; 7</span></span>
<span id="cb13-27"><a href="#cb13-27" tabindex="-1"></a><span class="co">#&gt; 8</span></span>
<span id="cb13-28"><a href="#cb13-28" tabindex="-1"></a><span class="co">#&gt; 9</span></span>
<span id="cb13-29"><a href="#cb13-29" tabindex="-1"></a><span class="co">#&gt; </span></span>
<span id="cb13-30"><a href="#cb13-30" tabindex="-1"></a><span class="co">#&gt; attr(,&quot;extra&quot;)</span></span>
<span id="cb13-31"><a href="#cb13-31" tabindex="-1"></a><span class="co">#&gt; character(0)</span></span>
<span id="cb13-32"><a href="#cb13-32" tabindex="-1"></a><span class="co">#&gt; attr(,&quot;remaining_width&quot;)</span></span>
<span id="cb13-33"><a href="#cb13-33" tabindex="-1"></a><span class="co">#&gt; [1] 8</span></span>
<span id="cb13-34"><a href="#cb13-34" tabindex="-1"></a><span class="co">#&gt; attr(,&quot;simple&quot;)</span></span>
<span id="cb13-35"><a href="#cb13-35" tabindex="-1"></a><span class="co">#&gt; [1] FALSE</span></span></code></pre></div>
<p>In a tibble, each column can be a data frame, matrix, or even array
itself, such columns are called <em>compound columns</em>. Such columns
are decomposed into sub-pillars and returned as a list of pillars.
Regular vectors are forwarded to <code>ctl_new_pillar()</code> and
returned as list of length one. Implementers of <code>&quot;tbl&quot;</code>
subclasses will rarely if ever need to extend or override this
method.</p>
<details>
<summary>
Source code of <code>pillar:::ctl_new_pillar_list.tbl()</code>
</summary>
<div class="sourceCode" id="cb14"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" tabindex="-1"></a>ctl_new_pillar_list.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (controller, x, width, ..., <span class="at">title =</span> <span class="cn">NULL</span>, <span class="at">first_pillar =</span> <span class="cn">NULL</span>) </span>
<span id="cb14-2"><a href="#cb14-2" tabindex="-1"></a>{</span>
<span id="cb14-3"><a href="#cb14-3" tabindex="-1"></a> <span class="st">&quot;!!!!DEBUG ctl_new_pillar_list.tbl(`v(width)`, `v(title)`)&quot;</span></span>
<span id="cb14-4"><a href="#cb14-4" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is.data.frame</span>(x)) {</span>
<span id="cb14-5"><a href="#cb14-5" tabindex="-1"></a> <span class="fu">new_data_frame_pillar_list</span>(x, controller, width, <span class="at">title =</span> title, </span>
<span id="cb14-6"><a href="#cb14-6" tabindex="-1"></a> <span class="at">first_pillar =</span> first_pillar)</span>
<span id="cb14-7"><a href="#cb14-7" tabindex="-1"></a> }</span>
<span id="cb14-8"><a href="#cb14-8" tabindex="-1"></a> <span class="cf">else</span> <span class="cf">if</span> (<span class="fu">is.matrix</span>(x) <span class="sc">&amp;&amp;</span> <span class="sc">!</span><span class="fu">inherits</span>(x, <span class="fu">c</span>(<span class="st">&quot;Surv&quot;</span>, <span class="st">&quot;Surv2&quot;</span>))) {</span>
<span id="cb14-9"><a href="#cb14-9" tabindex="-1"></a> <span class="fu">new_matrix_pillar_list</span>(x, controller, width, <span class="at">title =</span> title, </span>
<span id="cb14-10"><a href="#cb14-10" tabindex="-1"></a> <span class="at">first_pillar =</span> first_pillar)</span>
<span id="cb14-11"><a href="#cb14-11" tabindex="-1"></a> }</span>
<span id="cb14-12"><a href="#cb14-12" tabindex="-1"></a> <span class="cf">else</span> <span class="cf">if</span> (<span class="fu">is.array</span>(x) <span class="sc">&amp;&amp;</span> <span class="fu">length</span>(<span class="fu">dim</span>(x)) <span class="sc">&gt;</span> <span class="dv">2</span>) {</span>
<span id="cb14-13"><a href="#cb14-13" tabindex="-1"></a> <span class="fu">new_array_pillar_list</span>(x, controller, width, <span class="at">title =</span> title, </span>
<span id="cb14-14"><a href="#cb14-14" tabindex="-1"></a> <span class="at">first_pillar =</span> first_pillar)</span>
<span id="cb14-15"><a href="#cb14-15" tabindex="-1"></a> }</span>
<span id="cb14-16"><a href="#cb14-16" tabindex="-1"></a> <span class="cf">else</span> {</span>
<span id="cb14-17"><a href="#cb14-17" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is.null</span>(first_pillar)) {</span>
<span id="cb14-18"><a href="#cb14-18" tabindex="-1"></a> first_pillar <span class="ot">&lt;-</span> <span class="fu">ctl_new_pillar</span>(controller, x, width, </span>
<span id="cb14-19"><a href="#cb14-19" tabindex="-1"></a> ..., <span class="at">title =</span> <span class="fu">prepare_title</span>(title))</span>
<span id="cb14-20"><a href="#cb14-20" tabindex="-1"></a> }</span>
<span id="cb14-21"><a href="#cb14-21" tabindex="-1"></a> <span class="fu">new_single_pillar_list</span>(first_pillar, width)</span>
<span id="cb14-22"><a href="#cb14-22" tabindex="-1"></a> }</span>
<span id="cb14-23"><a href="#cb14-23" tabindex="-1"></a>}</span></code></pre></div>
</details>
</div>
<div id="simple-pillars" class="section level3">
<h3>Simple pillars</h3>
<p>The <code>ctl_new_pillar()</code> method is called for columns that
are not data frames or arrays, and also dispatches over the
container.</p>
<div class="sourceCode" id="cb15"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" tabindex="-1"></a><span class="fu">ctl_new_pillar</span>(tbl, tbl<span class="sc">$</span>a, <span class="at">width =</span> <span class="dv">20</span>)</span>
<span id="cb15-2"><a href="#cb15-2" tabindex="-1"></a><span class="co">#&gt; &lt;pillar&gt;</span></span>
<span id="cb15-3"><a href="#cb15-3" tabindex="-1"></a><span class="co">#&gt; &lt;int&gt;</span></span>
<span id="cb15-4"><a href="#cb15-4" tabindex="-1"></a><span class="co">#&gt; 1</span></span>
<span id="cb15-5"><a href="#cb15-5" tabindex="-1"></a><span class="co">#&gt; 2</span></span>
<span id="cb15-6"><a href="#cb15-6" tabindex="-1"></a><span class="co">#&gt; 3</span></span></code></pre></div>
<details>
<summary>
Source code of <code>pillar:::ctl_new_pillar.tbl()</code>
</summary>
<div class="sourceCode" id="cb16"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" tabindex="-1"></a>ctl_new_pillar.tbl <span class="ot">&lt;-</span> <span class="cf">function</span> (controller, x, width, ..., <span class="at">title =</span> <span class="cn">NULL</span>) </span>
<span id="cb16-2"><a href="#cb16-2" tabindex="-1"></a>{</span>
<span id="cb16-3"><a href="#cb16-3" tabindex="-1"></a> <span class="st">&quot;!!!!DEBUG ctl_new_pillar.tbl(`v(width)`, `v(title)`)&quot;</span></span>
<span id="cb16-4"><a href="#cb16-4" tabindex="-1"></a> <span class="fu">pillar</span>(x, title, <span class="cf">if</span> (<span class="sc">!</span><span class="fu">is.null</span>(width)) </span>
<span id="cb16-5"><a href="#cb16-5" tabindex="-1"></a> <span class="fu">max0</span>(width))</span>
<span id="cb16-6"><a href="#cb16-6" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>The default method calls <code>pillar()</code> directly, passing the
maximum width available.</p>
<details>
<summary>
Source code of <code>pillar()</code>
</summary>
<div class="sourceCode" id="cb17"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" tabindex="-1"></a>pillar <span class="ot">&lt;-</span> <span class="cf">function</span> (x, <span class="at">title =</span> <span class="cn">NULL</span>, <span class="at">width =</span> <span class="cn">NULL</span>, ...) </span>
<span id="cb17-2"><a href="#cb17-2" tabindex="-1"></a>{</span>
<span id="cb17-3"><a href="#cb17-3" tabindex="-1"></a> <span class="st">&quot;!!!!DEBUG pillar(`v(class(x))`, `v(title)`, `v(width)`)&quot;</span></span>
<span id="cb17-4"><a href="#cb17-4" tabindex="-1"></a> <span class="fu">pillar_from_shaft</span>(<span class="fu">new_pillar_title</span>(title), <span class="fu">new_pillar_type</span>(x), </span>
<span id="cb17-5"><a href="#cb17-5" tabindex="-1"></a> <span class="fu">pillar_shaft</span>(x, ...), width)</span>
<span id="cb17-6"><a href="#cb17-6" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>Formatting for title and type is provided by
<code>new_pillar_title()</code> and <code>new_pillar_type()</code>. The
body can be customized by implementing <code>pillar_shaft()</code> for a
vector class, see <code>vignette(&quot;pillar&quot;, package = &quot;vctrs&quot;)</code> for
details. If title or type dont fit the available width,
<code>pillar_shaft()</code> is never called.</p>
<p>This function now returns <code>NULL</code> if the width is
insufficient to contain the data. It is possible to change the
appearance of pillars by overriding or extending
<code>ctl_new_pillar()</code>.</p>
</div>
<div id="components" class="section level3">
<h3>Components</h3>
<p>Pillar objects share the same structure and are ultimately
constructed with <code>new_pillar()</code>.</p>
<details>
<summary>
Source code of <code>new_pillar()</code>
</summary>
<div class="sourceCode" id="cb18"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb18-1"><a href="#cb18-1" tabindex="-1"></a>new_pillar <span class="ot">&lt;-</span> <span class="cf">function</span> (components, ..., <span class="at">width =</span> <span class="cn">NULL</span>, <span class="at">class =</span> <span class="cn">NULL</span>, <span class="at">extra =</span> <span class="fu">deprecated</span>()) </span>
<span id="cb18-2"><a href="#cb18-2" tabindex="-1"></a>{</span>
<span id="cb18-3"><a href="#cb18-3" tabindex="-1"></a> <span class="st">&quot;!!!!DEBUG new_pillar(`v(width)`, `v(class)`)&quot;</span></span>
<span id="cb18-4"><a href="#cb18-4" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is_present</span>(extra)) {</span>
<span id="cb18-5"><a href="#cb18-5" tabindex="-1"></a> <span class="fu">deprecate_warn</span>(<span class="st">&quot;1.7.0&quot;</span>, <span class="st">&quot;pillar::new_pillar(extra = )&quot;</span>)</span>
<span id="cb18-6"><a href="#cb18-6" tabindex="-1"></a> }</span>
<span id="cb18-7"><a href="#cb18-7" tabindex="-1"></a> <span class="fu">check_dots_empty</span>()</span>
<span id="cb18-8"><a href="#cb18-8" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">length</span>(components) <span class="sc">&gt;</span> <span class="dv">0</span> <span class="sc">&amp;&amp;</span> <span class="sc">!</span><span class="fu">is_named</span>(components)) {</span>
<span id="cb18-9"><a href="#cb18-9" tabindex="-1"></a> <span class="fu">abort</span>(<span class="st">&quot;All components must have names.&quot;</span>)</span>
<span id="cb18-10"><a href="#cb18-10" tabindex="-1"></a> }</span>
<span id="cb18-11"><a href="#cb18-11" tabindex="-1"></a> <span class="fu">structure</span>(components, <span class="at">width =</span> width, <span class="at">class =</span> <span class="fu">c</span>(class, <span class="st">&quot;pillar&quot;</span>))</span>
<span id="cb18-12"><a href="#cb18-12" tabindex="-1"></a>}</span></code></pre></div>
</details>
<p>A pillar is stored as a list of components. Each pillar represents
only one simple (atomic) column, compound columns are always represented
as multiple pillar objects.</p>
</div>
</div>
<div id="formatting-pillars" class="section level2">
<h2>Formatting pillars</h2>
<p>When a pillar object is constructed, it has a minimum and a desired
(maximum) width. Because it depends on the number and width of other
pillar objects that may not be even constructed, the final width is not
known yet. It is passed to <code>format()</code>, which uses the desired
width if empty:</p>
<details>
<summary>
Source code of <code>pillar:::format.pillar()</code>
</summary>
<div class="sourceCode" id="cb19"><pre class="sourceCode r"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" tabindex="-1"></a>format.pillar <span class="ot">&lt;-</span> <span class="cf">function</span> (x, <span class="at">width =</span> <span class="cn">NULL</span>, ...) </span>
<span id="cb19-2"><a href="#cb19-2" tabindex="-1"></a>{</span>
<span id="cb19-3"><a href="#cb19-3" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is.null</span>(width)) {</span>
<span id="cb19-4"><a href="#cb19-4" tabindex="-1"></a> width <span class="ot">&lt;-</span> <span class="fu">get_width</span>(x)</span>
<span id="cb19-5"><a href="#cb19-5" tabindex="-1"></a> }</span>
<span id="cb19-6"><a href="#cb19-6" tabindex="-1"></a> <span class="cf">if</span> (<span class="fu">is.null</span>(width)) {</span>
<span id="cb19-7"><a href="#cb19-7" tabindex="-1"></a> width <span class="ot">&lt;-</span> <span class="fu">pillar_get_width</span>(x)</span>
<span id="cb19-8"><a href="#cb19-8" tabindex="-1"></a> }</span>
<span id="cb19-9"><a href="#cb19-9" tabindex="-1"></a> <span class="fu">as_glue</span>(<span class="fu">pillar_format_parts_2</span>(x, width)<span class="sc">$</span>aligned)</span>
<span id="cb19-10"><a href="#cb19-10" tabindex="-1"></a>}</span></code></pre></div>
</details>
</div>
<!-- code folding -->
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>
(function () {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
document.getElementsByTagName("head")[0].appendChild(script);
})();
</script>
</body>
</html>