* @param {object} opts (see Plotly.toImage in ../plot_api/to_image)
* @return {promise}
*/
function downloadImage(gd, opts) {
var _gd;
if (!Lib.isPlainObject(gd)) _gd = Lib.getGraphDiv(gd);
opts = opts || {};
opts.format = opts.format || 'png';
opts.width = opts.width || null;
opts.height = opts.height || null;
opts.imageDataOnly = true;
return new Promise(function (resolve, reject) {
if (_gd && _gd._snapshotInProgress) {
reject(new Error('Snapshotting already in progress.'));
}
// see comments within svgtoimg for additional
// discussion of problems with IE
// can now draw to canvas, but CORS tainted canvas
// does not allow toDataURL
// svg format will work though
if (Lib.isIE() && opts.format !== 'svg') {
reject(new Error(helpers.MSG_IE_BAD_FORMAT));
}
if (_gd) _gd._snapshotInProgress = true;
var promise = toImage(gd, opts);
var filename = opts.filename || gd.fn || 'newplot';
filename += '.' + opts.format.replace('-', '.');
promise.then(function (result) {
if (_gd) _gd._snapshotInProgress = false;
return fileSaver(result, filename, opts.format);
}).then(function (name) {
resolve(name);
}).catch(function (err) {
if (_gd) _gd._snapshotInProgress = false;
reject(err);
});
});
}
module.exports = downloadImage;
/***/ }),
/***/ 48616:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var helpers = __webpack_require__(81792);
/*
* substantial portions of this code from FileSaver.js
* https://github.com/eligrey/FileSaver.js
* License: https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
* FileSaver.js
* A saveAs() FileSaver implementation.
* 1.1.20160328
*
* By Eli Grey, http://eligrey.com
* License: MIT
* See https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md
*/
function fileSaver(url, name, format) {
var saveLink = document.createElement('a');
var canUseSaveLink = ('download' in saveLink);
var promise = new Promise(function (resolve, reject) {
var blob;
var objectUrl;
// IE 10+ (native saveAs)
if (Lib.isIE()) {
// At this point we are only dealing with a decoded SVG as
// a data URL (since IE only supports SVG)
blob = helpers.createBlob(url, 'svg');
window.navigator.msSaveBlob(blob, name);
blob = null;
return resolve(name);
}
if (canUseSaveLink) {
blob = helpers.createBlob(url, format);
objectUrl = helpers.createObjectURL(blob);
saveLink.href = objectUrl;
saveLink.download = name;
document.body.appendChild(saveLink);
saveLink.click();
document.body.removeChild(saveLink);
helpers.revokeObjectURL(objectUrl);
blob = null;
return resolve(name);
}
// Older versions of Safari did not allow downloading of blob urls
if (Lib.isSafari()) {
var prefix = format === 'svg' ? ',' : ';base64,';
helpers.octetStream(prefix + encodeURIComponent(url));
return resolve(name);
}
reject(new Error('download error'));
});
return promise;
}
module.exports = fileSaver;
/***/ }),
/***/ 81792:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var Registry = __webpack_require__(24040);
exports.getDelay = function (fullLayout) {
if (!fullLayout._has) return 0;
return fullLayout._has('gl3d') || fullLayout._has('gl2d') || fullLayout._has('mapbox') ? 500 : 0;
};
exports.getRedrawFunc = function (gd) {
return function () {
Registry.getComponentMethod('colorbar', 'draw')(gd);
};
};
exports.encodeSVG = function (svg) {
return 'data:image/svg+xml,' + encodeURIComponent(svg);
};
exports.encodeJSON = function (json) {
return 'data:application/json,' + encodeURIComponent(json);
};
var DOM_URL = window.URL || window.webkitURL;
exports.createObjectURL = function (blob) {
return DOM_URL.createObjectURL(blob);
};
exports.revokeObjectURL = function (url) {
return DOM_URL.revokeObjectURL(url);
};
exports.createBlob = function (url, format) {
if (format === 'svg') {
return new window.Blob([url], {
type: 'image/svg+xml;charset=utf-8'
});
} else if (format === 'full-json') {
return new window.Blob([url], {
type: 'application/json;charset=utf-8'
});
} else {
var binary = fixBinary(window.atob(url));
return new window.Blob([binary], {
type: 'image/' + format
});
}
};
exports.octetStream = function (s) {
document.location.href = 'data:application/octet-stream' + s;
};
// Taken from https://bl.ocks.org/nolanlawson/0eac306e4dac2114c752
function fixBinary(b) {
var len = b.length;
var buf = new ArrayBuffer(len);
var arr = new Uint8Array(buf);
for (var i = 0; i < len; i++) {
arr[i] = b.charCodeAt(i);
}
return buf;
}
exports.IMAGE_URL_PREFIX = /^data:image\/\w+;base64,/;
exports.MSG_IE_BAD_FORMAT = 'Sorry IE does not support downloading from canvas. Try {format:\'svg\'} instead.';
/***/ }),
/***/ 78904:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var helpers = __webpack_require__(81792);
var Snapshot = {
getDelay: helpers.getDelay,
getRedrawFunc: helpers.getRedrawFunc,
clone: __webpack_require__(91536),
toSVG: __webpack_require__(37164),
svgToImg: __webpack_require__(63268),
toImage: __webpack_require__(61808),
downloadImage: __webpack_require__(39792)
};
module.exports = Snapshot;
/***/ }),
/***/ 63268:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var EventEmitter = (__webpack_require__(61252).EventEmitter);
var helpers = __webpack_require__(81792);
function svgToImg(opts) {
var ev = opts.emitter || new EventEmitter();
var promise = new Promise(function (resolve, reject) {
var Image = window.Image;
var svg = opts.svg;
var format = opts.format || 'png';
// IE only support svg
if (Lib.isIE() && format !== 'svg') {
var ieSvgError = new Error(helpers.MSG_IE_BAD_FORMAT);
reject(ieSvgError);
// eventually remove the ev
// in favor of promises
if (!opts.promise) {
return ev.emit('error', ieSvgError);
} else {
return promise;
}
}
var canvas = opts.canvas;
var scale = opts.scale || 1;
var w0 = opts.width || 300;
var h0 = opts.height || 150;
var w1 = scale * w0;
var h1 = scale * h0;
var ctx = canvas.getContext('2d', {
willReadFrequently: true
});
var img = new Image();
var svgBlob, url;
if (format === 'svg' || Lib.isSafari()) {
url = helpers.encodeSVG(svg);
} else {
svgBlob = helpers.createBlob(svg, 'svg');
url = helpers.createObjectURL(svgBlob);
}
canvas.width = w1;
canvas.height = h1;
img.onload = function () {
var imgData;
svgBlob = null;
helpers.revokeObjectURL(url);
// don't need to draw to canvas if svg
// save some time and also avoid failure on IE
if (format !== 'svg') {
ctx.drawImage(img, 0, 0, w1, h1);
}
switch (format) {
case 'jpeg':
imgData = canvas.toDataURL('image/jpeg');
break;
case 'png':
imgData = canvas.toDataURL('image/png');
break;
case 'webp':
imgData = canvas.toDataURL('image/webp');
break;
case 'svg':
imgData = url;
break;
default:
var errorMsg = 'Image format is not jpeg, png, svg or webp.';
reject(new Error(errorMsg));
// eventually remove the ev
// in favor of promises
if (!opts.promise) {
return ev.emit('error', errorMsg);
}
}
resolve(imgData);
// eventually remove the ev
// in favor of promises
if (!opts.promise) {
ev.emit('success', imgData);
}
};
img.onerror = function (err) {
svgBlob = null;
helpers.revokeObjectURL(url);
reject(err);
// eventually remove the ev
// in favor of promises
if (!opts.promise) {
return ev.emit('error', err);
}
};
img.src = url;
});
// temporary for backward compatibility
// move to only Promise in 2.0.0
// and eliminate the EventEmitter
if (opts.promise) {
return promise;
}
return ev;
}
module.exports = svgToImg;
/***/ }),
/***/ 61808:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var EventEmitter = (__webpack_require__(61252).EventEmitter);
var Registry = __webpack_require__(24040);
var Lib = __webpack_require__(3400);
var helpers = __webpack_require__(81792);
var clonePlot = __webpack_require__(91536);
var toSVG = __webpack_require__(37164);
var svgToImg = __webpack_require__(63268);
/**
* @param {object} gd figure Object
* @param {object} opts option object
* @param opts.format 'jpeg' | 'png' | 'webp' | 'svg'
*/
function toImage(gd, opts) {
// first clone the GD so we can operate in a clean environment
var ev = new EventEmitter();
var clone = clonePlot(gd, {
format: 'png'
});
var clonedGd = clone.gd;
// put the cloned div somewhere off screen before attaching to DOM
clonedGd.style.position = 'absolute';
clonedGd.style.left = '-5000px';
document.body.appendChild(clonedGd);
function wait() {
var delay = helpers.getDelay(clonedGd._fullLayout);
setTimeout(function () {
var svg = toSVG(clonedGd);
var canvas = document.createElement('canvas');
canvas.id = Lib.randstr();
ev = svgToImg({
format: opts.format,
width: clonedGd._fullLayout.width,
height: clonedGd._fullLayout.height,
canvas: canvas,
emitter: ev,
svg: svg
});
ev.clean = function () {
if (clonedGd) document.body.removeChild(clonedGd);
};
}, delay);
}
var redrawFunc = helpers.getRedrawFunc(clonedGd);
Registry.call('_doPlot', clonedGd, clone.data, clone.layout, clone.config).then(redrawFunc).then(wait).catch(function (err) {
ev.emit('error', err);
});
return ev;
}
module.exports = toImage;
/***/ }),
/***/ 37164:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var d3 = __webpack_require__(33428);
var Lib = __webpack_require__(3400);
var Drawing = __webpack_require__(43616);
var Color = __webpack_require__(76308);
var xmlnsNamespaces = __webpack_require__(9616);
var DOUBLEQUOTE_REGEX = /"/g;
var DUMMY_SUB = 'TOBESTRIPPED';
var DUMMY_REGEX = new RegExp('("' + DUMMY_SUB + ')|(' + DUMMY_SUB + '")', 'g');
function htmlEntityDecode(s) {
var hiddenDiv = d3.select('body').append('div').style({
display: 'none'
}).html('');
var replaced = s.replace(/(&[^;]*;)/gi, function (d) {
if (d === '<') {
return '<';
} // special handling for brackets
if (d === '&rt;') {
return '>';
}
if (d.indexOf('<') !== -1 || d.indexOf('>') !== -1) {
return '';
}
return hiddenDiv.html(d).text(); // everything else, let the browser decode it to unicode
});
hiddenDiv.remove();
return replaced;
}
function xmlEntityEncode(str) {
return str.replace(/&(?!\w+;|\#[0-9]+;| \#x[0-9A-F]+;)/g, '&');
}
module.exports = function toSVG(gd, format, scale) {
var fullLayout = gd._fullLayout;
var svg = fullLayout._paper;
var toppaper = fullLayout._toppaper;
var width = fullLayout.width;
var height = fullLayout.height;
var i;
// make background color a rect in the svg, then revert after scraping
// all other alterations have been dealt with by properly preparing the svg
// in the first place... like setting cursors with css classes so we don't
// have to remove them, and providing the right namespaces in the svg to
// begin with
svg.insert('rect', ':first-child').call(Drawing.setRect, 0, 0, width, height).call(Color.fill, fullLayout.paper_bgcolor);
// subplot-specific to-SVG methods
// which notably add the contents of the gl-container
// into the main svg node
var basePlotModules = fullLayout._basePlotModules || [];
for (i = 0; i < basePlotModules.length; i++) {
var _module = basePlotModules[i];
if (_module.toSVG) _module.toSVG(gd);
}
// add top items above them assumes everything in toppaper is either
// a group or a defs, and if it's empty (like hoverlayer) we can ignore it.
if (toppaper) {
var nodes = toppaper.node().childNodes;
// make copy of nodes as childNodes prop gets mutated in loop below
var topGroups = Array.prototype.slice.call(nodes);
for (i = 0; i < topGroups.length; i++) {
var topGroup = topGroups[i];
if (topGroup.childNodes.length) svg.node().appendChild(topGroup);
}
}
// remove draglayer for Adobe Illustrator compatibility
if (fullLayout._draggers) {
fullLayout._draggers.remove();
}
// in case the svg element had an explicit background color, remove this
// we want the rect to get the color so it's the right size; svg bg will
// fill whatever container it's displayed in regardless of plot size.
svg.node().style.background = '';
svg.selectAll('text').attr({
'data-unformatted': null,
'data-math': null
}).each(function () {
var txt = d3.select(this);
// hidden text is pre-formatting mathjax, the browser ignores it
// but in a static plot it's useless and it can confuse batik
// we've tried to standardize on display:none but make sure we still
// catch visibility:hidden if it ever arises
if (this.style.visibility === 'hidden' || this.style.display === 'none') {
txt.remove();
return;
} else {
// clear other visibility/display values to default
// to not potentially confuse non-browser SVG implementations
txt.style({
visibility: null,
display: null
});
}
// Font family styles break things because of quotation marks,
// so we must remove them *after* the SVG DOM has been serialized
// to a string (browsers convert singles back)
var ff = this.style.fontFamily;
if (ff && ff.indexOf('"') !== -1) {
txt.style('font-family', ff.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
}
});
svg.selectAll('.gradient_filled,.pattern_filled').each(function () {
var pt = d3.select(this);
// similar to font family styles above,
// we must remove " after the SVG DOM has been serialized
var fill = this.style.fill;
if (fill && fill.indexOf('url(') !== -1) {
pt.style('fill', fill.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
}
var stroke = this.style.stroke;
if (stroke && stroke.indexOf('url(') !== -1) {
pt.style('stroke', stroke.replace(DOUBLEQUOTE_REGEX, DUMMY_SUB));
}
});
if (format === 'pdf' || format === 'eps') {
// these formats make the extra line MathJax adds around symbols look super thick in some cases
// it looks better if this is removed entirely.
svg.selectAll('#MathJax_SVG_glyphs path').attr('stroke-width', 0);
}
// fix for IE namespacing quirk?
// http://stackoverflow.com/questions/19610089/unwanted-namespaces-on-svg-markup-when-using-xmlserializer-in-javascript-with-ie
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns', xmlnsNamespaces.svg);
svg.node().setAttributeNS(xmlnsNamespaces.xmlns, 'xmlns:xlink', xmlnsNamespaces.xlink);
if (format === 'svg' && scale) {
svg.attr('width', scale * width);
svg.attr('height', scale * height);
svg.attr('viewBox', '0 0 ' + width + ' ' + height);
}
var s = new window.XMLSerializer().serializeToString(svg.node());
s = htmlEntityDecode(s);
s = xmlEntityEncode(s);
// Fix quotations around font strings and gradient URLs
s = s.replace(DUMMY_REGEX, '\'');
// Do we need this process now that IE9 and IE10 are not supported?
// IE is very strict, so we will need to clean
// svg with the following regex
// yes this is messy, but do not know a better way
// Even with this IE will not work due to tainted canvas
// see https://github.com/kangax/fabric.js/issues/1957
// http://stackoverflow.com/questions/18112047/canvas-todataurl-working-in-all-browsers-except-ie10
// Leave here just in case the CORS/tainted IE issue gets resolved
if (Lib.isIE()) {
// replace double quote with single quote
s = s.replace(/"/gi, '\'');
// url in svg are single quoted
// since we changed double to single
// we'll need to change these to double-quoted
s = s.replace(/(\('#)([^']*)('\))/gi, '(\"#$2\")');
// font names with spaces will be escaped single-quoted
// we'll need to change these to double-quoted
s = s.replace(/(\\')/gi, '\"');
}
return s;
};
/***/ }),
/***/ 84664:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
// arrayOk attributes, merge them into calcdata array
module.exports = function arraysToCalcdata(cd, trace) {
for (var i = 0; i < cd.length; i++) cd[i].i = i;
Lib.mergeArray(trace.text, cd, 'tx');
Lib.mergeArray(trace.hovertext, cd, 'htx');
var marker = trace.marker;
if (marker) {
Lib.mergeArray(marker.opacity, cd, 'mo', true);
Lib.mergeArray(marker.color, cd, 'mc');
var markerLine = marker.line;
if (markerLine) {
Lib.mergeArray(markerLine.color, cd, 'mlc');
Lib.mergeArrayCastPositive(markerLine.width, cd, 'mlw');
}
}
};
/***/ }),
/***/ 96376:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
var isArrayOrTypedArray = (__webpack_require__(3400).isArrayOrTypedArray);
var BADNUM = (__webpack_require__(39032).BADNUM);
var Registry = __webpack_require__(24040);
var Axes = __webpack_require__(54460);
var getAxisGroup = (__webpack_require__(71888).getAxisGroup);
var Sieve = __webpack_require__(72592);
/*
* Bar chart stacking/grouping positioning and autoscaling calculations
* for each direction separately calculate the ranges and positions
* note that this handles histograms too
* now doing this one subplot at a time
*/
function crossTraceCalc(gd, plotinfo) {
var xa = plotinfo.xaxis;
var ya = plotinfo.yaxis;
var fullLayout = gd._fullLayout;
var fullTraces = gd._fullData;
var calcTraces = gd.calcdata;
var calcTracesHorz = [];
var calcTracesVert = [];
for (var i = 0; i < fullTraces.length; i++) {
var fullTrace = fullTraces[i];
if (fullTrace.visible === true && Registry.traceIs(fullTrace, 'bar') && fullTrace.xaxis === xa._id && fullTrace.yaxis === ya._id) {
if (fullTrace.orientation === 'h') {
calcTracesHorz.push(calcTraces[i]);
} else {
calcTracesVert.push(calcTraces[i]);
}
if (fullTrace._computePh) {
var cd = gd.calcdata[i];
for (var j = 0; j < cd.length; j++) {
if (typeof cd[j].ph0 === 'function') cd[j].ph0 = cd[j].ph0();
if (typeof cd[j].ph1 === 'function') cd[j].ph1 = cd[j].ph1();
}
}
}
}
var opts = {
xCat: xa.type === 'category' || xa.type === 'multicategory',
yCat: ya.type === 'category' || ya.type === 'multicategory',
mode: fullLayout.barmode,
norm: fullLayout.barnorm,
gap: fullLayout.bargap,
groupgap: fullLayout.bargroupgap
};
setGroupPositions(gd, xa, ya, calcTracesVert, opts);
setGroupPositions(gd, ya, xa, calcTracesHorz, opts);
}
function setGroupPositions(gd, pa, sa, calcTraces, opts) {
if (!calcTraces.length) return;
var excluded;
var included;
var i, calcTrace, fullTrace;
initBase(sa, calcTraces);
switch (opts.mode) {
case 'overlay':
setGroupPositionsInOverlayMode(pa, sa, calcTraces, opts);
break;
case 'group':
// exclude from the group those traces for which the user set an offset
excluded = [];
included = [];
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
fullTrace = calcTrace[0].trace;
if (fullTrace.offset === undefined) included.push(calcTrace);else excluded.push(calcTrace);
}
if (included.length) {
setGroupPositionsInGroupMode(gd, pa, sa, included, opts);
}
if (excluded.length) {
setGroupPositionsInOverlayMode(pa, sa, excluded, opts);
}
break;
case 'stack':
case 'relative':
// exclude from the stack those traces for which the user set a base
excluded = [];
included = [];
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
fullTrace = calcTrace[0].trace;
if (fullTrace.base === undefined) included.push(calcTrace);else excluded.push(calcTrace);
}
// If any trace in `included` has a cornerradius, set cornerradius of all bars
// in `included` to match the first trace which has a cornerradius
standardizeCornerradius(included);
if (included.length) {
setGroupPositionsInStackOrRelativeMode(gd, pa, sa, included, opts);
}
if (excluded.length) {
setGroupPositionsInOverlayMode(pa, sa, excluded, opts);
}
break;
}
setCornerradius(calcTraces);
collectExtents(calcTraces, pa);
}
// Set cornerradiusvalue and cornerradiusform in calcTraces[0].t
function setCornerradius(calcTraces) {
var i, calcTrace, fullTrace, t, cr, crValue, crForm;
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
fullTrace = calcTrace[0].trace;
t = calcTrace[0].t;
if (t.cornerradiusvalue === undefined) {
cr = fullTrace.marker ? fullTrace.marker.cornerradius : undefined;
if (cr !== undefined) {
crValue = isNumeric(cr) ? +cr : +cr.slice(0, -1);
crForm = isNumeric(cr) ? 'px' : '%';
t.cornerradiusvalue = crValue;
t.cornerradiusform = crForm;
}
}
}
}
// Make sure all traces in a stack use the same cornerradius
function standardizeCornerradius(calcTraces) {
if (calcTraces.length < 2) return;
var i, calcTrace, fullTrace, t;
var cr, crValue, crForm;
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
fullTrace = calcTrace[0].trace;
cr = fullTrace.marker ? fullTrace.marker.cornerradius : undefined;
if (cr !== undefined) break;
}
// If any trace has cornerradius, store first cornerradius
// in calcTrace[0].t so that all traces in stack use same cornerradius
if (cr !== undefined) {
crValue = isNumeric(cr) ? +cr : +cr.slice(0, -1);
crForm = isNumeric(cr) ? 'px' : '%';
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
t = calcTrace[0].t;
t.cornerradiusvalue = crValue;
t.cornerradiusform = crForm;
}
}
}
function initBase(sa, calcTraces) {
var i, j;
for (i = 0; i < calcTraces.length; i++) {
var cd = calcTraces[i];
var trace = cd[0].trace;
var base = trace.type === 'funnel' ? trace._base : trace.base;
var b;
// not sure if it really makes sense to have dates for bar size data...
// ideally if we want to make gantt charts or something we'd treat
// the actual size (trace.x or y) as time delta but base as absolute
// time. But included here for completeness.
var scalendar = trace.orientation === 'h' ? trace.xcalendar : trace.ycalendar;
// 'base' on categorical axes makes no sense
var d2c = sa.type === 'category' || sa.type === 'multicategory' ? function () {
return null;
} : sa.d2c;
if (isArrayOrTypedArray(base)) {
for (j = 0; j < Math.min(base.length, cd.length); j++) {
b = d2c(base[j], 0, scalendar);
if (isNumeric(b)) {
cd[j].b = +b;
cd[j].hasB = 1;
} else cd[j].b = 0;
}
for (; j < cd.length; j++) {
cd[j].b = 0;
}
} else {
b = d2c(base, 0, scalendar);
var hasBase = isNumeric(b);
b = hasBase ? b : 0;
for (j = 0; j < cd.length; j++) {
cd[j].b = b;
if (hasBase) cd[j].hasB = 1;
}
}
}
}
function setGroupPositionsInOverlayMode(pa, sa, calcTraces, opts) {
// update position axis and set bar offsets and widths
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var sieve = new Sieve([calcTrace], {
posAxis: pa,
sepNegVal: false,
overlapNoMerge: !opts.norm
});
// set bar offsets and widths, and update position axis
setOffsetAndWidth(pa, sieve, opts);
// set bar bases and sizes, and update size axis
//
// (note that `setGroupPositionsInOverlayMode` handles the case barnorm
// is defined, because this function is also invoked for traces that
// can't be grouped or stacked)
if (opts.norm) {
sieveBars(sieve);
normalizeBars(sa, sieve, opts);
} else {
setBaseAndTop(sa, sieve);
}
}
}
function setGroupPositionsInGroupMode(gd, pa, sa, calcTraces, opts) {
var sieve = new Sieve(calcTraces, {
posAxis: pa,
sepNegVal: false,
overlapNoMerge: !opts.norm
});
// set bar offsets and widths, and update position axis
setOffsetAndWidthInGroupMode(gd, pa, sieve, opts);
// relative-stack bars within the same trace that would otherwise
// be hidden
unhideBarsWithinTrace(sieve, pa);
// set bar bases and sizes, and update size axis
if (opts.norm) {
sieveBars(sieve);
normalizeBars(sa, sieve, opts);
} else {
setBaseAndTop(sa, sieve);
}
}
function setGroupPositionsInStackOrRelativeMode(gd, pa, sa, calcTraces, opts) {
var sieve = new Sieve(calcTraces, {
posAxis: pa,
sepNegVal: opts.mode === 'relative',
overlapNoMerge: !(opts.norm || opts.mode === 'stack' || opts.mode === 'relative')
});
// set bar offsets and widths, and update position axis
setOffsetAndWidth(pa, sieve, opts);
// set bar bases and sizes, and update size axis
stackBars(sa, sieve, opts);
// flag the outmost bar (for text display purposes)
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
for (var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
if (bar.s !== BADNUM) {
var isOutmostBar = bar.b + bar.s === sieve.get(bar.p, bar.s);
if (isOutmostBar) bar._outmost = true;
}
}
}
// Note that marking the outmost bars has to be done
// before `normalizeBars` changes `bar.b` and `bar.s`.
if (opts.norm) normalizeBars(sa, sieve, opts);
}
function setOffsetAndWidth(pa, sieve, opts) {
var minDiff = sieve.minDiff;
var calcTraces = sieve.traces;
// set bar offsets and widths
var barGroupWidth = minDiff * (1 - opts.gap);
var barWidthPlusGap = barGroupWidth;
var barWidth = barWidthPlusGap * (1 - (opts.groupgap || 0));
// computer bar group center and bar offset
var offsetFromCenter = -barWidth / 2;
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var t = calcTrace[0].t;
// store bar width and offset for this trace
t.barwidth = barWidth;
t.poffset = offsetFromCenter;
t.bargroupwidth = barGroupWidth;
t.bardelta = minDiff;
}
// stack bars that only differ by rounding
sieve.binWidth = calcTraces[0][0].t.barwidth / 100;
// if defined, apply trace offset and width
applyAttributes(sieve);
// store the bar center in each calcdata item
setBarCenterAndWidth(pa, sieve);
// update position axes
updatePositionAxis(pa, sieve);
}
function setOffsetAndWidthInGroupMode(gd, pa, sieve, opts) {
var fullLayout = gd._fullLayout;
var positions = sieve.positions;
var distinctPositions = sieve.distinctPositions;
var minDiff = sieve.minDiff;
var calcTraces = sieve.traces;
var nTraces = calcTraces.length;
// if there aren't any overlapping positions,
// let them have full width even if mode is group
var overlap = positions.length !== distinctPositions.length;
var barGroupWidth = minDiff * (1 - opts.gap);
var groupId = getAxisGroup(fullLayout, pa._id) + calcTraces[0][0].trace.orientation;
var alignmentGroups = fullLayout._alignmentOpts[groupId] || {};
for (var i = 0; i < nTraces; i++) {
var calcTrace = calcTraces[i];
var trace = calcTrace[0].trace;
var alignmentGroupOpts = alignmentGroups[trace.alignmentgroup] || {};
var nOffsetGroups = Object.keys(alignmentGroupOpts.offsetGroups || {}).length;
var barWidthPlusGap;
if (nOffsetGroups) {
barWidthPlusGap = barGroupWidth / nOffsetGroups;
} else {
barWidthPlusGap = overlap ? barGroupWidth / nTraces : barGroupWidth;
}
var barWidth = barWidthPlusGap * (1 - (opts.groupgap || 0));
var offsetFromCenter;
if (nOffsetGroups) {
offsetFromCenter = ((2 * trace._offsetIndex + 1 - nOffsetGroups) * barWidthPlusGap - barWidth) / 2;
} else {
offsetFromCenter = overlap ? ((2 * i + 1 - nTraces) * barWidthPlusGap - barWidth) / 2 : -barWidth / 2;
}
var t = calcTrace[0].t;
t.barwidth = barWidth;
t.poffset = offsetFromCenter;
t.bargroupwidth = barGroupWidth;
t.bardelta = minDiff;
}
// stack bars that only differ by rounding
sieve.binWidth = calcTraces[0][0].t.barwidth / 100;
// if defined, apply trace width
applyAttributes(sieve);
// store the bar center in each calcdata item
setBarCenterAndWidth(pa, sieve);
// update position axes
updatePositionAxis(pa, sieve, overlap);
}
function applyAttributes(sieve) {
var calcTraces = sieve.traces;
var i, j;
for (i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var calcTrace0 = calcTrace[0];
var fullTrace = calcTrace0.trace;
var t = calcTrace0.t;
var offset = fullTrace._offset || fullTrace.offset;
var initialPoffset = t.poffset;
var newPoffset;
if (isArrayOrTypedArray(offset)) {
// if offset is an array, then clone it into t.poffset.
newPoffset = Array.prototype.slice.call(offset, 0, calcTrace.length);
// guard against non-numeric items
for (j = 0; j < newPoffset.length; j++) {
if (!isNumeric(newPoffset[j])) {
newPoffset[j] = initialPoffset;
}
}
// if the length of the array is too short,
// then extend it with the initial value of t.poffset
for (j = newPoffset.length; j < calcTrace.length; j++) {
newPoffset.push(initialPoffset);
}
t.poffset = newPoffset;
} else if (offset !== undefined) {
t.poffset = offset;
}
var width = fullTrace._width || fullTrace.width;
var initialBarwidth = t.barwidth;
if (isArrayOrTypedArray(width)) {
// if width is an array, then clone it into t.barwidth.
var newBarwidth = Array.prototype.slice.call(width, 0, calcTrace.length);
// guard against non-numeric items
for (j = 0; j < newBarwidth.length; j++) {
if (!isNumeric(newBarwidth[j])) newBarwidth[j] = initialBarwidth;
}
// if the length of the array is too short,
// then extend it with the initial value of t.barwidth
for (j = newBarwidth.length; j < calcTrace.length; j++) {
newBarwidth.push(initialBarwidth);
}
t.barwidth = newBarwidth;
// if user didn't set offset,
// then correct t.poffset to ensure bars remain centered
if (offset === undefined) {
newPoffset = [];
for (j = 0; j < calcTrace.length; j++) {
newPoffset.push(initialPoffset + (initialBarwidth - newBarwidth[j]) / 2);
}
t.poffset = newPoffset;
}
} else if (width !== undefined) {
t.barwidth = width;
// if user didn't set offset,
// then correct t.poffset to ensure bars remain centered
if (offset === undefined) {
t.poffset = initialPoffset + (initialBarwidth - width) / 2;
}
}
}
}
function setBarCenterAndWidth(pa, sieve) {
var calcTraces = sieve.traces;
var pLetter = getAxisLetter(pa);
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var t = calcTrace[0].t;
var poffset = t.poffset;
var poffsetIsArray = isArrayOrTypedArray(poffset);
var barwidth = t.barwidth;
var barwidthIsArray = isArrayOrTypedArray(barwidth);
for (var j = 0; j < calcTrace.length; j++) {
var calcBar = calcTrace[j];
// store the actual bar width and position, for use by hover
var width = calcBar.w = barwidthIsArray ? barwidth[j] : barwidth;
if (calcBar.p === undefined) {
calcBar.p = calcBar[pLetter];
calcBar['orig_' + pLetter] = calcBar[pLetter];
}
var delta = (poffsetIsArray ? poffset[j] : poffset) + width / 2;
calcBar[pLetter] = calcBar.p + delta;
}
}
}
function updatePositionAxis(pa, sieve, allowMinDtick) {
var calcTraces = sieve.traces;
var minDiff = sieve.minDiff;
var vpad = minDiff / 2;
Axes.minDtick(pa, sieve.minDiff, sieve.distinctPositions[0], allowMinDtick);
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var calcTrace0 = calcTrace[0];
var fullTrace = calcTrace0.trace;
var pts = [];
var bar, l, r, j;
for (j = 0; j < calcTrace.length; j++) {
bar = calcTrace[j];
l = bar.p - vpad;
r = bar.p + vpad;
pts.push(l, r);
}
if (fullTrace.width || fullTrace.offset) {
var t = calcTrace0.t;
var poffset = t.poffset;
var barwidth = t.barwidth;
var poffsetIsArray = isArrayOrTypedArray(poffset);
var barwidthIsArray = isArrayOrTypedArray(barwidth);
for (j = 0; j < calcTrace.length; j++) {
bar = calcTrace[j];
var calcBarOffset = poffsetIsArray ? poffset[j] : poffset;
var calcBarWidth = barwidthIsArray ? barwidth[j] : barwidth;
l = bar.p + calcBarOffset;
r = l + calcBarWidth;
pts.push(l, r);
}
}
fullTrace._extremes[pa._id] = Axes.findExtremes(pa, pts, {
padded: false
});
}
}
// store these bar bases and tops in calcdata
// and make sure the size axis includes zero,
// along with the bases and tops of each bar.
function setBaseAndTop(sa, sieve) {
var calcTraces = sieve.traces;
var sLetter = getAxisLetter(sa);
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var fullTrace = calcTrace[0].trace;
var isScatter = fullTrace.type === 'scatter';
var isVertical = fullTrace.orientation === 'v';
var pts = [];
var tozero = false;
for (var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
var base = isScatter ? 0 : bar.b;
var top = isScatter ? isVertical ? bar.y : bar.x : base + bar.s;
bar[sLetter] = top;
pts.push(top);
if (bar.hasB) pts.push(base);
if (!bar.hasB || !bar.b) {
tozero = true;
}
}
fullTrace._extremes[sa._id] = Axes.findExtremes(sa, pts, {
tozero: tozero,
padded: true
});
}
}
function stackBars(sa, sieve, opts) {
var sLetter = getAxisLetter(sa);
var calcTraces = sieve.traces;
var calcTrace;
var fullTrace;
var isFunnel;
var i, j;
var bar;
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
fullTrace = calcTrace[0].trace;
if (fullTrace.type === 'funnel') {
for (j = 0; j < calcTrace.length; j++) {
bar = calcTrace[j];
if (bar.s !== BADNUM) {
// create base of funnels
sieve.put(bar.p, -0.5 * bar.s);
}
}
}
}
for (i = 0; i < calcTraces.length; i++) {
calcTrace = calcTraces[i];
fullTrace = calcTrace[0].trace;
isFunnel = fullTrace.type === 'funnel';
var pts = [];
for (j = 0; j < calcTrace.length; j++) {
bar = calcTrace[j];
if (bar.s !== BADNUM) {
// stack current bar and get previous sum
var value;
if (isFunnel) {
value = bar.s;
} else {
value = bar.s + bar.b;
}
var base = sieve.put(bar.p, value);
var top = base + value;
// store the bar base and top in each calcdata item
bar.b = base;
bar[sLetter] = top;
if (!opts.norm) {
pts.push(top);
if (bar.hasB) {
pts.push(base);
}
}
}
}
// if barnorm is set, let normalizeBars update the axis range
if (!opts.norm) {
fullTrace._extremes[sa._id] = Axes.findExtremes(sa, pts, {
// N.B. we don't stack base with 'base',
// so set tozero:true always!
tozero: true,
padded: true
});
}
}
}
function sieveBars(sieve) {
var calcTraces = sieve.traces;
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
for (var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
if (bar.s !== BADNUM) {
sieve.put(bar.p, bar.b + bar.s);
}
}
}
}
function unhideBarsWithinTrace(sieve, pa) {
var calcTraces = sieve.traces;
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var fullTrace = calcTrace[0].trace;
if (fullTrace.base === undefined) {
var inTraceSieve = new Sieve([calcTrace], {
posAxis: pa,
sepNegVal: true,
overlapNoMerge: true
});
for (var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
if (bar.p !== BADNUM) {
// stack current bar and get previous sum
var base = inTraceSieve.put(bar.p, bar.b + bar.s);
// if previous sum if non-zero, this means:
// multiple bars have same starting point are potentially hidden,
// shift them vertically so that all bars are visible by default
if (base) bar.b = base;
}
}
}
}
}
// Note:
//
// normalizeBars requires that either sieveBars or stackBars has been
// previously invoked.
function normalizeBars(sa, sieve, opts) {
var calcTraces = sieve.traces;
var sLetter = getAxisLetter(sa);
var sTop = opts.norm === 'fraction' ? 1 : 100;
var sTiny = sTop / 1e9; // in case of rounding error in sum
var sMin = sa.l2c(sa.c2l(0));
var sMax = opts.mode === 'stack' ? sTop : sMin;
function needsPadding(v) {
return isNumeric(sa.c2l(v)) && (v < sMin - sTiny || v > sMax + sTiny || !isNumeric(sMin));
}
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
var fullTrace = calcTrace[0].trace;
var pts = [];
var tozero = false;
var padded = false;
for (var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
if (bar.s !== BADNUM) {
var scale = Math.abs(sTop / sieve.get(bar.p, bar.s));
bar.b *= scale;
bar.s *= scale;
var base = bar.b;
var top = base + bar.s;
bar[sLetter] = top;
pts.push(top);
padded = padded || needsPadding(top);
if (bar.hasB) {
pts.push(base);
padded = padded || needsPadding(base);
}
if (!bar.hasB || !bar.b) {
tozero = true;
}
}
}
fullTrace._extremes[sa._id] = Axes.findExtremes(sa, pts, {
tozero: tozero,
padded: padded
});
}
}
// Add an `_sMin` and `_sMax` value for each bar representing the min and max size value
// across all bars sharing the same position as that bar. These values are used for rounded
// bar corners, to carry rounding down to lower bars in the stack as needed.
function setHelperValuesForRoundedCorners(calcTraces, sMinByPos, sMaxByPos, pa) {
var pLetter = getAxisLetter(pa);
// Set `_sMin` and `_sMax` value for each bar
for (var i = 0; i < calcTraces.length; i++) {
var calcTrace = calcTraces[i];
for (var j = 0; j < calcTrace.length; j++) {
var bar = calcTrace[j];
var pos = bar[pLetter];
bar._sMin = sMinByPos[pos];
bar._sMax = sMaxByPos[pos];
}
}
}
// find the full position span of bars at each position
// for use by hover, to ensure labels move in if bars are
// narrower than the space they're in.
// run once per trace group (subplot & direction) and
// the same mapping is attached to all calcdata traces
function collectExtents(calcTraces, pa) {
var pLetter = getAxisLetter(pa);
var extents = {};
var i, j, cd;
var pMin = Infinity;
var pMax = -Infinity;
for (i = 0; i < calcTraces.length; i++) {
cd = calcTraces[i];
for (j = 0; j < cd.length; j++) {
var p = cd[j].p;
if (isNumeric(p)) {
pMin = Math.min(pMin, p);
pMax = Math.max(pMax, p);
}
}
}
// this is just for positioning of hover labels, and nobody will care if
// the label is 1px too far out; so round positions to 1/10K in case
// position values don't exactly match from trace to trace
var roundFactor = 10000 / (pMax - pMin);
var round = extents.round = function (p) {
return String(Math.round(roundFactor * (p - pMin)));
};
// Find min and max size axis extent for each position
// This is used for rounded bar corners, to carry rounding
// down to lower bars in the case of stacked bars
var sMinByPos = {};
var sMaxByPos = {};
// Check whether any trace has rounded corners
var anyTraceHasCornerradius = calcTraces.some(function (x) {
var trace = x[0].trace;
return 'marker' in trace && trace.marker.cornerradius;
});
for (i = 0; i < calcTraces.length; i++) {
cd = calcTraces[i];
cd[0].t.extents = extents;
var poffset = cd[0].t.poffset;
var poffsetIsArray = isArrayOrTypedArray(poffset);
for (j = 0; j < cd.length; j++) {
var di = cd[j];
var p0 = di[pLetter] - di.w / 2;
if (isNumeric(p0)) {
var p1 = di[pLetter] + di.w / 2;
var pVal = round(di.p);
if (extents[pVal]) {
extents[pVal] = [Math.min(p0, extents[pVal][0]), Math.max(p1, extents[pVal][1])];
} else {
extents[pVal] = [p0, p1];
}
}
di.p0 = di.p + (poffsetIsArray ? poffset[j] : poffset);
di.p1 = di.p0 + di.w;
di.s0 = di.b;
di.s1 = di.s0 + di.s;
if (anyTraceHasCornerradius) {
var sMin = Math.min(di.s0, di.s1) || 0;
var sMax = Math.max(di.s0, di.s1) || 0;
var pos = di[pLetter];
sMinByPos[pos] = pos in sMinByPos ? Math.min(sMinByPos[pos], sMin) : sMin;
sMaxByPos[pos] = pos in sMaxByPos ? Math.max(sMaxByPos[pos], sMax) : sMax;
}
}
}
if (anyTraceHasCornerradius) {
setHelperValuesForRoundedCorners(calcTraces, sMinByPos, sMaxByPos, pa);
}
}
function getAxisLetter(ax) {
return ax._id.charAt(0);
}
module.exports = {
crossTraceCalc: crossTraceCalc,
setGroupPositions: setGroupPositions
};
/***/ }),
/***/ 72592:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
module.exports = Sieve;
var distinctVals = (__webpack_require__(3400).distinctVals);
/**
* Helper class to sieve data from traces into bins
*
* @class
*
* @param {Array} traces
* Array of calculated traces
* @param {object} opts
* - @param {boolean} [sepNegVal]
* If true, then split data at the same position into a bar
* for positive values and another for negative values
* - @param {boolean} [overlapNoMerge]
* If true, then don't merge overlapping bars into a single bar
*/
function Sieve(traces, opts) {
this.traces = traces;
this.sepNegVal = opts.sepNegVal;
this.overlapNoMerge = opts.overlapNoMerge;
// for single-bin histograms - see histogram/calc
var width1 = Infinity;
var axLetter = opts.posAxis._id.charAt(0);
var positions = [];
for (var i = 0; i < traces.length; i++) {
var trace = traces[i];
for (var j = 0; j < trace.length; j++) {
var bar = trace[j];
var pos = bar.p;
if (pos === undefined) {
pos = bar[axLetter];
}
if (pos !== undefined) positions.push(pos);
}
if (trace[0] && trace[0].width1) {
width1 = Math.min(trace[0].width1, width1);
}
}
this.positions = positions;
var dv = distinctVals(positions);
this.distinctPositions = dv.vals;
if (dv.vals.length === 1 && width1 !== Infinity) this.minDiff = width1;else this.minDiff = Math.min(dv.minDiff, width1);
var type = (opts.posAxis || {}).type;
if (type === 'category' || type === 'multicategory') {
this.minDiff = 1;
}
this.binWidth = this.minDiff;
this.bins = {};
}
/**
* Sieve datum
*
* @method
* @param {number} position
* @param {number} value
* @returns {number} Previous bin value
*/
Sieve.prototype.put = function put(position, value) {
var label = this.getLabel(position, value);
var oldValue = this.bins[label] || 0;
this.bins[label] = oldValue + value;
return oldValue;
};
/**
* Get current bin value for a given datum
*
* @method
* @param {number} position Position of datum
* @param {number} [value] Value of datum
* (required if this.sepNegVal is true)
* @returns {number} Current bin value
*/
Sieve.prototype.get = function get(position, value) {
var label = this.getLabel(position, value);
return this.bins[label] || 0;
};
/**
* Get bin label for a given datum
*
* @method
* @param {number} position Position of datum
* @param {number} [value] Value of datum
* (required if this.sepNegVal is true)
* @returns {string} Bin label
* (prefixed with a 'v' if value is negative and this.sepNegVal is
* true; otherwise prefixed with '^')
*/
Sieve.prototype.getLabel = function getLabel(position, value) {
var prefix = value < 0 && this.sepNegVal ? 'v' : '^';
var label = this.overlapNoMerge ? position : Math.round(position / this.binWidth);
return prefix + label;
};
/***/ }),
/***/ 83328:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var scatterAttrs = __webpack_require__(52904);
var baseAttrs = __webpack_require__(45464);
var fontAttrs = __webpack_require__(25376);
var axisHoverFormat = (__webpack_require__(29736).axisHoverFormat);
var hovertemplateAttrs = (__webpack_require__(21776)/* .hovertemplateAttrs */ .Ks);
var texttemplateAttrs = (__webpack_require__(21776)/* .texttemplateAttrs */ .Gw);
var colorScaleAttrs = __webpack_require__(49084);
var extendFlat = (__webpack_require__(92880).extendFlat);
module.exports = extendFlat({
z: {
valType: 'data_array',
editType: 'calc'
},
x: extendFlat({}, scatterAttrs.x, {
impliedEdits: {
xtype: 'array'
}
}),
x0: extendFlat({}, scatterAttrs.x0, {
impliedEdits: {
xtype: 'scaled'
}
}),
dx: extendFlat({}, scatterAttrs.dx, {
impliedEdits: {
xtype: 'scaled'
}
}),
y: extendFlat({}, scatterAttrs.y, {
impliedEdits: {
ytype: 'array'
}
}),
y0: extendFlat({}, scatterAttrs.y0, {
impliedEdits: {
ytype: 'scaled'
}
}),
dy: extendFlat({}, scatterAttrs.dy, {
impliedEdits: {
ytype: 'scaled'
}
}),
xperiod: extendFlat({}, scatterAttrs.xperiod, {
impliedEdits: {
xtype: 'scaled'
}
}),
yperiod: extendFlat({}, scatterAttrs.yperiod, {
impliedEdits: {
ytype: 'scaled'
}
}),
xperiod0: extendFlat({}, scatterAttrs.xperiod0, {
impliedEdits: {
xtype: 'scaled'
}
}),
yperiod0: extendFlat({}, scatterAttrs.yperiod0, {
impliedEdits: {
ytype: 'scaled'
}
}),
xperiodalignment: extendFlat({}, scatterAttrs.xperiodalignment, {
impliedEdits: {
xtype: 'scaled'
}
}),
yperiodalignment: extendFlat({}, scatterAttrs.yperiodalignment, {
impliedEdits: {
ytype: 'scaled'
}
}),
text: {
valType: 'data_array',
editType: 'calc'
},
hovertext: {
valType: 'data_array',
editType: 'calc'
},
transpose: {
valType: 'boolean',
dflt: false,
editType: 'calc'
},
xtype: {
valType: 'enumerated',
values: ['array', 'scaled'],
editType: 'calc+clearAxisTypes'
},
ytype: {
valType: 'enumerated',
values: ['array', 'scaled'],
editType: 'calc+clearAxisTypes'
},
zsmooth: {
valType: 'enumerated',
values: ['fast', 'best', false],
dflt: false,
editType: 'calc'
},
hoverongaps: {
valType: 'boolean',
dflt: true,
editType: 'none'
},
connectgaps: {
valType: 'boolean',
editType: 'calc'
},
xgap: {
valType: 'number',
dflt: 0,
min: 0,
editType: 'plot'
},
ygap: {
valType: 'number',
dflt: 0,
min: 0,
editType: 'plot'
},
xhoverformat: axisHoverFormat('x'),
yhoverformat: axisHoverFormat('y'),
zhoverformat: axisHoverFormat('z', 1),
hovertemplate: hovertemplateAttrs(),
texttemplate: texttemplateAttrs({
arrayOk: false,
editType: 'plot'
}, {
keys: ['x', 'y', 'z', 'text']
}),
textfont: fontAttrs({
editType: 'plot',
autoSize: true,
autoColor: true,
colorEditType: 'style'
}),
showlegend: extendFlat({}, baseAttrs.showlegend, {
dflt: false
}),
zorder: scatterAttrs.zorder
}, {
transforms: undefined
}, colorScaleAttrs('', {
cLetter: 'z',
autoColorDflt: false
}));
/***/ }),
/***/ 19512:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Registry = __webpack_require__(24040);
var Lib = __webpack_require__(3400);
var Axes = __webpack_require__(54460);
var alignPeriod = __webpack_require__(1220);
var histogram2dCalc = __webpack_require__(55480);
var colorscaleCalc = __webpack_require__(47128);
var convertColumnData = __webpack_require__(2872);
var clean2dArray = __webpack_require__(26136);
var interp2d = __webpack_require__(70448);
var findEmpties = __webpack_require__(11240);
var makeBoundArray = __webpack_require__(35744);
var BADNUM = (__webpack_require__(39032).BADNUM);
module.exports = function calc(gd, trace) {
// prepare the raw data
// run makeCalcdata on x and y even for heatmaps, in case of category mappings
var xa = Axes.getFromId(gd, trace.xaxis || 'x');
var ya = Axes.getFromId(gd, trace.yaxis || 'y');
var isContour = Registry.traceIs(trace, 'contour');
var isHist = Registry.traceIs(trace, 'histogram');
var isGL2D = Registry.traceIs(trace, 'gl2d');
var zsmooth = isContour ? 'best' : trace.zsmooth;
var x, x0, dx, origX;
var y, y0, dy, origY;
var z, i, binned;
// cancel minimum tick spacings (only applies to bars and boxes)
xa._minDtick = 0;
ya._minDtick = 0;
if (isHist) {
binned = histogram2dCalc(gd, trace);
origX = binned.orig_x;
x = binned.x;
x0 = binned.x0;
dx = binned.dx;
origY = binned.orig_y;
y = binned.y;
y0 = binned.y0;
dy = binned.dy;
z = binned.z;
} else {
var zIn = trace.z;
if (Lib.isArray1D(zIn)) {
convertColumnData(trace, xa, ya, 'x', 'y', ['z']);
x = trace._x;
y = trace._y;
zIn = trace._z;
} else {
origX = trace.x ? xa.makeCalcdata(trace, 'x') : [];
origY = trace.y ? ya.makeCalcdata(trace, 'y') : [];
x = alignPeriod(trace, xa, 'x', origX).vals;
y = alignPeriod(trace, ya, 'y', origY).vals;
trace._x = x;
trace._y = y;
}
x0 = trace.x0;
dx = trace.dx;
y0 = trace.y0;
dy = trace.dy;
z = clean2dArray(zIn, trace, xa, ya);
}
if (xa.rangebreaks || ya.rangebreaks) {
z = dropZonBreaks(x, y, z);
if (!isHist) {
x = skipBreaks(x);
y = skipBreaks(y);
trace._x = x;
trace._y = y;
}
}
if (!isHist && (isContour || trace.connectgaps)) {
trace._emptypoints = findEmpties(z);
interp2d(z, trace._emptypoints);
}
function noZsmooth(msg) {
zsmooth = trace._input.zsmooth = trace.zsmooth = false;
Lib.warn('cannot use zsmooth: "fast": ' + msg);
}
function scaleIsLinear(s) {
if (s.length > 1) {
var avgdx = (s[s.length - 1] - s[0]) / (s.length - 1);
var maxErrX = Math.abs(avgdx / 100);
for (i = 0; i < s.length - 1; i++) {
if (Math.abs(s[i + 1] - s[i] - avgdx) > maxErrX) {
return false;
}
}
}
return true;
}
// Check whether all brick are uniform
trace._islinear = false;
if (xa.type === 'log' || ya.type === 'log') {
if (zsmooth === 'fast') {
noZsmooth('log axis found');
}
} else if (!scaleIsLinear(x)) {
if (zsmooth === 'fast') noZsmooth('x scale is not linear');
} else if (!scaleIsLinear(y)) {
if (zsmooth === 'fast') noZsmooth('y scale is not linear');
} else {
trace._islinear = true;
}
// create arrays of brick boundaries, to be used by autorange and heatmap.plot
var xlen = Lib.maxRowLength(z);
var xIn = trace.xtype === 'scaled' ? '' : x;
var xArray = makeBoundArray(trace, xIn, x0, dx, xlen, xa);
var yIn = trace.ytype === 'scaled' ? '' : y;
var yArray = makeBoundArray(trace, yIn, y0, dy, z.length, ya);
// handled in gl2d convert step
if (!isGL2D) {
trace._extremes[xa._id] = Axes.findExtremes(xa, xArray);
trace._extremes[ya._id] = Axes.findExtremes(ya, yArray);
}
var cd0 = {
x: xArray,
y: yArray,
z: z,
text: trace._text || trace.text,
hovertext: trace._hovertext || trace.hovertext
};
if (trace.xperiodalignment && origX) {
cd0.orig_x = origX;
}
if (trace.yperiodalignment && origY) {
cd0.orig_y = origY;
}
if (xIn && xIn.length === xArray.length - 1) cd0.xCenter = xIn;
if (yIn && yIn.length === yArray.length - 1) cd0.yCenter = yIn;
if (isHist) {
cd0.xRanges = binned.xRanges;
cd0.yRanges = binned.yRanges;
cd0.pts = binned.pts;
}
if (!isContour) {
colorscaleCalc(gd, trace, {
vals: z,
cLetter: 'z'
});
}
if (isContour && trace.contours && trace.contours.coloring === 'heatmap') {
var dummyTrace = {
type: trace.type === 'contour' ? 'heatmap' : 'histogram2d',
xcalendar: trace.xcalendar,
ycalendar: trace.ycalendar
};
cd0.xfill = makeBoundArray(dummyTrace, xIn, x0, dx, xlen, xa);
cd0.yfill = makeBoundArray(dummyTrace, yIn, y0, dy, z.length, ya);
}
return [cd0];
};
function skipBreaks(a) {
var b = [];
var len = a.length;
for (var i = 0; i < len; i++) {
var v = a[i];
if (v !== BADNUM) b.push(v);
}
return b;
}
function dropZonBreaks(x, y, z) {
var newZ = [];
var k = -1;
for (var i = 0; i < z.length; i++) {
if (y[i] === BADNUM) continue;
k++;
newZ[k] = [];
for (var j = 0; j < z[i].length; j++) {
if (x[j] === BADNUM) continue;
newZ[k].push(z[i][j]);
}
}
return newZ;
}
/***/ }),
/***/ 26136:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
var Lib = __webpack_require__(3400);
var BADNUM = (__webpack_require__(39032).BADNUM);
module.exports = function clean2dArray(zOld, trace, xa, ya) {
var rowlen, collen, getCollen, old2new, i, j;
function cleanZvalue(v) {
if (!isNumeric(v)) return undefined;
return +v;
}
if (trace && trace.transpose) {
rowlen = 0;
for (i = 0; i < zOld.length; i++) rowlen = Math.max(rowlen, zOld[i].length);
if (rowlen === 0) return false;
getCollen = function (zOld) {
return zOld.length;
};
old2new = function (zOld, i, j) {
return (zOld[j] || [])[i];
};
} else {
rowlen = zOld.length;
getCollen = function (zOld, i) {
return zOld[i].length;
};
old2new = function (zOld, i, j) {
return (zOld[i] || [])[j];
};
}
var padOld2new = function (zOld, i, j) {
if (i === BADNUM || j === BADNUM) return BADNUM;
return old2new(zOld, i, j);
};
function axisMapping(ax) {
if (trace && trace.type !== 'carpet' && trace.type !== 'contourcarpet' && ax && ax.type === 'category' && trace['_' + ax._id.charAt(0)].length) {
var axLetter = ax._id.charAt(0);
var axMapping = {};
var traceCategories = trace['_' + axLetter + 'CategoryMap'] || trace[axLetter];
for (i = 0; i < traceCategories.length; i++) {
axMapping[traceCategories[i]] = i;
}
return function (i) {
var ind = axMapping[ax._categories[i]];
return ind + 1 ? ind : BADNUM;
};
} else {
return Lib.identity;
}
}
var xMap = axisMapping(xa);
var yMap = axisMapping(ya);
if (ya && ya.type === 'category') rowlen = ya._categories.length;
var zNew = new Array(rowlen);
for (i = 0; i < rowlen; i++) {
if (xa && xa.type === 'category') {
collen = xa._categories.length;
} else {
collen = getCollen(zOld, i);
}
zNew[i] = new Array(collen);
for (j = 0; j < collen; j++) zNew[i][j] = cleanZvalue(padOld2new(zOld, yMap(i), xMap(j)));
}
return zNew;
};
/***/ }),
/***/ 96288:
/***/ (function(module) {
"use strict";
module.exports = {
min: 'zmin',
max: 'zmax'
};
/***/ }),
/***/ 2872:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var BADNUM = (__webpack_require__(39032).BADNUM);
var alignPeriod = __webpack_require__(1220);
module.exports = function convertColumnData(trace, ax1, ax2, var1Name, var2Name, arrayVarNames) {
var colLen = trace._length;
var col1 = ax1.makeCalcdata(trace, var1Name);
var col2 = ax2.makeCalcdata(trace, var2Name);
col1 = alignPeriod(trace, ax1, var1Name, col1).vals;
col2 = alignPeriod(trace, ax2, var2Name, col2).vals;
var textCol = trace.text;
var hasColumnText = textCol !== undefined && Lib.isArray1D(textCol);
var hoverTextCol = trace.hovertext;
var hasColumnHoverText = hoverTextCol !== undefined && Lib.isArray1D(hoverTextCol);
var i, j;
var col1dv = Lib.distinctVals(col1);
var col1vals = col1dv.vals;
var col2dv = Lib.distinctVals(col2);
var col2vals = col2dv.vals;
var newArrays = [];
var text;
var hovertext;
var nI = col2vals.length;
var nJ = col1vals.length;
for (i = 0; i < arrayVarNames.length; i++) {
newArrays[i] = Lib.init2dArray(nI, nJ);
}
if (hasColumnText) {
text = Lib.init2dArray(nI, nJ);
}
if (hasColumnHoverText) {
hovertext = Lib.init2dArray(nI, nJ);
}
var after2before = Lib.init2dArray(nI, nJ);
for (i = 0; i < colLen; i++) {
if (col1[i] !== BADNUM && col2[i] !== BADNUM) {
var i1 = Lib.findBin(col1[i] + col1dv.minDiff / 2, col1vals);
var i2 = Lib.findBin(col2[i] + col2dv.minDiff / 2, col2vals);
for (j = 0; j < arrayVarNames.length; j++) {
var arrayVarName = arrayVarNames[j];
var arrayVar = trace[arrayVarName];
var newArray = newArrays[j];
newArray[i2][i1] = arrayVar[i];
after2before[i2][i1] = i;
}
if (hasColumnText) text[i2][i1] = textCol[i];
if (hasColumnHoverText) hovertext[i2][i1] = hoverTextCol[i];
}
}
trace['_' + var1Name] = col1vals;
trace['_' + var2Name] = col2vals;
for (j = 0; j < arrayVarNames.length; j++) {
trace['_' + arrayVarNames[j]] = newArrays[j];
}
if (hasColumnText) trace._text = text;
if (hasColumnHoverText) trace._hovertext = hovertext;
if (ax1 && ax1.type === 'category') {
trace['_' + var1Name + 'CategoryMap'] = col1vals.map(function (v) {
return ax1._categories[v];
});
}
if (ax2 && ax2.type === 'category') {
trace['_' + var2Name + 'CategoryMap'] = col2vals.map(function (v) {
return ax2._categories[v];
});
}
trace._after2before = after2before;
};
/***/ }),
/***/ 11240:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var maxRowLength = (__webpack_require__(3400).maxRowLength);
/* Return a list of empty points in 2D array z
* each empty point z[i][j] gives an array [i, j, neighborCount]
* neighborCount is the count of 4 nearest neighbors that DO exist
* this is to give us an order of points to evaluate for interpolation.
* if no neighbors exist, we iteratively look for neighbors that HAVE
* neighbors, and add a fractional neighborCount
*/
module.exports = function findEmpties(z) {
var empties = [];
var neighborHash = {};
var noNeighborList = [];
var nextRow = z[0];
var row = [];
var blank = [0, 0, 0];
var rowLength = maxRowLength(z);
var prevRow;
var i;
var j;
var thisPt;
var p;
var neighborCount;
var newNeighborHash;
var foundNewNeighbors;
for (i = 0; i < z.length; i++) {
prevRow = row;
row = nextRow;
nextRow = z[i + 1] || [];
for (j = 0; j < rowLength; j++) {
if (row[j] === undefined) {
neighborCount = (row[j - 1] !== undefined ? 1 : 0) + (row[j + 1] !== undefined ? 1 : 0) + (prevRow[j] !== undefined ? 1 : 0) + (nextRow[j] !== undefined ? 1 : 0);
if (neighborCount) {
// for this purpose, don't count off-the-edge points
// as undefined neighbors
if (i === 0) neighborCount++;
if (j === 0) neighborCount++;
if (i === z.length - 1) neighborCount++;
if (j === row.length - 1) neighborCount++;
// if all neighbors that could exist do, we don't
// need this for finding farther neighbors
if (neighborCount < 4) {
neighborHash[[i, j]] = [i, j, neighborCount];
}
empties.push([i, j, neighborCount]);
} else noNeighborList.push([i, j]);
}
}
}
while (noNeighborList.length) {
newNeighborHash = {};
foundNewNeighbors = false;
// look for cells that now have neighbors but didn't before
for (p = noNeighborList.length - 1; p >= 0; p--) {
thisPt = noNeighborList[p];
i = thisPt[0];
j = thisPt[1];
neighborCount = ((neighborHash[[i - 1, j]] || blank)[2] + (neighborHash[[i + 1, j]] || blank)[2] + (neighborHash[[i, j - 1]] || blank)[2] + (neighborHash[[i, j + 1]] || blank)[2]) / 20;
if (neighborCount) {
newNeighborHash[thisPt] = [i, j, neighborCount];
noNeighborList.splice(p, 1);
foundNewNeighbors = true;
}
}
if (!foundNewNeighbors) {
throw 'findEmpties iterated with no new neighbors';
}
// put these new cells into the main neighbor list
for (thisPt in newNeighborHash) {
neighborHash[thisPt] = newNeighborHash[thisPt];
empties.push(newNeighborHash[thisPt]);
}
}
// sort the full list in descending order of neighbor count
return empties.sort(function (a, b) {
return b[2] - a[2];
});
};
/***/ }),
/***/ 70448:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var INTERPTHRESHOLD = 1e-2;
var NEIGHBORSHIFTS = [[-1, 0], [1, 0], [0, -1], [0, 1]];
function correctionOvershoot(maxFractionalChange) {
// start with less overshoot, until we know it's converging,
// then ramp up the overshoot for faster convergence
return 0.5 - 0.25 * Math.min(1, maxFractionalChange * 0.5);
}
/*
* interp2d: Fill in missing data from a 2D array using an iterative
* poisson equation solver with zero-derivative BC at edges.
* Amazingly, this just amounts to repeatedly averaging all the existing
* nearest neighbors, at least if we don't take x/y scaling into account,
* which is the right approach here where x and y may not even have the
* same units.
*
* @param {array of arrays} z
* The 2D array to fill in. Will be mutated here. Assumed to already be
* cleaned, so all entries are numbers except gaps, which are `undefined`.
* @param {array of arrays} emptyPoints
* Each entry [i, j, neighborCount] for empty points z[i][j] and the number
* of neighbors that are *not* missing. Assumed to be sorted from most to
* least neighbors, as produced by heatmap/find_empties.
*/
module.exports = function interp2d(z, emptyPoints) {
var maxFractionalChange = 1;
var i;
// one pass to fill in a starting value for all the empties
iterateInterp2d(z, emptyPoints);
// we're don't need to iterate lone empties - remove them
for (i = 0; i < emptyPoints.length; i++) {
if (emptyPoints[i][2] < 4) break;
}
// but don't remove these points from the original array,
// we'll use them for masking, so make a copy.
emptyPoints = emptyPoints.slice(i);
for (i = 0; i < 100 && maxFractionalChange > INTERPTHRESHOLD; i++) {
maxFractionalChange = iterateInterp2d(z, emptyPoints, correctionOvershoot(maxFractionalChange));
}
if (maxFractionalChange > INTERPTHRESHOLD) {
Lib.log('interp2d didn\'t converge quickly', maxFractionalChange);
}
return z;
};
function iterateInterp2d(z, emptyPoints, overshoot) {
var maxFractionalChange = 0;
var thisPt;
var i;
var j;
var p;
var q;
var neighborShift;
var neighborRow;
var neighborVal;
var neighborCount;
var neighborSum;
var initialVal;
var minNeighbor;
var maxNeighbor;
for (p = 0; p < emptyPoints.length; p++) {
thisPt = emptyPoints[p];
i = thisPt[0];
j = thisPt[1];
initialVal = z[i][j];
neighborSum = 0;
neighborCount = 0;
for (q = 0; q < 4; q++) {
neighborShift = NEIGHBORSHIFTS[q];
neighborRow = z[i + neighborShift[0]];
if (!neighborRow) continue;
neighborVal = neighborRow[j + neighborShift[1]];
if (neighborVal !== undefined) {
if (neighborSum === 0) {
minNeighbor = maxNeighbor = neighborVal;
} else {
minNeighbor = Math.min(minNeighbor, neighborVal);
maxNeighbor = Math.max(maxNeighbor, neighborVal);
}
neighborCount++;
neighborSum += neighborVal;
}
}
if (neighborCount === 0) {
throw 'iterateInterp2d order is wrong: no defined neighbors';
}
// this is the laplace equation interpolation:
// each point is just the average of its neighbors
// note that this ignores differential x/y scaling
// which I think is the right approach, since we
// don't know what that scaling means
z[i][j] = neighborSum / neighborCount;
if (initialVal === undefined) {
if (neighborCount < 4) maxFractionalChange = 1;
} else {
// we can make large empty regions converge faster
// if we overshoot the change vs the previous value
z[i][j] = (1 + overshoot) * z[i][j] - overshoot * initialVal;
if (maxNeighbor > minNeighbor) {
maxFractionalChange = Math.max(maxFractionalChange, Math.abs(z[i][j] - initialVal) / (maxNeighbor - minNeighbor));
}
}
}
return maxFractionalChange;
}
/***/ }),
/***/ 35744:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Registry = __webpack_require__(24040);
var isArrayOrTypedArray = (__webpack_require__(3400).isArrayOrTypedArray);
module.exports = function makeBoundArray(trace, arrayIn, v0In, dvIn, numbricks, ax) {
var arrayOut = [];
var isContour = Registry.traceIs(trace, 'contour');
var isHist = Registry.traceIs(trace, 'histogram');
var isGL2D = Registry.traceIs(trace, 'gl2d');
var v0;
var dv;
var i;
var isArrayOfTwoItemsOrMore = isArrayOrTypedArray(arrayIn) && arrayIn.length > 1;
if (isArrayOfTwoItemsOrMore && !isHist && ax.type !== 'category') {
var len = arrayIn.length;
// given vals are brick centers
// hopefully length === numbricks, but use this method even if too few are supplied
// and extend it linearly based on the last two points
if (len <= numbricks) {
// contour plots only want the centers
if (isContour || isGL2D) arrayOut = Array.from(arrayIn).slice(0, numbricks);else if (numbricks === 1) {
if (ax.type === 'log') {
arrayOut = [0.5 * arrayIn[0], 2 * arrayIn[0]];
} else {
arrayOut = [arrayIn[0] - 0.5, arrayIn[0] + 0.5];
}
} else if (ax.type === 'log') {
arrayOut = [Math.pow(arrayIn[0], 1.5) / Math.pow(arrayIn[1], 0.5)];
for (i = 1; i < len; i++) {
// Geomean
arrayOut.push(Math.sqrt(arrayIn[i - 1] * arrayIn[i]));
}
arrayOut.push(Math.pow(arrayIn[len - 1], 1.5) / Math.pow(arrayIn[len - 2], 0.5));
} else {
arrayOut = [1.5 * arrayIn[0] - 0.5 * arrayIn[1]];
for (i = 1; i < len; i++) {
// Arithmetic mean
arrayOut.push((arrayIn[i - 1] + arrayIn[i]) * 0.5);
}
arrayOut.push(1.5 * arrayIn[len - 1] - 0.5 * arrayIn[len - 2]);
}
if (len < numbricks) {
var lastPt = arrayOut[arrayOut.length - 1];
var delta; // either multiplicative delta (log axis type) or arithmetic delta (all other axis types)
if (ax.type === 'log') {
delta = lastPt / arrayOut[arrayOut.length - 2];
for (i = len; i < numbricks; i++) {
lastPt *= delta;
arrayOut.push(lastPt);
}
} else {
delta = lastPt - arrayOut[arrayOut.length - 2];
for (i = len; i < numbricks; i++) {
lastPt += delta;
arrayOut.push(lastPt);
}
}
}
} else {
// hopefully length === numbricks+1, but do something regardless:
// given vals are brick boundaries
return isContour ? arrayIn.slice(0, numbricks) :
// we must be strict for contours
arrayIn.slice(0, numbricks + 1);
}
} else {
var calendar = trace[ax._id.charAt(0) + 'calendar'];
if (isHist) {
v0 = ax.r2c(v0In, 0, calendar);
} else {
if (isArrayOrTypedArray(arrayIn) && arrayIn.length === 1) {
v0 = arrayIn[0];
} else if (v0In === undefined) {
v0 = 0;
} else {
var fn = ax.type === 'log' ? ax.d2c : ax.r2c;
v0 = fn(v0In, 0, calendar);
}
}
dv = dvIn || 1;
for (i = isContour || isGL2D ? 0 : -0.5; i < numbricks; i++) {
arrayOut.push(v0 + dv * i);
}
}
return arrayOut;
};
/***/ }),
/***/ 51264:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
var Lib = __webpack_require__(3400);
var Registry = __webpack_require__(24040);
module.exports = function handleXYZDefaults(traceIn, traceOut, coerce, layout, xName, yName) {
var z = coerce('z');
xName = xName || 'x';
yName = yName || 'y';
var x, y;
if (z === undefined || !z.length) return 0;
if (Lib.isArray1D(z)) {
x = coerce(xName);
y = coerce(yName);
var xlen = Lib.minRowLength(x);
var ylen = Lib.minRowLength(y);
// column z must be accompanied by xName and yName arrays
if (xlen === 0 || ylen === 0) return 0;
traceOut._length = Math.min(xlen, ylen, z.length);
} else {
x = coordDefaults(xName, coerce);
y = coordDefaults(yName, coerce);
// TODO put z validation elsewhere
if (!isValidZ(z)) return 0;
coerce('transpose');
traceOut._length = null;
}
if (traceIn.type === 'heatmapgl') return true; // skip calendars until we handle them in those traces
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
handleCalendarDefaults(traceIn, traceOut, [xName, yName], layout);
return true;
};
function coordDefaults(coordStr, coerce) {
var coord = coerce(coordStr);
var coordType = coord ? coerce(coordStr + 'type', 'array') : 'scaled';
if (coordType === 'scaled') {
coerce(coordStr + '0');
coerce('d' + coordStr);
}
return coord;
}
function isValidZ(z) {
var allRowsAreArrays = true;
var oneRowIsFilled = false;
var hasOneNumber = false;
var zi;
/*
* Without this step:
*
* hasOneNumber = false breaks contour but not heatmap
* allRowsAreArrays = false breaks contour but not heatmap
* oneRowIsFilled = false breaks both
*/
for (var i = 0; i < z.length; i++) {
zi = z[i];
if (!Lib.isArrayOrTypedArray(zi)) {
allRowsAreArrays = false;
break;
}
if (zi.length > 0) oneRowIsFilled = true;
for (var j = 0; j < zi.length; j++) {
if (isNumeric(zi[j])) {
hasOneNumber = true;
break;
}
}
}
return allRowsAreArrays && oneRowIsFilled && hasOneNumber;
}
/***/ }),
/***/ 74512:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var heatmapAttrs = __webpack_require__(83328);
var colorScaleAttrs = __webpack_require__(49084);
var extendFlat = (__webpack_require__(92880).extendFlat);
var overrideAll = (__webpack_require__(67824).overrideAll);
var commonList = ['z', 'x', 'x0', 'dx', 'y', 'y0', 'dy', 'text', 'transpose', 'xtype', 'ytype'];
var attrs = {};
for (var i = 0; i < commonList.length; i++) {
var k = commonList[i];
attrs[k] = heatmapAttrs[k];
}
attrs.zsmooth = {
valType: 'enumerated',
values: ['fast', false],
dflt: 'fast',
editType: 'calc'
};
extendFlat(attrs, colorScaleAttrs('', {
cLetter: 'z',
autoColorDflt: false
}));
module.exports = overrideAll(attrs, 'calc', 'nested');
/***/ }),
/***/ 84656:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var createHeatmap2D = (__webpack_require__(67792).gl_heatmap2d);
var Axes = __webpack_require__(54460);
var str2RGBArray = __webpack_require__(43080);
function Heatmap(scene, uid) {
this.scene = scene;
this.uid = uid;
this.type = 'heatmapgl';
this.name = '';
this.hoverinfo = 'all';
this.xData = [];
this.yData = [];
this.zData = [];
this.textLabels = [];
this.idToIndex = [];
this.bounds = [0, 0, 0, 0];
this.options = {
zsmooth: 'fast',
z: [],
x: [],
y: [],
shape: [0, 0],
colorLevels: [0],
colorValues: [0, 0, 0, 1]
};
this.heatmap = createHeatmap2D(scene.glplot, this.options);
this.heatmap._trace = this;
}
var proto = Heatmap.prototype;
proto.handlePick = function (pickResult) {
var options = this.options;
var shape = options.shape;
var index = pickResult.pointId;
var xIndex = index % shape[0];
var yIndex = Math.floor(index / shape[0]);
var zIndex = index;
return {
trace: this,
dataCoord: pickResult.dataCoord,
traceCoord: [options.x[xIndex], options.y[yIndex], options.z[zIndex]],
textLabel: this.textLabels[index],
name: this.name,
pointIndex: [yIndex, xIndex],
hoverinfo: this.hoverinfo
};
};
proto.update = function (fullTrace, calcTrace) {
var calcPt = calcTrace[0];
this.index = fullTrace.index;
this.name = fullTrace.name;
this.hoverinfo = fullTrace.hoverinfo;
// convert z from 2D -> 1D
var z = calcPt.z;
this.options.z = [].concat.apply([], z);
var rowLen = z[0].length;
var colLen = z.length;
this.options.shape = [rowLen, colLen];
this.options.x = calcPt.x;
this.options.y = calcPt.y;
this.options.zsmooth = fullTrace.zsmooth;
var colorOptions = convertColorscale(fullTrace);
this.options.colorLevels = colorOptions.colorLevels;
this.options.colorValues = colorOptions.colorValues;
// convert text from 2D -> 1D
this.textLabels = [].concat.apply([], fullTrace.text);
this.heatmap.update(this.options);
var xa = this.scene.xaxis;
var ya = this.scene.yaxis;
var xOpts, yOpts;
if (fullTrace.zsmooth === false) {
// increase padding for discretised heatmap as suggested by Louise Ord
xOpts = {
ppad: calcPt.x[1] - calcPt.x[0]
};
yOpts = {
ppad: calcPt.y[1] - calcPt.y[0]
};
}
fullTrace._extremes[xa._id] = Axes.findExtremes(xa, calcPt.x, xOpts);
fullTrace._extremes[ya._id] = Axes.findExtremes(ya, calcPt.y, yOpts);
};
proto.dispose = function () {
this.heatmap.dispose();
};
function convertColorscale(fullTrace) {
var scl = fullTrace.colorscale;
var zmin = fullTrace.zmin;
var zmax = fullTrace.zmax;
var N = scl.length;
var domain = new Array(N);
var range = new Array(4 * N);
for (var i = 0; i < N; i++) {
var si = scl[i];
var color = str2RGBArray(si[1]);
domain[i] = zmin + si[0] * (zmax - zmin);
for (var j = 0; j < 4; j++) {
range[4 * i + j] = color[j];
}
}
return {
colorLevels: domain,
colorValues: range
};
}
function createHeatmap(scene, fullTrace, calcTrace) {
var plot = new Heatmap(scene, fullTrace.uid);
plot.update(fullTrace, calcTrace);
return plot;
}
module.exports = createHeatmap;
/***/ }),
/***/ 86464:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var handleXYZDefaults = __webpack_require__(51264);
var colorscaleDefaults = __webpack_require__(27260);
var attributes = __webpack_require__(74512);
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var validData = handleXYZDefaults(traceIn, traceOut, coerce, layout);
if (!validData) {
traceOut.visible = false;
return;
}
coerce('text');
coerce('zsmooth');
colorscaleDefaults(traceIn, traceOut, layout, coerce, {
prefix: '',
cLetter: 'z'
});
};
/***/ }),
/***/ 45536:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var deprecationWarning = ['*heatmapgl* trace is deprecated!', 'Please consider switching to the *heatmap* or *image* trace types.', 'Alternatively you could contribute/sponsor rewriting this trace type', 'based on cartesian features and using regl framework.'].join(' ');
module.exports = {
attributes: __webpack_require__(74512),
supplyDefaults: __webpack_require__(86464),
colorbar: __webpack_require__(96288),
calc: __webpack_require__(19512),
plot: __webpack_require__(84656),
moduleType: 'trace',
name: 'heatmapgl',
basePlotModule: __webpack_require__(39952),
categories: ['gl', 'gl2d', '2dMap'],
meta: {}
};
/***/ }),
/***/ 2000:
/***/ (function(module) {
"use strict";
module.exports = function doAvg(size, counts) {
var nMax = size.length;
var total = 0;
for (var i = 0; i < nMax; i++) {
if (counts[i]) {
size[i] /= counts[i];
total += size[i];
} else size[i] = null;
}
return total;
};
/***/ }),
/***/ 16964:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
module.exports = {
count: function (n, i, size) {
size[n]++;
return 1;
},
sum: function (n, i, size, counterData) {
var v = counterData[i];
if (isNumeric(v)) {
v = Number(v);
size[n] += v;
return v;
}
return 0;
},
avg: function (n, i, size, counterData, counts) {
var v = counterData[i];
if (isNumeric(v)) {
v = Number(v);
size[n] += v;
counts[n]++;
}
return 0;
},
min: function (n, i, size, counterData) {
var v = counterData[i];
if (isNumeric(v)) {
v = Number(v);
if (!isNumeric(size[n])) {
size[n] = v;
return v;
} else if (size[n] > v) {
var delta = v - size[n];
size[n] = v;
return delta;
}
}
return 0;
},
max: function (n, i, size, counterData) {
var v = counterData[i];
if (isNumeric(v)) {
v = Number(v);
if (!isNumeric(size[n])) {
size[n] = v;
return v;
} else if (size[n] < v) {
var delta = v - size[n];
size[n] = v;
return delta;
}
}
return 0;
}
};
/***/ }),
/***/ 67712:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var numConstants = __webpack_require__(39032);
var oneYear = numConstants.ONEAVGYEAR;
var oneMonth = numConstants.ONEAVGMONTH;
var oneDay = numConstants.ONEDAY;
var oneHour = numConstants.ONEHOUR;
var oneMin = numConstants.ONEMIN;
var oneSec = numConstants.ONESEC;
var tickIncrement = (__webpack_require__(54460).tickIncrement);
/*
* make a function that will find rounded bin edges
* @param {number} leftGap: how far from the left edge of any bin is the closest data value?
* @param {number} rightGap: how far from the right edge of any bin is the closest data value?
* @param {Array[number]} binEdges: the actual edge values used in binning
* @param {object} pa: the position axis
* @param {string} calendar: the data calendar
*
* @return {function(v, isRightEdge)}:
* find the start (isRightEdge is falsy) or end (truthy) label value for a bin edge `v`
*/
module.exports = function getBinSpanLabelRound(leftGap, rightGap, binEdges, pa, calendar) {
// the rounding digit is the largest digit that changes in *all* of 4 regions:
// - inside the rightGap before binEdges[0] (shifted 10% to the left)
// - inside the leftGap after binEdges[0] (expanded by 10% of rightGap on each end)
// - same for binEdges[1]
var dv0 = -1.1 * rightGap;
var dv1 = -0.1 * rightGap;
var dv2 = leftGap - dv1;
var edge0 = binEdges[0];
var edge1 = binEdges[1];
var leftDigit = Math.min(biggestDigitChanged(edge0 + dv1, edge0 + dv2, pa, calendar), biggestDigitChanged(edge1 + dv1, edge1 + dv2, pa, calendar));
var rightDigit = Math.min(biggestDigitChanged(edge0 + dv0, edge0 + dv1, pa, calendar), biggestDigitChanged(edge1 + dv0, edge1 + dv1, pa, calendar));
// normally we try to make the label for the right edge different from
// the left edge label, so it's unambiguous which bin gets data on the edge.
// but if this results in more than 3 extra digits (or for dates, more than
// 2 fields ie hr&min or min&sec, which is 3600x), it'll be more clutter than
// useful so keep the label cleaner instead
var digit, disambiguateEdges;
if (leftDigit > rightDigit && rightDigit < Math.abs(edge1 - edge0) / 4000) {
digit = leftDigit;
disambiguateEdges = false;
} else {
digit = Math.min(leftDigit, rightDigit);
disambiguateEdges = true;
}
if (pa.type === 'date' && digit > oneDay) {
var dashExclude = digit === oneYear ? 1 : 6;
var increment = digit === oneYear ? 'M12' : 'M1';
return function (v, isRightEdge) {
var dateStr = pa.c2d(v, oneYear, calendar);
var dashPos = dateStr.indexOf('-', dashExclude);
if (dashPos > 0) dateStr = dateStr.substr(0, dashPos);
var roundedV = pa.d2c(dateStr, 0, calendar);
if (roundedV < v) {
var nextV = tickIncrement(roundedV, increment, false, calendar);
if ((roundedV + nextV) / 2 < v + leftGap) roundedV = nextV;
}
if (isRightEdge && disambiguateEdges) {
return tickIncrement(roundedV, increment, true, calendar);
}
return roundedV;
};
}
return function (v, isRightEdge) {
var roundedV = digit * Math.round(v / digit);
// if we rounded down and we could round up and still be < leftGap
// (or what leftGap values round to), do that
if (roundedV + digit / 10 < v && roundedV + digit * 0.9 < v + leftGap) {
roundedV += digit;
}
// finally for the right edge back off one digit - but only if we can do that
// and not clip off any data that's potentially in the bin
if (isRightEdge && disambiguateEdges) {
roundedV -= digit;
}
return roundedV;
};
};
/*
* Find the largest digit that changes within a (calcdata) region [v1, v2]
* if dates, "digit" means date/time part when it's bigger than a second
* returns the unit value to round to this digit, eg 0.01 to round to hundredths, or
* 100 to round to hundreds. returns oneMonth or oneYear for month or year rounding,
* so that Math.min will work, rather than 'M1' and 'M12'
*/
function biggestDigitChanged(v1, v2, pa, calendar) {
// are we crossing zero? can't say anything.
// in principle this doesn't apply to dates but turns out this doesn't matter.
if (v1 * v2 <= 0) return Infinity;
var dv = Math.abs(v2 - v1);
var isDate = pa.type === 'date';
var digit = biggestGuaranteedDigitChanged(dv, isDate);
// see if a larger digit also changed
for (var i = 0; i < 10; i++) {
// numbers: next digit needs to be >10x but <100x then gets rounded down.
// dates: next digit can be as much as 60x (then rounded down)
var nextDigit = biggestGuaranteedDigitChanged(digit * 80, isDate);
// if we get to years, the chain stops
if (digit === nextDigit) break;
if (didDigitChange(nextDigit, v1, v2, isDate, pa, calendar)) digit = nextDigit;else break;
}
return digit;
}
/*
* Find the largest digit that *definitely* changes in a region [v, v + dv] for any v
* for nonuniform date regions (months/years) pick the largest
*/
function biggestGuaranteedDigitChanged(dv, isDate) {
if (isDate && dv > oneSec) {
// this is supposed to be the biggest *guaranteed* change
// so compare to the longest month and year across any calendar,
// and we'll iterate back up later
// note: does not support rounding larger than one year. We could add
// that if anyone wants it, but seems unusual and not strictly necessary.
if (dv > oneDay) {
if (dv > oneYear * 1.1) return oneYear;
if (dv > oneMonth * 1.1) return oneMonth;
return oneDay;
}
if (dv > oneHour) return oneHour;
if (dv > oneMin) return oneMin;
return oneSec;
}
return Math.pow(10, Math.floor(Math.log(dv) / Math.LN10));
}
function didDigitChange(digit, v1, v2, isDate, pa, calendar) {
if (isDate && digit > oneDay) {
var dateParts1 = dateParts(v1, pa, calendar);
var dateParts2 = dateParts(v2, pa, calendar);
var parti = digit === oneYear ? 0 : 1;
return dateParts1[parti] !== dateParts2[parti];
}
return Math.floor(v2 / digit) - Math.floor(v1 / digit) > 0.1;
}
function dateParts(v, pa, calendar) {
var parts = pa.c2d(v, oneYear, calendar).split('-');
if (parts[0] === '') {
parts.unshift();
parts[0] = '-' + parts[0];
}
return parts;
}
/***/ }),
/***/ 35852:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
var Lib = __webpack_require__(3400);
var Registry = __webpack_require__(24040);
var Axes = __webpack_require__(54460);
var arraysToCalcdata = __webpack_require__(84664);
var binFunctions = __webpack_require__(16964);
var normFunctions = __webpack_require__(10648);
var doAvg = __webpack_require__(2000);
var getBinSpanLabelRound = __webpack_require__(67712);
function calc(gd, trace) {
var pos = [];
var size = [];
var isHorizontal = trace.orientation === 'h';
var pa = Axes.getFromId(gd, isHorizontal ? trace.yaxis : trace.xaxis);
var mainData = isHorizontal ? 'y' : 'x';
var counterData = {
x: 'y',
y: 'x'
}[mainData];
var calendar = trace[mainData + 'calendar'];
var cumulativeSpec = trace.cumulative;
var i;
var binsAndPos = calcAllAutoBins(gd, trace, pa, mainData);
var binSpec = binsAndPos[0];
var pos0 = binsAndPos[1];
var nonuniformBins = typeof binSpec.size === 'string';
var binEdges = [];
var bins = nonuniformBins ? binEdges : binSpec;
// make the empty bin array
var inc = [];
var counts = [];
var inputPoints = [];
var total = 0;
var norm = trace.histnorm;
var func = trace.histfunc;
var densityNorm = norm.indexOf('density') !== -1;
var i2, binEnd, n;
if (cumulativeSpec.enabled && densityNorm) {
// we treat "cumulative" like it means "integral" if you use a density norm,
// which in the end means it's the same as without "density"
norm = norm.replace(/ ?density$/, '');
densityNorm = false;
}
var extremeFunc = func === 'max' || func === 'min';
var sizeInit = extremeFunc ? null : 0;
var binFunc = binFunctions.count;
var normFunc = normFunctions[norm];
var isAvg = false;
var pr2c = function (v) {
return pa.r2c(v, 0, calendar);
};
var rawCounterData;
if (Lib.isArrayOrTypedArray(trace[counterData]) && func !== 'count') {
rawCounterData = trace[counterData];
isAvg = func === 'avg';
binFunc = binFunctions[func];
}
// create the bins (and any extra arrays needed)
// assume more than 1e6 bins is an error, so we don't crash the browser
i = pr2c(binSpec.start);
// decrease end a little in case of rounding errors
binEnd = pr2c(binSpec.end) + (i - Axes.tickIncrement(i, binSpec.size, false, calendar)) / 1e6;
while (i < binEnd && pos.length < 1e6) {
i2 = Axes.tickIncrement(i, binSpec.size, false, calendar);
pos.push((i + i2) / 2);
size.push(sizeInit);
inputPoints.push([]);
// nonuniform bins (like months) we need to search,
// rather than straight calculate the bin we're in
binEdges.push(i);
// nonuniform bins also need nonuniform normalization factors
if (densityNorm) inc.push(1 / (i2 - i));
if (isAvg) counts.push(0);
// break to avoid infinite loops
if (i2 <= i) break;
i = i2;
}
binEdges.push(i);
// for date axes we need bin bounds to be calcdata. For nonuniform bins
// we already have this, but uniform with start/end/size they're still strings.
if (!nonuniformBins && pa.type === 'date') {
bins = {
start: pr2c(bins.start),
end: pr2c(bins.end),
size: bins.size
};
}
// stash left and right gaps by group
if (!gd._fullLayout._roundFnOpts) gd._fullLayout._roundFnOpts = {};
var groupName = trace['_' + mainData + 'bingroup'];
var roundFnOpts = {
leftGap: Infinity,
rightGap: Infinity
};
if (groupName) {
if (!gd._fullLayout._roundFnOpts[groupName]) gd._fullLayout._roundFnOpts[groupName] = roundFnOpts;
roundFnOpts = gd._fullLayout._roundFnOpts[groupName];
}
// bin the data
// and make histogram-specific pt-number-to-cd-index map object
var nMax = size.length;
var uniqueValsPerBin = true;
var leftGap = roundFnOpts.leftGap;
var rightGap = roundFnOpts.rightGap;
var ptNumber2cdIndex = {};
for (i = 0; i < pos0.length; i++) {
var posi = pos0[i];
n = Lib.findBin(posi, bins);
if (n >= 0 && n < nMax) {
total += binFunc(n, i, size, rawCounterData, counts);
if (uniqueValsPerBin && inputPoints[n].length && posi !== pos0[inputPoints[n][0]]) {
uniqueValsPerBin = false;
}
inputPoints[n].push(i);
ptNumber2cdIndex[i] = n;
leftGap = Math.min(leftGap, posi - binEdges[n]);
rightGap = Math.min(rightGap, binEdges[n + 1] - posi);
}
}
roundFnOpts.leftGap = leftGap;
roundFnOpts.rightGap = rightGap;
var roundFn;
if (!uniqueValsPerBin) {
roundFn = function (v, isRightEdge) {
return function () {
var roundFnOpts = gd._fullLayout._roundFnOpts[groupName];
return getBinSpanLabelRound(roundFnOpts.leftGap, roundFnOpts.rightGap, binEdges, pa, calendar)(v, isRightEdge);
};
};
}
// average and/or normalize the data, if needed
if (isAvg) total = doAvg(size, counts);
if (normFunc) normFunc(size, total, inc);
// after all normalization etc, now we can accumulate if desired
if (cumulativeSpec.enabled) cdf(size, cumulativeSpec.direction, cumulativeSpec.currentbin);
var seriesLen = Math.min(pos.length, size.length);
var cd = [];
var firstNonzero = 0;
var lastNonzero = seriesLen - 1;
// look for empty bins at the ends to remove, so autoscale omits them
for (i = 0; i < seriesLen; i++) {
if (size[i]) {
firstNonzero = i;
break;
}
}
for (i = seriesLen - 1; i >= firstNonzero; i--) {
if (size[i]) {
lastNonzero = i;
break;
}
}
// create the "calculated data" to plot
for (i = firstNonzero; i <= lastNonzero; i++) {
if (isNumeric(pos[i]) && isNumeric(size[i])) {
var cdi = {
p: pos[i],
s: size[i],
b: 0
};
// setup hover and event data fields,
// N.B. pts and "hover" positions ph0/ph1 don't seem to make much sense
// for cumulative distributions
if (!cumulativeSpec.enabled) {
cdi.pts = inputPoints[i];
if (uniqueValsPerBin) {
cdi.ph0 = cdi.ph1 = inputPoints[i].length ? pos0[inputPoints[i][0]] : pos[i];
} else {
// Defer evaluation of ph(0|1) in crossTraceCalc
trace._computePh = true;
cdi.ph0 = roundFn(binEdges[i]);
cdi.ph1 = roundFn(binEdges[i + 1], true);
}
}
cd.push(cdi);
}
}
if (cd.length === 1) {
// when we collapse to a single bin, calcdata no longer describes bin size
// so we need to explicitly specify it
cd[0].width1 = Axes.tickIncrement(cd[0].p, binSpec.size, false, calendar) - cd[0].p;
}
arraysToCalcdata(cd, trace);
if (Lib.isArrayOrTypedArray(trace.selectedpoints)) {
Lib.tagSelected(cd, trace, ptNumber2cdIndex);
}
return cd;
}
/*
* calcAllAutoBins: we want all histograms inside the same bingroup
* (see logic in Histogram.crossTraceDefaults) to share bin specs
*
* If the user has explicitly specified differing
* bin specs, there's nothing we can do, but if possible we will try to use the
* smallest bins of any of the auto values for all histograms inside the same
* bingroup.
*/
function calcAllAutoBins(gd, trace, pa, mainData, _overlayEdgeCase) {
var binAttr = mainData + 'bins';
var fullLayout = gd._fullLayout;
var groupName = trace['_' + mainData + 'bingroup'];
var binOpts = fullLayout._histogramBinOpts[groupName];
var isOverlay = fullLayout.barmode === 'overlay';
var i, traces, tracei, calendar, pos0, autoVals, cumulativeSpec;
var r2c = function (v) {
return pa.r2c(v, 0, calendar);
};
var c2r = function (v) {
return pa.c2r(v, 0, calendar);
};
var cleanBound = pa.type === 'date' ? function (v) {
return v || v === 0 ? Lib.cleanDate(v, null, calendar) : null;
} : function (v) {
return isNumeric(v) ? Number(v) : null;
};
function setBound(attr, bins, newBins) {
if (bins[attr + 'Found']) {
bins[attr] = cleanBound(bins[attr]);
if (bins[attr] === null) bins[attr] = newBins[attr];
} else {
autoVals[attr] = bins[attr] = newBins[attr];
Lib.nestedProperty(traces[0], binAttr + '.' + attr).set(newBins[attr]);
}
}
// all but the first trace in this group has already been marked finished
// clear this flag, so next time we run calc we will run autobin again
if (trace['_' + mainData + 'autoBinFinished']) {
delete trace['_' + mainData + 'autoBinFinished'];
} else {
traces = binOpts.traces;
var allPos = [];
// Note: we're including `legendonly` traces here for autobin purposes,
// so that showing & hiding from the legend won't affect bins.
// But this complicates things a bit since those traces don't `calc`,
// hence `isFirstVisible`.
var isFirstVisible = true;
var has2dMap = false;
var hasHist2dContour = false;
for (i = 0; i < traces.length; i++) {
tracei = traces[i];
if (tracei.visible) {
var mainDatai = binOpts.dirs[i];
pos0 = tracei['_' + mainDatai + 'pos0'] = pa.makeCalcdata(tracei, mainDatai);
allPos = Lib.concat(allPos, pos0);
delete tracei['_' + mainData + 'autoBinFinished'];
if (trace.visible === true) {
if (isFirstVisible) {
isFirstVisible = false;
} else {
delete tracei._autoBin;
tracei['_' + mainData + 'autoBinFinished'] = 1;
}
if (Registry.traceIs(tracei, '2dMap')) {
has2dMap = true;
}
if (tracei.type === 'histogram2dcontour') {
hasHist2dContour = true;
}
}
}
}
calendar = traces[0][mainData + 'calendar'];
var newBinSpec = Axes.autoBin(allPos, pa, binOpts.nbins, has2dMap, calendar, binOpts.sizeFound && binOpts.size);
var autoBin = traces[0]._autoBin = {};
autoVals = autoBin[binOpts.dirs[0]] = {};
if (hasHist2dContour) {
// the "true" 2nd argument reverses the tick direction (which we can't
// just do with a minus sign because of month bins)
if (!binOpts.size) {
newBinSpec.start = c2r(Axes.tickIncrement(r2c(newBinSpec.start), newBinSpec.size, true, calendar));
}
if (binOpts.end === undefined) {
newBinSpec.end = c2r(Axes.tickIncrement(r2c(newBinSpec.end), newBinSpec.size, false, calendar));
}
}
// Edge case: single-valued histogram overlaying others
// Use them all together to calculate the bin size for the single-valued one
// Don't re-calculate bin width if user manually specified it (checing in bingroup=='' or xbins is defined)
if (isOverlay && !Registry.traceIs(trace, '2dMap') && newBinSpec._dataSpan === 0 && pa.type !== 'category' && pa.type !== 'multicategory' && trace.bingroup === '' && typeof trace.xbins === 'undefined') {
// Several single-valued histograms! Stop infinite recursion,
// just return an extra flag that tells handleSingleValueOverlays
// to sort out this trace too
if (_overlayEdgeCase) return [newBinSpec, pos0, true];
newBinSpec = handleSingleValueOverlays(gd, trace, pa, mainData, binAttr);
}
// adjust for CDF edge cases
cumulativeSpec = tracei.cumulative || {};
if (cumulativeSpec.enabled && cumulativeSpec.currentbin !== 'include') {
if (cumulativeSpec.direction === 'decreasing') {
newBinSpec.start = c2r(Axes.tickIncrement(r2c(newBinSpec.start), newBinSpec.size, true, calendar));
} else {
newBinSpec.end = c2r(Axes.tickIncrement(r2c(newBinSpec.end), newBinSpec.size, false, calendar));
}
}
binOpts.size = newBinSpec.size;
if (!binOpts.sizeFound) {
autoVals.size = newBinSpec.size;
Lib.nestedProperty(traces[0], binAttr + '.size').set(newBinSpec.size);
}
setBound('start', binOpts, newBinSpec);
setBound('end', binOpts, newBinSpec);
}
pos0 = trace['_' + mainData + 'pos0'];
delete trace['_' + mainData + 'pos0'];
// Each trace can specify its own start/end, or if omitted
// we ensure they're beyond the bounds of this trace's data,
// and we need to make sure start is aligned with the main start
var traceInputBins = trace._input[binAttr] || {};
var traceBinOptsCalc = Lib.extendFlat({}, binOpts);
var mainStart = binOpts.start;
var startIn = pa.r2l(traceInputBins.start);
var hasStart = startIn !== undefined;
if ((binOpts.startFound || hasStart) && startIn !== pa.r2l(mainStart)) {
// We have an explicit start to reconcile across traces
// if this trace has an explicit start, shift it down to a bin edge
// if another trace had an explicit start, shift it down to a
// bin edge past our data
var traceStart = hasStart ? startIn : Lib.aggNums(Math.min, null, pos0);
var dummyAx = {
type: pa.type === 'category' || pa.type === 'multicategory' ? 'linear' : pa.type,
r2l: pa.r2l,
dtick: binOpts.size,
tick0: mainStart,
calendar: calendar,
range: [traceStart, Axes.tickIncrement(traceStart, binOpts.size, false, calendar)].map(pa.l2r)
};
var newStart = Axes.tickFirst(dummyAx);
if (newStart > pa.r2l(traceStart)) {
newStart = Axes.tickIncrement(newStart, binOpts.size, true, calendar);
}
traceBinOptsCalc.start = pa.l2r(newStart);
if (!hasStart) Lib.nestedProperty(trace, binAttr + '.start').set(traceBinOptsCalc.start);
}
var mainEnd = binOpts.end;
var endIn = pa.r2l(traceInputBins.end);
var hasEnd = endIn !== undefined;
if ((binOpts.endFound || hasEnd) && endIn !== pa.r2l(mainEnd)) {
// Reconciling an explicit end is easier, as it doesn't need to
// match bin edges
var traceEnd = hasEnd ? endIn : Lib.aggNums(Math.max, null, pos0);
traceBinOptsCalc.end = pa.l2r(traceEnd);
if (!hasEnd) Lib.nestedProperty(trace, binAttr + '.start').set(traceBinOptsCalc.end);
}
// Backward compatibility for one-time autobinning.
// autobin: true is handled in cleanData, but autobin: false
// needs to be here where we have determined the values.
var autoBinAttr = 'autobin' + mainData;
if (trace._input[autoBinAttr] === false) {
trace._input[binAttr] = Lib.extendFlat({}, trace[binAttr] || {});
delete trace._input[autoBinAttr];
delete trace[autoBinAttr];
}
return [traceBinOptsCalc, pos0];
}
/*
* Adjust single-value histograms in overlay mode to make as good a
* guess as we can at autobin values the user would like.
*
* Returns the binSpec for the trace that sparked all this
*/
function handleSingleValueOverlays(gd, trace, pa, mainData, binAttr) {
var fullLayout = gd._fullLayout;
var overlaidTraceGroup = getConnectedHistograms(gd, trace);
var pastThisTrace = false;
var minSize = Infinity;
var singleValuedTraces = [trace];
var i, tracei, binOpts;
// first collect all the:
// - min bin size from all multi-valued traces
// - single-valued traces
for (i = 0; i < overlaidTraceGroup.length; i++) {
tracei = overlaidTraceGroup[i];
if (tracei === trace) {
pastThisTrace = true;
} else if (!pastThisTrace) {
// This trace has already had its autobins calculated, so either:
// - it is part of a bingroup
// - it is NOT a single-valued trace
binOpts = fullLayout._histogramBinOpts[tracei['_' + mainData + 'bingroup']];
minSize = Math.min(minSize, binOpts.size || tracei[binAttr].size);
} else {
var resulti = calcAllAutoBins(gd, tracei, pa, mainData, true);
var binSpeci = resulti[0];
var isSingleValued = resulti[2];
// so we can use this result when we get to tracei in the normal
// course of events, mark it as done and put _pos0 back
tracei['_' + mainData + 'autoBinFinished'] = 1;
tracei['_' + mainData + 'pos0'] = resulti[1];
if (isSingleValued) {
singleValuedTraces.push(tracei);
} else {
minSize = Math.min(minSize, binSpeci.size);
}
}
}
// find the real data values for each single-valued trace
// hunt through pos0 for the first valid value
var dataVals = new Array(singleValuedTraces.length);
for (i = 0; i < singleValuedTraces.length; i++) {
var pos0 = singleValuedTraces[i]['_' + mainData + 'pos0'];
for (var j = 0; j < pos0.length; j++) {
if (pos0[j] !== undefined) {
dataVals[i] = pos0[j];
break;
}
}
}
// are ALL traces are single-valued? use the min difference between
// all of their values (which defaults to 1 if there's still only one)
if (!isFinite(minSize)) {
minSize = Lib.distinctVals(dataVals).minDiff;
}
// now apply the min size we found to all single-valued traces
for (i = 0; i < singleValuedTraces.length; i++) {
tracei = singleValuedTraces[i];
var calendar = tracei[mainData + 'calendar'];
var newBins = {
start: pa.c2r(dataVals[i] - minSize / 2, 0, calendar),
end: pa.c2r(dataVals[i] + minSize / 2, 0, calendar),
size: minSize
};
tracei._input[binAttr] = tracei[binAttr] = newBins;
binOpts = fullLayout._histogramBinOpts[tracei['_' + mainData + 'bingroup']];
if (binOpts) Lib.extendFlat(binOpts, newBins);
}
return trace[binAttr];
}
/*
* Return an array of histograms that share axes and orientation.
*
* Only considers histograms. In principle we could include bars in a
* similar way to how we do manually binned histograms, though this
* would have tons of edge cases and value judgments to make.
*/
function getConnectedHistograms(gd, trace) {
var xid = trace.xaxis;
var yid = trace.yaxis;
var orientation = trace.orientation;
var out = [];
var fullData = gd._fullData;
for (var i = 0; i < fullData.length; i++) {
var tracei = fullData[i];
if (tracei.type === 'histogram' && tracei.visible === true && tracei.orientation === orientation && tracei.xaxis === xid && tracei.yaxis === yid) {
out.push(tracei);
}
}
return out;
}
function cdf(size, direction, currentBin) {
var i, vi, prevSum;
function firstHalfPoint(i) {
prevSum = size[i];
size[i] /= 2;
}
function nextHalfPoint(i) {
vi = size[i];
size[i] = prevSum + vi / 2;
prevSum += vi;
}
if (currentBin === 'half') {
if (direction === 'increasing') {
firstHalfPoint(0);
for (i = 1; i < size.length; i++) {
nextHalfPoint(i);
}
} else {
firstHalfPoint(size.length - 1);
for (i = size.length - 2; i >= 0; i--) {
nextHalfPoint(i);
}
}
} else if (direction === 'increasing') {
for (i = 1; i < size.length; i++) {
size[i] += size[i - 1];
}
// 'exclude' is identical to 'include' just shifted one bin over
if (currentBin === 'exclude') {
size.unshift(0);
size.pop();
}
} else {
for (i = size.length - 2; i >= 0; i--) {
size[i] += size[i + 1];
}
if (currentBin === 'exclude') {
size.push(0);
size.shift();
}
}
}
module.exports = {
calc: calc,
calcAllAutoBins: calcAllAutoBins
};
/***/ }),
/***/ 10648:
/***/ (function(module) {
"use strict";
module.exports = {
percent: function (size, total) {
var nMax = size.length;
var norm = 100 / total;
for (var n = 0; n < nMax; n++) size[n] *= norm;
},
probability: function (size, total) {
var nMax = size.length;
for (var n = 0; n < nMax; n++) size[n] /= total;
},
density: function (size, total, inc, yinc) {
var nMax = size.length;
yinc = yinc || 1;
for (var n = 0; n < nMax; n++) size[n] *= inc[n] * yinc;
},
'probability density': function (size, total, inc, yinc) {
var nMax = size.length;
if (yinc) total /= yinc;
for (var n = 0; n < nMax; n++) size[n] *= inc[n] / total;
}
};
/***/ }),
/***/ 55480:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Axes = __webpack_require__(54460);
var binFunctions = __webpack_require__(16964);
var normFunctions = __webpack_require__(10648);
var doAvg = __webpack_require__(2000);
var getBinSpanLabelRound = __webpack_require__(67712);
var calcAllAutoBins = (__webpack_require__(35852).calcAllAutoBins);
module.exports = function calc(gd, trace) {
var xa = Axes.getFromId(gd, trace.xaxis);
var ya = Axes.getFromId(gd, trace.yaxis);
var xcalendar = trace.xcalendar;
var ycalendar = trace.ycalendar;
var xr2c = function (v) {
return xa.r2c(v, 0, xcalendar);
};
var yr2c = function (v) {
return ya.r2c(v, 0, ycalendar);
};
var xc2r = function (v) {
return xa.c2r(v, 0, xcalendar);
};
var yc2r = function (v) {
return ya.c2r(v, 0, ycalendar);
};
var i, j, n, m;
// calculate the bins
var xBinsAndPos = calcAllAutoBins(gd, trace, xa, 'x');
var xBinSpec = xBinsAndPos[0];
var xPos0 = xBinsAndPos[1];
var yBinsAndPos = calcAllAutoBins(gd, trace, ya, 'y');
var yBinSpec = yBinsAndPos[0];
var yPos0 = yBinsAndPos[1];
var serieslen = trace._length;
if (xPos0.length > serieslen) xPos0.splice(serieslen, xPos0.length - serieslen);
if (yPos0.length > serieslen) yPos0.splice(serieslen, yPos0.length - serieslen);
// make the empty bin array & scale the map
var z = [];
var onecol = [];
var zerocol = [];
var nonuniformBinsX = typeof xBinSpec.size === 'string';
var nonuniformBinsY = typeof yBinSpec.size === 'string';
var xEdges = [];
var yEdges = [];
var xbins = nonuniformBinsX ? xEdges : xBinSpec;
var ybins = nonuniformBinsY ? yEdges : yBinSpec;
var total = 0;
var counts = [];
var inputPoints = [];
var norm = trace.histnorm;
var func = trace.histfunc;
var densitynorm = norm.indexOf('density') !== -1;
var extremefunc = func === 'max' || func === 'min';
var sizeinit = extremefunc ? null : 0;
var binfunc = binFunctions.count;
var normfunc = normFunctions[norm];
var doavg = false;
var xinc = [];
var yinc = [];
// set a binning function other than count?
// for binning functions: check first for 'z',
// then 'mc' in case we had a colored scatter plot
// and want to transfer these colors to the 2D histo
// TODO: axe this, make it the responsibility of the app changing type? or an impliedEdit?
var rawCounterData = 'z' in trace ? trace.z : 'marker' in trace && Array.isArray(trace.marker.color) ? trace.marker.color : '';
if (rawCounterData && func !== 'count') {
doavg = func === 'avg';
binfunc = binFunctions[func];
}
// decrease end a little in case of rounding errors
var xBinSize = xBinSpec.size;
var xBinStart = xr2c(xBinSpec.start);
var xBinEnd = xr2c(xBinSpec.end) + (xBinStart - Axes.tickIncrement(xBinStart, xBinSize, false, xcalendar)) / 1e6;
for (i = xBinStart; i < xBinEnd; i = Axes.tickIncrement(i, xBinSize, false, xcalendar)) {
onecol.push(sizeinit);
xEdges.push(i);
if (doavg) zerocol.push(0);
}
xEdges.push(i);
var nx = onecol.length;
var dx = (i - xBinStart) / nx;
var x0 = xc2r(xBinStart + dx / 2);
var yBinSize = yBinSpec.size;
var yBinStart = yr2c(yBinSpec.start);
var yBinEnd = yr2c(yBinSpec.end) + (yBinStart - Axes.tickIncrement(yBinStart, yBinSize, false, ycalendar)) / 1e6;
for (i = yBinStart; i < yBinEnd; i = Axes.tickIncrement(i, yBinSize, false, ycalendar)) {
z.push(onecol.slice());
yEdges.push(i);
var ipCol = new Array(nx);
for (j = 0; j < nx; j++) ipCol[j] = [];
inputPoints.push(ipCol);
if (doavg) counts.push(zerocol.slice());
}
yEdges.push(i);
var ny = z.length;
var dy = (i - yBinStart) / ny;
var y0 = yc2r(yBinStart + dy / 2);
if (densitynorm) {
xinc = makeIncrements(onecol.length, xbins, dx, nonuniformBinsX);
yinc = makeIncrements(z.length, ybins, dy, nonuniformBinsY);
}
// for date axes we need bin bounds to be calcdata. For nonuniform bins
// we already have this, but uniform with start/end/size they're still strings.
if (!nonuniformBinsX && xa.type === 'date') xbins = binsToCalc(xr2c, xbins);
if (!nonuniformBinsY && ya.type === 'date') ybins = binsToCalc(yr2c, ybins);
// put data into bins
var uniqueValsPerX = true;
var uniqueValsPerY = true;
var xVals = new Array(nx);
var yVals = new Array(ny);
var xGapLow = Infinity;
var xGapHigh = Infinity;
var yGapLow = Infinity;
var yGapHigh = Infinity;
for (i = 0; i < serieslen; i++) {
var xi = xPos0[i];
var yi = yPos0[i];
n = Lib.findBin(xi, xbins);
m = Lib.findBin(yi, ybins);
if (n >= 0 && n < nx && m >= 0 && m < ny) {
total += binfunc(n, i, z[m], rawCounterData, counts[m]);
inputPoints[m][n].push(i);
if (uniqueValsPerX) {
if (xVals[n] === undefined) xVals[n] = xi;else if (xVals[n] !== xi) uniqueValsPerX = false;
}
if (uniqueValsPerY) {
if (yVals[m] === undefined) yVals[m] = yi;else if (yVals[m] !== yi) uniqueValsPerY = false;
}
xGapLow = Math.min(xGapLow, xi - xEdges[n]);
xGapHigh = Math.min(xGapHigh, xEdges[n + 1] - xi);
yGapLow = Math.min(yGapLow, yi - yEdges[m]);
yGapHigh = Math.min(yGapHigh, yEdges[m + 1] - yi);
}
}
// normalize, if needed
if (doavg) {
for (m = 0; m < ny; m++) total += doAvg(z[m], counts[m]);
}
if (normfunc) {
for (m = 0; m < ny; m++) normfunc(z[m], total, xinc, yinc[m]);
}
return {
x: xPos0,
xRanges: getRanges(xEdges, uniqueValsPerX && xVals, xGapLow, xGapHigh, xa, xcalendar),
x0: x0,
dx: dx,
y: yPos0,
yRanges: getRanges(yEdges, uniqueValsPerY && yVals, yGapLow, yGapHigh, ya, ycalendar),
y0: y0,
dy: dy,
z: z,
pts: inputPoints
};
};
function makeIncrements(len, bins, dv, nonuniform) {
var out = new Array(len);
var i;
if (nonuniform) {
for (i = 0; i < len; i++) out[i] = 1 / (bins[i + 1] - bins[i]);
} else {
var inc = 1 / dv;
for (i = 0; i < len; i++) out[i] = inc;
}
return out;
}
function binsToCalc(r2c, bins) {
return {
start: r2c(bins.start),
end: r2c(bins.end),
size: bins.size
};
}
function getRanges(edges, uniqueVals, gapLow, gapHigh, ax, calendar) {
var i;
var len = edges.length - 1;
var out = new Array(len);
var roundFn = getBinSpanLabelRound(gapLow, gapHigh, edges, ax, calendar);
for (i = 0; i < len; i++) {
var v = (uniqueVals || [])[i];
out[i] = v === undefined ? [roundFn(edges[i]), roundFn(edges[i + 1], true)] : [v, v];
}
return out;
}
/***/ }),
/***/ 82296:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var colorScaleAttrs = __webpack_require__(49084);
var axesAttrs = __webpack_require__(94724);
var fontAttrs = __webpack_require__(25376);
var domainAttrs = (__webpack_require__(86968)/* .attributes */ .u);
var extendFlat = (__webpack_require__(92880).extendFlat);
var templatedArray = (__webpack_require__(31780).templatedArray);
module.exports = {
domain: domainAttrs({
name: 'parcoords',
trace: true,
editType: 'plot'
}),
labelangle: {
valType: 'angle',
dflt: 0,
editType: 'plot'
},
labelside: {
valType: 'enumerated',
values: ['top', 'bottom'],
dflt: 'top',
editType: 'plot'
},
labelfont: fontAttrs({
editType: 'plot'
}),
tickfont: fontAttrs({
editType: 'plot'
}),
rangefont: fontAttrs({
editType: 'plot'
}),
dimensions: templatedArray('dimension', {
label: {
valType: 'string',
editType: 'plot'
},
// TODO: better way to determine ordinal vs continuous axes,
// so users can use tickvals/ticktext with a continuous axis.
tickvals: extendFlat({}, axesAttrs.tickvals, {
editType: 'plot'
}),
ticktext: extendFlat({}, axesAttrs.ticktext, {
editType: 'plot'
}),
tickformat: extendFlat({}, axesAttrs.tickformat, {
editType: 'plot'
}),
visible: {
valType: 'boolean',
dflt: true,
editType: 'plot'
},
range: {
valType: 'info_array',
items: [{
valType: 'number',
editType: 'plot'
}, {
valType: 'number',
editType: 'plot'
}],
editType: 'plot'
},
constraintrange: {
valType: 'info_array',
freeLength: true,
dimensions: '1-2',
items: [{
valType: 'any',
editType: 'plot'
}, {
valType: 'any',
editType: 'plot'
}],
editType: 'plot'
},
multiselect: {
valType: 'boolean',
dflt: true,
editType: 'plot'
},
values: {
valType: 'data_array',
editType: 'calc'
},
editType: 'calc'
}),
line: extendFlat({
editType: 'calc'
}, colorScaleAttrs('line', {
// the default autocolorscale isn't quite usable for parcoords due to context ambiguity around 0 (grey, off-white)
// autocolorscale therefore defaults to false too, to avoid being overridden by the blue-white-red autocolor palette
colorscaleDflt: 'Viridis',
autoColorDflt: false,
editTypeOverride: 'calc'
})),
unselected: {
line: {
color: {
valType: 'color',
dflt: '#7f7f7f',
editType: 'plot'
},
opacity: {
valType: 'number',
min: 0,
max: 1,
dflt: 'auto',
editType: 'plot'
},
editType: 'plot'
},
editType: 'plot'
}
};
/***/ }),
/***/ 71864:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var c = __webpack_require__(30140);
var d3 = __webpack_require__(33428);
var keyFun = (__webpack_require__(71688).keyFun);
var repeat = (__webpack_require__(71688).repeat);
var sortAsc = (__webpack_require__(3400).sorterAsc);
var strTranslate = (__webpack_require__(3400).strTranslate);
var snapRatio = c.bar.snapRatio;
function snapOvershoot(v, vAdjacent) {
return v * (1 - snapRatio) + vAdjacent * snapRatio;
}
var snapClose = c.bar.snapClose;
function closeToCovering(v, vAdjacent) {
return v * (1 - snapClose) + vAdjacent * snapClose;
}
// snap for the low end of a range on an ordinal scale
// on an ordinal scale, always show some overshoot from the exact value,
// so it's clear we're covering it
// find the interval we're in, and snap to 1/4 the distance to the next
// these two could be unified at a slight loss of readability / perf
function ordinalScaleSnap(isHigh, a, v, existingRanges) {
if (overlappingExisting(v, existingRanges)) return v;
var dir = isHigh ? -1 : 1;
var first = 0;
var last = a.length - 1;
if (dir < 0) {
var tmp = first;
first = last;
last = tmp;
}
var aHere = a[first];
var aPrev = aHere;
for (var i = first; dir * i < dir * last; i += dir) {
var nextI = i + dir;
var aNext = a[nextI];
// very close to the previous - snap down to it
if (dir * v < dir * closeToCovering(aHere, aNext)) return snapOvershoot(aHere, aPrev);
if (dir * v < dir * aNext || nextI === last) return snapOvershoot(aNext, aHere);
aPrev = aHere;
aHere = aNext;
}
}
function overlappingExisting(v, existingRanges) {
for (var i = 0; i < existingRanges.length; i++) {
if (v >= existingRanges[i][0] && v <= existingRanges[i][1]) return true;
}
return false;
}
function barHorizontalSetup(selection) {
selection.attr('x', -c.bar.captureWidth / 2).attr('width', c.bar.captureWidth);
}
function backgroundBarHorizontalSetup(selection) {
selection.attr('visibility', 'visible').style('visibility', 'visible').attr('fill', 'yellow').attr('opacity', 0);
}
function setHighlight(d) {
if (!d.brush.filterSpecified) {
return '0,' + d.height;
}
var pixelRanges = unitToPx(d.brush.filter.getConsolidated(), d.height);
var dashArray = [0]; // we start with a 0 length selection as filter ranges are inclusive, not exclusive
var p, sectionHeight, iNext;
var currentGap = pixelRanges.length ? pixelRanges[0][0] : null;
for (var i = 0; i < pixelRanges.length; i++) {
p = pixelRanges[i];
sectionHeight = p[1] - p[0];
dashArray.push(currentGap);
dashArray.push(sectionHeight);
iNext = i + 1;
if (iNext < pixelRanges.length) {
currentGap = pixelRanges[iNext][0] - p[1];
}
}
dashArray.push(d.height);
// d.height is added at the end to ensure that (1) we have an even number of dasharray points, MDN page says
// "If an odd number of values is provided, then the list of values is repeated to yield an even number of values."
// and (2) it's _at least_ as long as the full height (even if range is minuscule and at the bottom) though this
// may not be necessary, maybe duplicating the last point would do too. But no harm in a longer dasharray than line.
return dashArray;
}
function unitToPx(unitRanges, height) {
return unitRanges.map(function (pr) {
return pr.map(function (v) {
return Math.max(0, v * height);
}).sort(sortAsc);
});
}
// is the cursor over the north, middle, or south of a bar?
// the end handles extend over the last 10% of the bar
function getRegion(fPix, y) {
var pad = c.bar.handleHeight;
if (y > fPix[1] + pad || y < fPix[0] - pad) return;
if (y >= 0.9 * fPix[1] + 0.1 * fPix[0]) return 'n';
if (y <= 0.9 * fPix[0] + 0.1 * fPix[1]) return 's';
return 'ns';
}
function clearCursor() {
d3.select(document.body).style('cursor', null);
}
function styleHighlight(selection) {
// stroke-dasharray is used to minimize the number of created DOM nodes, because the requirement calls for up to
// 1000 individual selections on an axis, and there can be 60 axes per parcoords, and multiple parcoords per
// dashboard. The technique is similar to https://codepen.io/monfera/pen/rLYqWR and using a `polyline` with
// multiple sections, or a `path` element via its `d` attribute would also be DOM-sparing alternatives.
selection.attr('stroke-dasharray', setHighlight);
}
function renderHighlight(root, tweenCallback) {
var bar = d3.select(root).selectAll('.highlight, .highlight-shadow');
var barToStyle = tweenCallback ? bar.transition().duration(c.bar.snapDuration).each('end', tweenCallback) : bar;
styleHighlight(barToStyle);
}
function getInterval(d, y) {
var b = d.brush;
var active = b.filterSpecified;
var closestInterval = NaN;
var out = {};
var i;
if (active) {
var height = d.height;
var intervals = b.filter.getConsolidated();
var pixIntervals = unitToPx(intervals, height);
var hoveredInterval = NaN;
var previousInterval = NaN;
var nextInterval = NaN;
for (i = 0; i <= pixIntervals.length; i++) {
var p = pixIntervals[i];
if (p && p[0] <= y && y <= p[1]) {
// over a bar
hoveredInterval = i;
break;
} else {
// between bars, or before/after the first/last bar
previousInterval = i ? i - 1 : NaN;
if (p && p[0] > y) {
nextInterval = i;
break; // no point continuing as intervals are non-overlapping and sorted; could use log search
}
}
}
closestInterval = hoveredInterval;
if (isNaN(closestInterval)) {
if (isNaN(previousInterval) || isNaN(nextInterval)) {
closestInterval = isNaN(previousInterval) ? nextInterval : previousInterval;
} else {
closestInterval = y - pixIntervals[previousInterval][1] < pixIntervals[nextInterval][0] - y ? previousInterval : nextInterval;
}
}
if (!isNaN(closestInterval)) {
var fPix = pixIntervals[closestInterval];
var region = getRegion(fPix, y);
if (region) {
out.interval = intervals[closestInterval];
out.intervalPix = fPix;
out.region = region;
}
}
}
if (d.ordinal && !out.region) {
var a = d.unitTickvals;
var unitLocation = d.unitToPaddedPx.invert(y);
for (i = 0; i < a.length; i++) {
var rangei = [a[Math.max(i - 1, 0)] * 0.25 + a[i] * 0.75, a[Math.min(i + 1, a.length - 1)] * 0.25 + a[i] * 0.75];
if (unitLocation >= rangei[0] && unitLocation <= rangei[1]) {
out.clickableOrdinalRange = rangei;
break;
}
}
}
return out;
}
function dragstart(lThis, d) {
d3.event.sourceEvent.stopPropagation();
var y = d.height - d3.mouse(lThis)[1] - 2 * c.verticalPadding;
var unitLocation = d.unitToPaddedPx.invert(y);
var b = d.brush;
var interval = getInterval(d, y);
var unitRange = interval.interval;
var s = b.svgBrush;
s.wasDragged = false; // we start assuming there won't be a drag - useful for reset
s.grabbingBar = interval.region === 'ns';
if (s.grabbingBar) {
var pixelRange = unitRange.map(d.unitToPaddedPx);
s.grabPoint = y - pixelRange[0] - c.verticalPadding;
s.barLength = pixelRange[1] - pixelRange[0];
}
s.clickableOrdinalRange = interval.clickableOrdinalRange;
s.stayingIntervals = d.multiselect && b.filterSpecified ? b.filter.getConsolidated() : [];
if (unitRange) {
s.stayingIntervals = s.stayingIntervals.filter(function (int2) {
return int2[0] !== unitRange[0] && int2[1] !== unitRange[1];
});
}
s.startExtent = interval.region ? unitRange[interval.region === 's' ? 1 : 0] : unitLocation;
d.parent.inBrushDrag = true;
s.brushStartCallback();
}
function drag(lThis, d) {
d3.event.sourceEvent.stopPropagation();
var y = d.height - d3.mouse(lThis)[1] - 2 * c.verticalPadding;
var s = d.brush.svgBrush;
s.wasDragged = true;
s._dragging = true;
if (s.grabbingBar) {
// moving the bar
s.newExtent = [y - s.grabPoint, y + s.barLength - s.grabPoint].map(d.unitToPaddedPx.invert);
} else {
// south/north drag or new bar creation
s.newExtent = [s.startExtent, d.unitToPaddedPx.invert(y)].sort(sortAsc);
}
d.brush.filterSpecified = true;
s.extent = s.stayingIntervals.concat([s.newExtent]);
s.brushCallback(d);
renderHighlight(lThis.parentNode);
}
function dragend(lThis, d) {
var brush = d.brush;
var filter = brush.filter;
var s = brush.svgBrush;
if (!s._dragging) {
// i.e. click
// mock zero drag
mousemove(lThis, d);
drag(lThis, d);
// remember it is a click not a drag
d.brush.svgBrush.wasDragged = false;
}
s._dragging = false;
var e = d3.event;
e.sourceEvent.stopPropagation();
var grabbingBar = s.grabbingBar;
s.grabbingBar = false;
s.grabLocation = undefined;
d.parent.inBrushDrag = false;
clearCursor(); // instead of clearing, a nicer thing would be to set it according to current location
if (!s.wasDragged) {
// a click+release on the same spot (ie. w/o dragging) means a bar or full reset
s.wasDragged = undefined; // logic-wise unneeded, just shows `wasDragged` has no longer a meaning
if (s.clickableOrdinalRange) {
if (brush.filterSpecified && d.multiselect) {
s.extent.push(s.clickableOrdinalRange);
} else {
s.extent = [s.clickableOrdinalRange];
brush.filterSpecified = true;
}
} else if (grabbingBar) {
s.extent = s.stayingIntervals;
if (s.extent.length === 0) {
brushClear(brush);
}
} else {
brushClear(brush);
}
s.brushCallback(d);
renderHighlight(lThis.parentNode);
s.brushEndCallback(brush.filterSpecified ? filter.getConsolidated() : []);
return; // no need to fuse intervals or snap to ordinals, so we can bail early
}
var mergeIntervals = function () {
// Key piece of logic: once the button is released, possibly overlapping intervals will be fused:
// Here it's done immediately on click release while on ordinal snap transition it's done at the end
filter.set(filter.getConsolidated());
};
if (d.ordinal) {
var a = d.unitTickvals;
if (a[a.length - 1] < a[0]) a.reverse();
s.newExtent = [ordinalScaleSnap(0, a, s.newExtent[0], s.stayingIntervals), ordinalScaleSnap(1, a, s.newExtent[1], s.stayingIntervals)];
var hasNewExtent = s.newExtent[1] > s.newExtent[0];
s.extent = s.stayingIntervals.concat(hasNewExtent ? [s.newExtent] : []);
if (!s.extent.length) {
brushClear(brush);
}
s.brushCallback(d);
if (hasNewExtent) {
// merging intervals post the snap tween
renderHighlight(lThis.parentNode, mergeIntervals);
} else {
// if no new interval, don't animate, just redraw the highlight immediately
mergeIntervals();
renderHighlight(lThis.parentNode);
}
} else {
mergeIntervals(); // merging intervals immediately
}
s.brushEndCallback(brush.filterSpecified ? filter.getConsolidated() : []);
}
function mousemove(lThis, d) {
var y = d.height - d3.mouse(lThis)[1] - 2 * c.verticalPadding;
var interval = getInterval(d, y);
var cursor = 'crosshair';
if (interval.clickableOrdinalRange) cursor = 'pointer';else if (interval.region) cursor = interval.region + '-resize';
d3.select(document.body).style('cursor', cursor);
}
function attachDragBehavior(selection) {
// There's some fiddling with pointer cursor styling so that the cursor preserves its shape while dragging a brush
// even if the cursor strays from the interacting bar, which is bound to happen as bars are thin and the user
// will inevitably leave the hotspot strip. In this regard, it does something similar to what the D3 brush would do.
selection.on('mousemove', function (d) {
d3.event.preventDefault();
if (!d.parent.inBrushDrag) mousemove(this, d);
}).on('mouseleave', function (d) {
if (!d.parent.inBrushDrag) clearCursor();
}).call(d3.behavior.drag().on('dragstart', function (d) {
dragstart(this, d);
}).on('drag', function (d) {
drag(this, d);
}).on('dragend', function (d) {
dragend(this, d);
}));
}
function startAsc(a, b) {
return a[0] - b[0];
}
function renderAxisBrush(axisBrush, paperColor, gd) {
var isStatic = gd._context.staticPlot;
var background = axisBrush.selectAll('.background').data(repeat);
background.enter().append('rect').classed('background', true).call(barHorizontalSetup).call(backgroundBarHorizontalSetup).style('pointer-events', isStatic ? 'none' : 'auto') // parent pointer events are disabled; we must have it to register events
.attr('transform', strTranslate(0, c.verticalPadding));
background.call(attachDragBehavior).attr('height', function (d) {
return d.height - c.verticalPadding;
});
var highlightShadow = axisBrush.selectAll('.highlight-shadow').data(repeat); // we have a set here, can't call it `extent`
highlightShadow.enter().append('line').classed('highlight-shadow', true).attr('x', -c.bar.width / 2).attr('stroke-width', c.bar.width + c.bar.strokeWidth).attr('stroke', paperColor).attr('opacity', c.bar.strokeOpacity).attr('stroke-linecap', 'butt');
highlightShadow.attr('y1', function (d) {
return d.height;
}).call(styleHighlight);
var highlight = axisBrush.selectAll('.highlight').data(repeat); // we have a set here, can't call it `extent`
highlight.enter().append('line').classed('highlight', true).attr('x', -c.bar.width / 2).attr('stroke-width', c.bar.width - c.bar.strokeWidth).attr('stroke', c.bar.fillColor).attr('opacity', c.bar.fillOpacity).attr('stroke-linecap', 'butt');
highlight.attr('y1', function (d) {
return d.height;
}).call(styleHighlight);
}
function ensureAxisBrush(axisOverlays, paperColor, gd) {
var axisBrush = axisOverlays.selectAll('.' + c.cn.axisBrush).data(repeat, keyFun);
axisBrush.enter().append('g').classed(c.cn.axisBrush, true);
renderAxisBrush(axisBrush, paperColor, gd);
}
function getBrushExtent(brush) {
return brush.svgBrush.extent.map(function (e) {
return e.slice();
});
}
function brushClear(brush) {
brush.filterSpecified = false;
brush.svgBrush.extent = [[-Infinity, Infinity]];
}
function axisBrushMoved(callback) {
return function axisBrushMoved(dimension) {
var brush = dimension.brush;
var extent = getBrushExtent(brush);
var newExtent = extent.slice();
brush.filter.set(newExtent);
callback();
};
}
function dedupeRealRanges(intervals) {
// Fuses elements of intervals if they overlap, yielding discontiguous intervals, results.length <= intervals.length
// Currently uses closed intervals, ie. dedupeRealRanges([[400, 800], [300, 400]]) -> [300, 800]
var queue = intervals.slice();
var result = [];
var currentInterval;
var current = queue.shift();
while (current) {
// [].shift === undefined, so we don't descend into an empty array
currentInterval = current.slice();
while ((current = queue.shift()) && current[0] <= /* right-open interval would need `<` */currentInterval[1]) {
currentInterval[1] = Math.max(currentInterval[1], current[1]);
}
result.push(currentInterval);
}
if (result.length === 1 && result[0][0] > result[0][1]) {
// discard result
result = [];
}
return result;
}
function makeFilter() {
var filter = [];
var consolidated;
var bounds;
return {
set: function (a) {
filter = a.map(function (d) {
return d.slice().sort(sortAsc);
}).sort(startAsc);
// handle unselected case
if (filter.length === 1 && filter[0][0] === -Infinity && filter[0][1] === Infinity) {
filter = [[0, -1]];
}
consolidated = dedupeRealRanges(filter);
bounds = filter.reduce(function (p, n) {
return [Math.min(p[0], n[0]), Math.max(p[1], n[1])];
}, [Infinity, -Infinity]);
},
get: function () {
return filter.slice();
},
getConsolidated: function () {
return consolidated;
},
getBounds: function () {
return bounds;
}
};
}
function makeBrush(state, rangeSpecified, initialRange, brushStartCallback, brushCallback, brushEndCallback) {
var filter = makeFilter();
filter.set(initialRange);
return {
filter: filter,
filterSpecified: rangeSpecified,
// there's a difference between not filtering and filtering a non-proper subset
svgBrush: {
extent: [],
// this is where the svgBrush writes contents into
brushStartCallback: brushStartCallback,
brushCallback: axisBrushMoved(brushCallback),
brushEndCallback: brushEndCallback
}
};
}
// for use by supplyDefaults, but it needed tons of pieces from here so
// seemed to make more sense just to put the whole routine here
function cleanRanges(ranges, dimension) {
if (Array.isArray(ranges[0])) {
ranges = ranges.map(function (ri) {
return ri.sort(sortAsc);
});
if (!dimension.multiselect) ranges = [ranges[0]];else ranges = dedupeRealRanges(ranges.sort(startAsc));
} else ranges = [ranges.sort(sortAsc)];
// ordinal snapping
if (dimension.tickvals) {
var sortedTickVals = dimension.tickvals.slice().sort(sortAsc);
ranges = ranges.map(function (ri) {
var rSnapped = [ordinalScaleSnap(0, sortedTickVals, ri[0], []), ordinalScaleSnap(1, sortedTickVals, ri[1], [])];
if (rSnapped[1] > rSnapped[0]) return rSnapped;
}).filter(function (ri) {
return ri;
});
if (!ranges.length) return;
}
return ranges.length > 1 ? ranges : ranges[0];
}
module.exports = {
makeBrush: makeBrush,
ensureAxisBrush: ensureAxisBrush,
cleanRanges: cleanRanges
};
/***/ }),
/***/ 61664:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
module.exports = {
attributes: __webpack_require__(82296),
supplyDefaults: __webpack_require__(60664),
calc: __webpack_require__(95044),
colorbar: {
container: 'line',
min: 'cmin',
max: 'cmax'
},
moduleType: 'trace',
name: 'parcoords',
basePlotModule: __webpack_require__(19976),
categories: ['gl', 'regl', 'noOpacity', 'noHover'],
meta: {}
};
/***/ }),
/***/ 19976:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var d3 = __webpack_require__(33428);
var getModuleCalcData = (__webpack_require__(84888)/* .getModuleCalcData */ ._M);
var parcoordsPlot = __webpack_require__(24196);
var xmlnsNamespaces = __webpack_require__(9616);
exports.name = 'parcoords';
exports.plot = function (gd) {
var calcData = getModuleCalcData(gd.calcdata, 'parcoords')[0];
if (calcData.length) parcoordsPlot(gd, calcData);
};
exports.clean = function (newFullData, newFullLayout, oldFullData, oldFullLayout) {
var hadParcoords = oldFullLayout._has && oldFullLayout._has('parcoords');
var hasParcoords = newFullLayout._has && newFullLayout._has('parcoords');
if (hadParcoords && !hasParcoords) {
oldFullLayout._paperdiv.selectAll('.parcoords').remove();
oldFullLayout._glimages.selectAll('*').remove();
}
};
exports.toSVG = function (gd) {
var imageRoot = gd._fullLayout._glimages;
var root = d3.select(gd).selectAll('.svg-container');
var canvases = root.filter(function (d, i) {
return i === root.size() - 1;
}).selectAll('.gl-canvas-context, .gl-canvas-focus');
function canvasToImage() {
var canvas = this;
var imageData = canvas.toDataURL('image/png');
var image = imageRoot.append('svg:image');
image.attr({
xmlns: xmlnsNamespaces.svg,
'xlink:href': imageData,
preserveAspectRatio: 'none',
x: 0,
y: 0,
width: canvas.style.width,
height: canvas.style.height
});
}
canvases.each(canvasToImage);
// Chrome / Safari bug workaround - browser apparently loses connection to the defined pattern
// Without the workaround, these browsers 'lose' the filter brush styling (color etc.) after a snapshot
// on a subsequent interaction.
// Firefox works fine without this workaround
window.setTimeout(function () {
d3.selectAll('#filterBarPattern').attr('id', 'filterBarPattern');
}, 60);
};
/***/ }),
/***/ 95044:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isArrayOrTypedArray = (__webpack_require__(3400).isArrayOrTypedArray);
var Colorscale = __webpack_require__(8932);
var wrap = (__webpack_require__(71688).wrap);
module.exports = function calc(gd, trace) {
var lineColor;
var cscale;
if (Colorscale.hasColorscale(trace, 'line') && isArrayOrTypedArray(trace.line.color)) {
lineColor = trace.line.color;
cscale = Colorscale.extractOpts(trace.line).colorscale;
Colorscale.calc(gd, trace, {
vals: lineColor,
containerStr: 'line',
cLetter: 'c'
});
} else {
lineColor = constHalf(trace._length);
cscale = [[0, trace.line.color], [1, trace.line.color]];
}
return wrap({
lineColor: lineColor,
cscale: cscale
});
};
function constHalf(len) {
var out = new Array(len);
for (var i = 0; i < len; i++) {
out[i] = 0.5;
}
return out;
}
/***/ }),
/***/ 30140:
/***/ (function(module) {
"use strict";
module.exports = {
maxDimensionCount: 60,
// this cannot be increased without WebGL code refactoring
overdrag: 45,
verticalPadding: 2,
// otherwise, horizontal lines on top or bottom are of lower width
tickDistance: 50,
canvasPixelRatio: 1,
blockLineCount: 5000,
layers: ['contextLineLayer', 'focusLineLayer', 'pickLineLayer'],
axisTitleOffset: 28,
axisExtentOffset: 10,
bar: {
width: 4,
// Visible width of the filter bar
captureWidth: 10,
// Mouse-sensitive width for interaction (Fitts law)
fillColor: 'magenta',
// Color of the filter bar fill
fillOpacity: 1,
// Filter bar fill opacity
snapDuration: 150,
// tween duration in ms for brush snap for ordinal axes
snapRatio: 0.25,
// ratio of bar extension relative to the distance between two adjacent ordinal values
snapClose: 0.01,
// fraction of inter-value distance to snap to the closer one, even if you're not over it
strokeOpacity: 1,
// Filter bar side stroke opacity
strokeWidth: 1,
// Filter bar side stroke width in pixels
handleHeight: 8,
// Height of the filter bar vertical resize areas on top and bottom
handleOpacity: 1,
// Opacity of the filter bar vertical resize areas on top and bottom
handleOverlap: 0 // A larger than 0 value causes overlaps with the filter bar, represented as pixels
},
cn: {
axisExtentText: 'axis-extent-text',
parcoordsLineLayers: 'parcoords-line-layers',
parcoordsLineLayer: 'parcoords-lines',
parcoords: 'parcoords',
parcoordsControlView: 'parcoords-control-view',
yAxis: 'y-axis',
axisOverlays: 'axis-overlays',
axis: 'axis',
axisHeading: 'axis-heading',
axisTitle: 'axis-title',
axisExtent: 'axis-extent',
axisExtentTop: 'axis-extent-top',
axisExtentTopText: 'axis-extent-top-text',
axisExtentBottom: 'axis-extent-bottom',
axisExtentBottomText: 'axis-extent-bottom-text',
axisBrush: 'axis-brush'
},
id: {
filterBarPattern: 'filter-bar-pattern'
}
};
/***/ }),
/***/ 60664:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var hasColorscale = (__webpack_require__(94288).hasColorscale);
var colorscaleDefaults = __webpack_require__(27260);
var handleDomainDefaults = (__webpack_require__(86968)/* .defaults */ .Q);
var handleArrayContainerDefaults = __webpack_require__(51272);
var Axes = __webpack_require__(54460);
var attributes = __webpack_require__(82296);
var axisBrush = __webpack_require__(71864);
var maxDimensionCount = (__webpack_require__(30140).maxDimensionCount);
var mergeLength = __webpack_require__(26284);
function handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce) {
var lineColor = coerce('line.color', defaultColor);
if (hasColorscale(traceIn, 'line') && Lib.isArrayOrTypedArray(lineColor)) {
if (lineColor.length) {
coerce('line.colorscale');
colorscaleDefaults(traceIn, traceOut, layout, coerce, {
prefix: 'line.',
cLetter: 'c'
});
// TODO: I think it would be better to keep showing lines beyond the last line color
// but I'm not sure what color to give these lines - probably black or white
// depending on the background color?
return lineColor.length;
} else {
traceOut.line.color = defaultColor;
}
}
return Infinity;
}
function dimensionDefaults(dimensionIn, dimensionOut, parentOut, opts) {
function coerce(attr, dflt) {
return Lib.coerce(dimensionIn, dimensionOut, attributes.dimensions, attr, dflt);
}
var values = coerce('values');
var visible = coerce('visible');
if (!(values && values.length)) {
visible = dimensionOut.visible = false;
}
if (visible) {
coerce('label');
coerce('tickvals');
coerce('ticktext');
coerce('tickformat');
var range = coerce('range');
dimensionOut._ax = {
_id: 'y',
type: 'linear',
showexponent: 'all',
exponentformat: 'B',
range: range
};
Axes.setConvert(dimensionOut._ax, opts.layout);
coerce('multiselect');
var constraintRange = coerce('constraintrange');
if (constraintRange) {
dimensionOut.constraintrange = axisBrush.cleanRanges(constraintRange, dimensionOut);
}
}
}
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var dimensionsIn = traceIn.dimensions;
if (Array.isArray(dimensionsIn) && dimensionsIn.length > maxDimensionCount) {
Lib.log('parcoords traces support up to ' + maxDimensionCount + ' dimensions at the moment');
dimensionsIn.splice(maxDimensionCount);
}
var dimensions = handleArrayContainerDefaults(traceIn, traceOut, {
name: 'dimensions',
layout: layout,
handleItemDefaults: dimensionDefaults
});
var len = handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
handleDomainDefaults(traceOut, layout, coerce);
if (!Array.isArray(dimensions) || !dimensions.length) {
traceOut.visible = false;
}
mergeLength(traceOut, dimensions, 'values', len);
// make default font size 10px (default is 12),
// scale linearly with global font size
var fontDflt = {
family: layout.font.family,
size: Math.round(layout.font.size / 1.2),
color: layout.font.color
};
Lib.coerceFont(coerce, 'labelfont', fontDflt);
Lib.coerceFont(coerce, 'tickfont', fontDflt);
Lib.coerceFont(coerce, 'rangefont', fontDflt);
coerce('labelangle');
coerce('labelside');
coerce('unselected.line.color');
coerce('unselected.line.opacity');
};
/***/ }),
/***/ 95724:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var isTypedArray = (__webpack_require__(3400).isTypedArray);
exports.convertTypedArray = function (a) {
return isTypedArray(a) ? Array.prototype.slice.call(a) : a;
};
exports.isOrdinal = function (dimension) {
return !!dimension.tickvals;
};
exports.isVisible = function (dimension) {
return dimension.visible || !('visible' in dimension);
};
/***/ }),
/***/ 29928:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var index = __webpack_require__(61664);
index.plot = __webpack_require__(24196);
module.exports = index;
/***/ }),
/***/ 51352:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var vertexShaderSource = ['precision highp float;', '', 'varying vec4 fragColor;', '', 'attribute vec4 p01_04, p05_08, p09_12, p13_16,', ' p17_20, p21_24, p25_28, p29_32,', ' p33_36, p37_40, p41_44, p45_48,', ' p49_52, p53_56, p57_60, colors;', '', 'uniform mat4 dim0A, dim1A, dim0B, dim1B, dim0C, dim1C, dim0D, dim1D,', ' loA, hiA, loB, hiB, loC, hiC, loD, hiD;', '', 'uniform vec2 resolution, viewBoxPos, viewBoxSize;', 'uniform float maskHeight;', 'uniform float drwLayer; // 0: context, 1: focus, 2: pick', 'uniform vec4 contextColor;', 'uniform sampler2D maskTexture, palette;', '', 'bool isPick = (drwLayer > 1.5);', 'bool isContext = (drwLayer < 0.5);', '', 'const vec4 ZEROS = vec4(0.0, 0.0, 0.0, 0.0);', 'const vec4 UNITS = vec4(1.0, 1.0, 1.0, 1.0);', '', 'float val(mat4 p, mat4 v) {', ' return dot(matrixCompMult(p, v) * UNITS, UNITS);', '}', '', 'float axisY(float ratio, mat4 A, mat4 B, mat4 C, mat4 D) {', ' float y1 = val(A, dim0A) + val(B, dim0B) + val(C, dim0C) + val(D, dim0D);', ' float y2 = val(A, dim1A) + val(B, dim1B) + val(C, dim1C) + val(D, dim1D);', ' return y1 * (1.0 - ratio) + y2 * ratio;', '}', '', 'int iMod(int a, int b) {', ' return a - b * (a / b);', '}', '', 'bool fOutside(float p, float lo, float hi) {', ' return (lo < hi) && (lo > p || p > hi);', '}', '', 'bool vOutside(vec4 p, vec4 lo, vec4 hi) {', ' return (', ' fOutside(p[0], lo[0], hi[0]) ||', ' fOutside(p[1], lo[1], hi[1]) ||', ' fOutside(p[2], lo[2], hi[2]) ||', ' fOutside(p[3], lo[3], hi[3])', ' );', '}', '', 'bool mOutside(mat4 p, mat4 lo, mat4 hi) {', ' return (', ' vOutside(p[0], lo[0], hi[0]) ||', ' vOutside(p[1], lo[1], hi[1]) ||', ' vOutside(p[2], lo[2], hi[2]) ||', ' vOutside(p[3], lo[3], hi[3])', ' );', '}', '', 'bool outsideBoundingBox(mat4 A, mat4 B, mat4 C, mat4 D) {', ' return mOutside(A, loA, hiA) ||', ' mOutside(B, loB, hiB) ||', ' mOutside(C, loC, hiC) ||', ' mOutside(D, loD, hiD);', '}', '', 'bool outsideRasterMask(mat4 A, mat4 B, mat4 C, mat4 D) {', ' mat4 pnts[4];', ' pnts[0] = A;', ' pnts[1] = B;', ' pnts[2] = C;', ' pnts[3] = D;', '', ' for(int i = 0; i < 4; ++i) {', ' for(int j = 0; j < 4; ++j) {', ' for(int k = 0; k < 4; ++k) {', ' if(0 == iMod(', ' int(255.0 * texture2D(maskTexture,', ' vec2(', ' (float(i * 2 + j / 2) + 0.5) / 8.0,', ' (pnts[i][j][k] * (maskHeight - 1.0) + 1.0) / maskHeight', ' ))[3]', ' ) / int(pow(2.0, float(iMod(j * 4 + k, 8)))),', ' 2', ' )) return true;', ' }', ' }', ' }', ' return false;', '}', '', 'vec4 position(bool isContext, float v, mat4 A, mat4 B, mat4 C, mat4 D) {', ' float x = 0.5 * sign(v) + 0.5;', ' float y = axisY(x, A, B, C, D);', ' float z = 1.0 - abs(v);', '', ' z += isContext ? 0.0 : 2.0 * float(', ' outsideBoundingBox(A, B, C, D) ||', ' outsideRasterMask(A, B, C, D)', ' );', '', ' return vec4(', ' 2.0 * (vec2(x, y) * viewBoxSize + viewBoxPos) / resolution - 1.0,', ' z,', ' 1.0', ' );', '}', '', 'void main() {', ' mat4 A = mat4(p01_04, p05_08, p09_12, p13_16);', ' mat4 B = mat4(p17_20, p21_24, p25_28, p29_32);', ' mat4 C = mat4(p33_36, p37_40, p41_44, p45_48);', ' mat4 D = mat4(p49_52, p53_56, p57_60, ZEROS);', '', ' float v = colors[3];', '', ' gl_Position = position(isContext, v, A, B, C, D);', '', ' fragColor =', ' isContext ? vec4(contextColor) :', ' isPick ? vec4(colors.rgb, 1.0) : texture2D(palette, vec2(abs(v), 0.5));', '}'].join('\n');
var fragmentShaderSource = ['precision highp float;', '', 'varying vec4 fragColor;', '', 'void main() {', ' gl_FragColor = fragColor;', '}'].join('\n');
var maxDim = (__webpack_require__(30140).maxDimensionCount);
var Lib = __webpack_require__(3400);
// don't change; otherwise near/far plane lines are lost
var depthLimitEpsilon = 1e-6;
// precision of multiselect is the full range divided into this many parts
var maskHeight = 2048;
var dummyPixel = new Uint8Array(4);
var dataPixel = new Uint8Array(4);
var paletteTextureConfig = {
shape: [256, 1],
format: 'rgba',
type: 'uint8',
mag: 'nearest',
min: 'nearest'
};
function ensureDraw(regl) {
regl.read({
x: 0,
y: 0,
width: 1,
height: 1,
data: dummyPixel
});
}
function clear(regl, x, y, width, height) {
var gl = regl._gl;
gl.enable(gl.SCISSOR_TEST);
gl.scissor(x, y, width, height);
regl.clear({
color: [0, 0, 0, 0],
depth: 1
}); // clearing is done in scissored panel only
}
function renderBlock(regl, glAes, renderState, blockLineCount, sampleCount, item) {
var rafKey = item.key;
function render(blockNumber) {
var count = Math.min(blockLineCount, sampleCount - blockNumber * blockLineCount);
if (blockNumber === 0) {
// stop drawing possibly stale glyphs before clearing
window.cancelAnimationFrame(renderState.currentRafs[rafKey]);
delete renderState.currentRafs[rafKey];
clear(regl, item.scissorX, item.scissorY, item.scissorWidth, item.viewBoxSize[1]);
}
if (renderState.clearOnly) {
return;
}
item.count = 2 * count;
item.offset = 2 * blockNumber * blockLineCount;
glAes(item);
if (blockNumber * blockLineCount + count < sampleCount) {
renderState.currentRafs[rafKey] = window.requestAnimationFrame(function () {
render(blockNumber + 1);
});
}
renderState.drawCompleted = false;
}
if (!renderState.drawCompleted) {
ensureDraw(regl);
renderState.drawCompleted = true;
}
// start with rendering item 0; recursion handles the rest
render(0);
}
function adjustDepth(d) {
// WebGL matrix operations use floats with limited precision, potentially causing a number near a border of [0, 1]
// to end up slightly outside the border. With an epsilon, we reduce the chance that a line gets clipped by the
// near or the far plane.
return Math.max(depthLimitEpsilon, Math.min(1 - depthLimitEpsilon, d));
}
function palette(unitToColor, opacity) {
var result = new Array(256);
for (var i = 0; i < 256; i++) {
result[i] = unitToColor(i / 255).concat(opacity);
}
return result;
}
// Maps the sample index [0...sampleCount - 1] to a range of [0, 1] as the shader expects colors in the [0, 1] range.
// but first it shifts the sample index by 0, 8 or 16 bits depending on rgbIndex [0..2]
// with the end result that each line will be of a unique color, making it possible for the pick handler
// to uniquely identify which line is hovered over (bijective mapping).
// The inverse, i.e. readPixel is invoked from 'parcoords.js'
function calcPickColor(i, rgbIndex) {
return (i >>> 8 * rgbIndex) % 256 / 255;
}
function makePoints(sampleCount, dims, color) {
var points = new Array(sampleCount * (maxDim + 4));
var n = 0;
for (var i = 0; i < sampleCount; i++) {
for (var k = 0; k < maxDim; k++) {
points[n++] = k < dims.length ? dims[k].paddedUnitValues[i] : 0.5;
}
points[n++] = calcPickColor(i, 2);
points[n++] = calcPickColor(i, 1);
points[n++] = calcPickColor(i, 0);
points[n++] = adjustDepth(color[i]);
}
return points;
}
function makeVecAttr(vecIndex, sampleCount, points) {
var pointPairs = new Array(sampleCount * 8);
var n = 0;
for (var i = 0; i < sampleCount; i++) {
for (var j = 0; j < 2; j++) {
for (var k = 0; k < 4; k++) {
var q = vecIndex * 4 + k;
var v = points[i * 64 + q];
if (q === 63 && j === 0) {
v *= -1;
}
pointPairs[n++] = v;
}
}
}
return pointPairs;
}
function pad2(num) {
var s = '0' + num;
return s.substr(s.length - 2);
}
function getAttrName(i) {
return i < maxDim ? 'p' + pad2(i + 1) + '_' + pad2(i + 4) : 'colors';
}
function setAttributes(attributes, sampleCount, points) {
for (var i = 0; i <= maxDim; i += 4) {
attributes[getAttrName(i)](makeVecAttr(i / 4, sampleCount, points));
}
}
function emptyAttributes(regl) {
var attributes = {};
for (var i = 0; i <= maxDim; i += 4) {
attributes[getAttrName(i)] = regl.buffer({
usage: 'dynamic',
type: 'float',
data: new Uint8Array(0)
});
}
return attributes;
}
function makeItem(model, leftmost, rightmost, itemNumber, i0, i1, x, y, panelSizeX, panelSizeY, crossfilterDimensionIndex, drwLayer, constraints, plotGlPixelRatio) {
var dims = [[], []];
for (var k = 0; k < 64; k++) {
dims[0][k] = k === i0 ? 1 : 0;
dims[1][k] = k === i1 ? 1 : 0;
}
x *= plotGlPixelRatio;
y *= plotGlPixelRatio;
panelSizeX *= plotGlPixelRatio;
panelSizeY *= plotGlPixelRatio;
var overdrag = model.lines.canvasOverdrag * plotGlPixelRatio;
var domain = model.domain;
var canvasWidth = model.canvasWidth * plotGlPixelRatio;
var canvasHeight = model.canvasHeight * plotGlPixelRatio;
var padL = model.pad.l * plotGlPixelRatio;
var padB = model.pad.b * plotGlPixelRatio;
var layoutHeight = model.layoutHeight * plotGlPixelRatio;
var layoutWidth = model.layoutWidth * plotGlPixelRatio;
var deselectedLinesColor = model.deselectedLines.color;
var deselectedLinesOpacity = model.deselectedLines.opacity;
var itemModel = Lib.extendFlat({
key: crossfilterDimensionIndex,
resolution: [canvasWidth, canvasHeight],
viewBoxPos: [x + overdrag, y],
viewBoxSize: [panelSizeX, panelSizeY],
i0: i0,
i1: i1,
dim0A: dims[0].slice(0, 16),
dim0B: dims[0].slice(16, 32),
dim0C: dims[0].slice(32, 48),
dim0D: dims[0].slice(48, 64),
dim1A: dims[1].slice(0, 16),
dim1B: dims[1].slice(16, 32),
dim1C: dims[1].slice(32, 48),
dim1D: dims[1].slice(48, 64),
drwLayer: drwLayer,
contextColor: [deselectedLinesColor[0] / 255, deselectedLinesColor[1] / 255, deselectedLinesColor[2] / 255, deselectedLinesOpacity !== 'auto' ? deselectedLinesColor[3] * deselectedLinesOpacity : Math.max(1 / 255, Math.pow(1 / model.lines.color.length, 1 / 3))],
scissorX: (itemNumber === leftmost ? 0 : x + overdrag) + (padL - overdrag) + layoutWidth * domain.x[0],
scissorWidth: (itemNumber === rightmost ? canvasWidth - x + overdrag : panelSizeX + 0.5) + (itemNumber === leftmost ? x + overdrag : 0),
scissorY: y + padB + layoutHeight * domain.y[0],
scissorHeight: panelSizeY,
viewportX: padL - overdrag + layoutWidth * domain.x[0],
viewportY: padB + layoutHeight * domain.y[0],
viewportWidth: canvasWidth,
viewportHeight: canvasHeight
}, constraints);
return itemModel;
}
function expandedPixelRange(bounds) {
var dh = maskHeight - 1;
var a = Math.max(0, Math.floor(bounds[0] * dh), 0);
var b = Math.min(dh, Math.ceil(bounds[1] * dh), dh);
return [Math.min(a, b), Math.max(a, b)];
}
module.exports = function (canvasGL, d) {
// context & pick describe which canvas we're talking about - won't change with new data
var isContext = d.context;
var isPick = d.pick;
var regl = d.regl;
var gl = regl._gl;
var supportedLineWidth = gl.getParameter(gl.ALIASED_LINE_WIDTH_RANGE);
// ensure here that plotGlPixelRatio is within supported range; otherwise regl throws error
var plotGlPixelRatio = Math.max(supportedLineWidth[0], Math.min(supportedLineWidth[1], d.viewModel.plotGlPixelRatio));
var renderState = {
currentRafs: {},
drawCompleted: true,
clearOnly: false
};
// state to be set by update and used later
var model;
var vm;
var initialDims;
var sampleCount;
var attributes = emptyAttributes(regl);
var maskTexture;
var paletteTexture = regl.texture(paletteTextureConfig);
var prevAxisOrder = [];
update(d);
var glAes = regl({
profile: false,
blend: {
enable: isContext,
func: {
srcRGB: 'src alpha',
dstRGB: 'one minus src alpha',
srcAlpha: 1,
dstAlpha: 1 // 'one minus src alpha'
},
equation: {
rgb: 'add',
alpha: 'add'
},
color: [0, 0, 0, 0]
},
depth: {
enable: !isContext,
mask: true,
func: 'less',
range: [0, 1]
},
// for polygons
cull: {
enable: true,
face: 'back'
},
scissor: {
enable: true,
box: {
x: regl.prop('scissorX'),
y: regl.prop('scissorY'),
width: regl.prop('scissorWidth'),
height: regl.prop('scissorHeight')
}
},
viewport: {
x: regl.prop('viewportX'),
y: regl.prop('viewportY'),
width: regl.prop('viewportWidth'),
height: regl.prop('viewportHeight')
},
dither: false,
vert: vertexShaderSource,
frag: fragmentShaderSource,
primitive: 'lines',
lineWidth: plotGlPixelRatio,
attributes: attributes,
uniforms: {
resolution: regl.prop('resolution'),
viewBoxPos: regl.prop('viewBoxPos'),
viewBoxSize: regl.prop('viewBoxSize'),
dim0A: regl.prop('dim0A'),
dim1A: regl.prop('dim1A'),
dim0B: regl.prop('dim0B'),
dim1B: regl.prop('dim1B'),
dim0C: regl.prop('dim0C'),
dim1C: regl.prop('dim1C'),
dim0D: regl.prop('dim0D'),
dim1D: regl.prop('dim1D'),
loA: regl.prop('loA'),
hiA: regl.prop('hiA'),
loB: regl.prop('loB'),
hiB: regl.prop('hiB'),
loC: regl.prop('loC'),
hiC: regl.prop('hiC'),
loD: regl.prop('loD'),
hiD: regl.prop('hiD'),
palette: paletteTexture,
contextColor: regl.prop('contextColor'),
maskTexture: regl.prop('maskTexture'),
drwLayer: regl.prop('drwLayer'),
maskHeight: regl.prop('maskHeight')
},
offset: regl.prop('offset'),
count: regl.prop('count')
});
function update(dNew) {
model = dNew.model;
vm = dNew.viewModel;
initialDims = vm.dimensions.slice();
sampleCount = initialDims[0] ? initialDims[0].values.length : 0;
var lines = model.lines;
var color = isPick ? lines.color.map(function (_, i) {
return i / lines.color.length;
}) : lines.color;
var points = makePoints(sampleCount, initialDims, color);
setAttributes(attributes, sampleCount, points);
if (!isContext && !isPick) {
paletteTexture = regl.texture(Lib.extendFlat({
data: palette(model.unitToColor, 255)
}, paletteTextureConfig));
}
}
function makeConstraints(isContext) {
var i, j, k;
var limits = [[], []];
for (k = 0; k < 64; k++) {
var p = !isContext && k < initialDims.length ? initialDims[k].brush.filter.getBounds() : [-Infinity, Infinity];
limits[0][k] = p[0];
limits[1][k] = p[1];
}
var len = maskHeight * 8;
var mask = new Array(len);
for (i = 0; i < len; i++) {
mask[i] = 255;
}
if (!isContext) {
for (i = 0; i < initialDims.length; i++) {
var u = i % 8;
var v = (i - u) / 8;
var bitMask = Math.pow(2, u);
var dim = initialDims[i];
var ranges = dim.brush.filter.get();
if (ranges.length < 2) continue; // bail if the bounding box based filter is sufficient
var prevEnd = expandedPixelRange(ranges[0])[1];
for (j = 1; j < ranges.length; j++) {
var nextRange = expandedPixelRange(ranges[j]);
for (k = prevEnd + 1; k < nextRange[0]; k++) {
mask[k * 8 + v] &= ~bitMask;
}
prevEnd = Math.max(prevEnd, nextRange[1]);
}
}
}
var textureData = {
// 8 units x 8 bits = 64 bits, just sufficient for the almost 64 dimensions we support
shape: [8, maskHeight],
format: 'alpha',
type: 'uint8',
mag: 'nearest',
min: 'nearest',
data: mask
};
if (maskTexture) maskTexture(textureData);else maskTexture = regl.texture(textureData);
return {
maskTexture: maskTexture,
maskHeight: maskHeight,
loA: limits[0].slice(0, 16),
loB: limits[0].slice(16, 32),
loC: limits[0].slice(32, 48),
loD: limits[0].slice(48, 64),
hiA: limits[1].slice(0, 16),
hiB: limits[1].slice(16, 32),
hiC: limits[1].slice(32, 48),
hiD: limits[1].slice(48, 64)
};
}
function renderGLParcoords(panels, setChanged, clearOnly) {
var panelCount = panels.length;
var i;
var leftmost;
var rightmost;
var lowestX = Infinity;
var highestX = -Infinity;
for (i = 0; i < panelCount; i++) {
if (panels[i].dim0.canvasX < lowestX) {
lowestX = panels[i].dim0.canvasX;
leftmost = i;
}
if (panels[i].dim1.canvasX > highestX) {
highestX = panels[i].dim1.canvasX;
rightmost = i;
}
}
if (panelCount === 0) {
// clear canvas here, as the panel iteration below will not enter the loop body
clear(regl, 0, 0, model.canvasWidth, model.canvasHeight);
}
var constraints = makeConstraints(isContext);
for (i = 0; i < panelCount; i++) {
var p = panels[i];
var i0 = p.dim0.crossfilterDimensionIndex;
var i1 = p.dim1.crossfilterDimensionIndex;
var x = p.canvasX;
var y = p.canvasY;
var nextX = x + p.panelSizeX;
var plotGlPixelRatio = p.plotGlPixelRatio;
if (setChanged || !prevAxisOrder[i0] || prevAxisOrder[i0][0] !== x || prevAxisOrder[i0][1] !== nextX) {
prevAxisOrder[i0] = [x, nextX];
var item = makeItem(model, leftmost, rightmost, i, i0, i1, x, y, p.panelSizeX, p.panelSizeY, p.dim0.crossfilterDimensionIndex, isContext ? 0 : isPick ? 2 : 1, constraints, plotGlPixelRatio);
renderState.clearOnly = clearOnly;
var blockLineCount = setChanged ? model.lines.blockLineCount : sampleCount;
renderBlock(regl, glAes, renderState, blockLineCount, sampleCount, item);
}
}
}
function readPixel(canvasX, canvasY) {
regl.read({
x: canvasX,
y: canvasY,
width: 1,
height: 1,
data: dataPixel
});
return dataPixel;
}
function readPixels(canvasX, canvasY, width, height) {
var pixelArray = new Uint8Array(4 * width * height);
regl.read({
x: canvasX,
y: canvasY,
width: width,
height: height,
data: pixelArray
});
return pixelArray;
}
function destroy() {
canvasGL.style['pointer-events'] = 'none';
paletteTexture.destroy();
if (maskTexture) maskTexture.destroy();
for (var k in attributes) attributes[k].destroy();
}
return {
render: renderGLParcoords,
readPixel: readPixel,
readPixels: readPixels,
destroy: destroy,
update: update
};
};
/***/ }),
/***/ 26284:
/***/ (function(module) {
"use strict";
/**
* mergeLength: set trace length as the minimum of all dimension data lengths
* and propagates this length into each dimension
*
* @param {object} traceOut: the fullData trace
* @param {Array(object)} dimensions: array of dimension objects
* @param {string} dataAttr: the attribute of each dimension containing the data
* @param {integer} len: an already-existing length from other attributes
*/
module.exports = function (traceOut, dimensions, dataAttr, len) {
if (!len) len = Infinity;
var i, dimi;
for (i = 0; i < dimensions.length; i++) {
dimi = dimensions[i];
if (dimi.visible) len = Math.min(len, dimi[dataAttr].length);
}
if (len === Infinity) len = 0;
traceOut._length = len;
for (i = 0; i < dimensions.length; i++) {
dimi = dimensions[i];
if (dimi.visible) dimi._length = len;
}
return len;
};
/***/ }),
/***/ 36336:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var d3 = __webpack_require__(33428);
var Lib = __webpack_require__(3400);
var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
var numberFormat = Lib.numberFormat;
var rgba = __webpack_require__(96824);
var Axes = __webpack_require__(54460);
var strRotate = Lib.strRotate;
var strTranslate = Lib.strTranslate;
var svgTextUtils = __webpack_require__(72736);
var Drawing = __webpack_require__(43616);
var Colorscale = __webpack_require__(8932);
var gup = __webpack_require__(71688);
var keyFun = gup.keyFun;
var repeat = gup.repeat;
var unwrap = gup.unwrap;
var helpers = __webpack_require__(95724);
var c = __webpack_require__(30140);
var brush = __webpack_require__(71864);
var lineLayerMaker = __webpack_require__(51352);
function findExtreme(fn, values, len) {
return Lib.aggNums(fn, null, values, len);
}
function findExtremes(values, len) {
return fixExtremes(findExtreme(Math.min, values, len), findExtreme(Math.max, values, len));
}
function dimensionExtent(dimension) {
var range = dimension.range;
return range ? fixExtremes(range[0], range[1]) : findExtremes(dimension.values, dimension._length);
}
function fixExtremes(lo, hi) {
if (isNaN(lo) || !isFinite(lo)) {
lo = 0;
}
if (isNaN(hi) || !isFinite(hi)) {
hi = 0;
}
// avoid a degenerate (zero-width) domain
if (lo === hi) {
if (lo === 0) {
// no use to multiplying zero, so add/subtract in this case
lo -= 1;
hi += 1;
} else {
// this keeps the range in the order of magnitude of the data
lo *= 0.9;
hi *= 1.1;
}
}
return [lo, hi];
}
function toText(formatter, texts) {
if (texts) {
return function (v, i) {
var text = texts[i];
if (text === null || text === undefined) return formatter(v);
return text;
};
}
return formatter;
}
function domainScale(height, padding, dimension, tickvals, ticktext) {
var extent = dimensionExtent(dimension);
if (tickvals) {
return d3.scale.ordinal().domain(tickvals.map(toText(numberFormat(dimension.tickformat), ticktext))).range(tickvals.map(function (d) {
var unitVal = (d - extent[0]) / (extent[1] - extent[0]);
return height - padding + unitVal * (2 * padding - height);
}));
}
return d3.scale.linear().domain(extent).range([height - padding, padding]);
}
function unitToPaddedPx(height, padding) {
return d3.scale.linear().range([padding, height - padding]);
}
function domainToPaddedUnitScale(dimension, padFraction) {
return d3.scale.linear().domain(dimensionExtent(dimension)).range([padFraction, 1 - padFraction]);
}
function ordinalScale(dimension) {
if (!dimension.tickvals) return;
var extent = dimensionExtent(dimension);
return d3.scale.ordinal().domain(dimension.tickvals).range(dimension.tickvals.map(function (d) {
return (d - extent[0]) / (extent[1] - extent[0]);
}));
}
function unitToColorScale(cscale) {
var colorStops = cscale.map(function (d) {
return d[0];
});
var colorTuples = cscale.map(function (d) {
var RGBA = rgba(d[1]);
return d3.rgb('rgb(' + RGBA[0] + ',' + RGBA[1] + ',' + RGBA[2] + ')');
});
var prop = function (n) {
return function (o) {
return o[n];
};
};
// We can't use d3 color interpolation as we may have non-uniform color palette raster
// (various color stop distances).
var polylinearUnitScales = 'rgb'.split('').map(function (key) {
return d3.scale.linear().clamp(true).domain(colorStops).range(colorTuples.map(prop(key)));
});
return function (d) {
return polylinearUnitScales.map(function (s) {
return s(d);
});
};
}
function someFiltersActive(view) {
return view.dimensions.some(function (p) {
return p.brush.filterSpecified;
});
}
function model(layout, d, i) {
var cd0 = unwrap(d);
var trace = cd0.trace;
var lineColor = helpers.convertTypedArray(cd0.lineColor);
var line = trace.line;
var deselectedLines = {
color: rgba(trace.unselected.line.color),
opacity: trace.unselected.line.opacity
};
var cOpts = Colorscale.extractOpts(line);
var cscale = cOpts.reversescale ? Colorscale.flipScale(cd0.cscale) : cd0.cscale;
var domain = trace.domain;
var dimensions = trace.dimensions;
var width = layout.width;
var labelAngle = trace.labelangle;
var labelSide = trace.labelside;
var labelFont = trace.labelfont;
var tickFont = trace.tickfont;
var rangeFont = trace.rangefont;
var lines = Lib.extendDeepNoArrays({}, line, {
color: lineColor.map(d3.scale.linear().domain(dimensionExtent({
values: lineColor,
range: [cOpts.min, cOpts.max],
_length: trace._length
}))),
blockLineCount: c.blockLineCount,
canvasOverdrag: c.overdrag * c.canvasPixelRatio
});
var groupWidth = Math.floor(width * (domain.x[1] - domain.x[0]));
var groupHeight = Math.floor(layout.height * (domain.y[1] - domain.y[0]));
var pad = layout.margin || {
l: 80,
r: 80,
t: 100,
b: 80
};
var rowContentWidth = groupWidth;
var rowHeight = groupHeight;
return {
key: i,
colCount: dimensions.filter(helpers.isVisible).length,
dimensions: dimensions,
tickDistance: c.tickDistance,
unitToColor: unitToColorScale(cscale),
lines: lines,
deselectedLines: deselectedLines,
labelAngle: labelAngle,
labelSide: labelSide,
labelFont: labelFont,
tickFont: tickFont,
rangeFont: rangeFont,
layoutWidth: width,
layoutHeight: layout.height,
domain: domain,
translateX: domain.x[0] * width,
translateY: layout.height - domain.y[1] * layout.height,
pad: pad,
canvasWidth: rowContentWidth * c.canvasPixelRatio + 2 * lines.canvasOverdrag,
canvasHeight: rowHeight * c.canvasPixelRatio,
width: rowContentWidth,
height: rowHeight,
canvasPixelRatio: c.canvasPixelRatio
};
}
function viewModel(state, callbacks, model) {
var width = model.width;
var height = model.height;
var dimensions = model.dimensions;
var canvasPixelRatio = model.canvasPixelRatio;
var xScale = function (d) {
return width * d / Math.max(1, model.colCount - 1);
};
var unitPad = c.verticalPadding / height;
var _unitToPaddedPx = unitToPaddedPx(height, c.verticalPadding);
var vm = {
key: model.key,
xScale: xScale,
model: model,
inBrushDrag: false // consider factoring it out and putting it in a centralized global-ish gesture state object
};
var uniqueKeys = {};
vm.dimensions = dimensions.filter(helpers.isVisible).map(function (dimension, i) {
var domainToPaddedUnit = domainToPaddedUnitScale(dimension, unitPad);
var foundKey = uniqueKeys[dimension.label];
uniqueKeys[dimension.label] = (foundKey || 0) + 1;
var key = dimension.label + (foundKey ? '__' + foundKey : '');
var specifiedConstraint = dimension.constraintrange;
var filterRangeSpecified = specifiedConstraint && specifiedConstraint.length;
if (filterRangeSpecified && !isArrayOrTypedArray(specifiedConstraint[0])) {
specifiedConstraint = [specifiedConstraint];
}
var filterRange = filterRangeSpecified ? specifiedConstraint.map(function (d) {
return d.map(domainToPaddedUnit);
}) : [[-Infinity, Infinity]];
var brushMove = function () {
var p = vm;
p.focusLayer && p.focusLayer.render(p.panels, true);
var filtersActive = someFiltersActive(p);
if (!state.contextShown() && filtersActive) {
p.contextLayer && p.contextLayer.render(p.panels, true);
state.contextShown(true);
} else if (state.contextShown() && !filtersActive) {
p.contextLayer && p.contextLayer.render(p.panels, true, true);
state.contextShown(false);
}
};
var truncatedValues = dimension.values;
if (truncatedValues.length > dimension._length) {
truncatedValues = truncatedValues.slice(0, dimension._length);
}
var tickvals = dimension.tickvals;
var ticktext;
function makeTickItem(v, i) {
return {
val: v,
text: ticktext[i]
};
}
function sortTickItem(a, b) {
return a.val - b.val;
}
if (isArrayOrTypedArray(tickvals) && tickvals.length) {
if (Lib.isTypedArray(tickvals)) tickvals = Array.from(tickvals);
ticktext = dimension.ticktext;
// ensure ticktext and tickvals have same length
if (!isArrayOrTypedArray(ticktext) || !ticktext.length) {
ticktext = tickvals.map(numberFormat(dimension.tickformat));
} else if (ticktext.length > tickvals.length) {
ticktext = ticktext.slice(0, tickvals.length);
} else if (tickvals.length > ticktext.length) {
tickvals = tickvals.slice(0, ticktext.length);
}
// check if we need to sort tickvals/ticktext
for (var j = 1; j < tickvals.length; j++) {
if (tickvals[j] < tickvals[j - 1]) {
var tickItems = tickvals.map(makeTickItem).sort(sortTickItem);
for (var k = 0; k < tickvals.length; k++) {
tickvals[k] = tickItems[k].val;
ticktext[k] = tickItems[k].text;
}
break;
}
}
} else tickvals = undefined;
truncatedValues = helpers.convertTypedArray(truncatedValues);
return {
key: key,
label: dimension.label,
tickFormat: dimension.tickformat,
tickvals: tickvals,
ticktext: ticktext,
ordinal: helpers.isOrdinal(dimension),
multiselect: dimension.multiselect,
xIndex: i,
crossfilterDimensionIndex: i,
visibleIndex: dimension._index,
height: height,
values: truncatedValues,
paddedUnitValues: truncatedValues.map(domainToPaddedUnit),
unitTickvals: tickvals && tickvals.map(domainToPaddedUnit),
xScale: xScale,
x: xScale(i),
canvasX: xScale(i) * canvasPixelRatio,
unitToPaddedPx: _unitToPaddedPx,
domainScale: domainScale(height, c.verticalPadding, dimension, tickvals, ticktext),
ordinalScale: ordinalScale(dimension),
parent: vm,
model: model,
brush: brush.makeBrush(state, filterRangeSpecified, filterRange, function () {
state.linePickActive(false);
}, brushMove, function (f) {
vm.focusLayer.render(vm.panels, true);
vm.pickLayer && vm.pickLayer.render(vm.panels, true);
state.linePickActive(true);
if (callbacks && callbacks.filterChanged) {
var invScale = domainToPaddedUnit.invert;
// update gd.data as if a Plotly.restyle were fired
var newRanges = f.map(function (r) {
return r.map(invScale).sort(Lib.sorterAsc);
}).sort(function (a, b) {
return a[0] - b[0];
});
callbacks.filterChanged(vm.key, dimension._index, newRanges);
}
})
};
});
return vm;
}
function styleExtentTexts(selection) {
selection.classed(c.cn.axisExtentText, true).attr('text-anchor', 'middle').style('cursor', 'default');
}
function parcoordsInteractionState() {
var linePickActive = true;
var contextShown = false;
return {
linePickActive: function (val) {
return arguments.length ? linePickActive = !!val : linePickActive;
},
contextShown: function (val) {
return arguments.length ? contextShown = !!val : contextShown;
}
};
}
function calcTilt(angle, position) {
var dir = position === 'top' ? 1 : -1;
var radians = angle * Math.PI / 180;
var dx = Math.sin(radians);
var dy = Math.cos(radians);
return {
dir: dir,
dx: dx,
dy: dy,
degrees: angle
};
}
function updatePanelLayout(yAxis, vm, plotGlPixelRatio) {
var panels = vm.panels || (vm.panels = []);
var data = yAxis.data();
for (var i = 0; i < data.length - 1; i++) {
var p = panels[i] || (panels[i] = {});
var dim0 = data[i];
var dim1 = data[i + 1];
p.dim0 = dim0;
p.dim1 = dim1;
p.canvasX = dim0.canvasX;
p.panelSizeX = dim1.canvasX - dim0.canvasX;
p.panelSizeY = vm.model.canvasHeight;
p.y = 0;
p.canvasY = 0;
p.plotGlPixelRatio = plotGlPixelRatio;
}
}
function calcAllTicks(cd) {
for (var i = 0; i < cd.length; i++) {
for (var j = 0; j < cd[i].length; j++) {
var trace = cd[i][j].trace;
var dimensions = trace.dimensions;
for (var k = 0; k < dimensions.length; k++) {
var values = dimensions[k].values;
var dim = dimensions[k]._ax;
if (dim) {
if (!dim.range) {
dim.range = findExtremes(values, trace._length);
} else {
dim.range = fixExtremes(dim.range[0], dim.range[1]);
}
if (!dim.dtick) {
dim.dtick = 0.01 * (Math.abs(dim.range[1] - dim.range[0]) || 1);
}
dim.tickformat = dimensions[k].tickformat;
Axes.calcTicks(dim);
dim.cleanRange();
}
}
}
}
}
function linearFormat(dim, v) {
return Axes.tickText(dim._ax, v, false).text;
}
function extremeText(d, isTop) {
if (d.ordinal) return '';
var domain = d.domainScale.domain();
var v = domain[isTop ? domain.length - 1 : 0];
return linearFormat(d.model.dimensions[d.visibleIndex], v);
}
module.exports = function parcoords(gd, cdModule, layout, callbacks) {
var isStatic = gd._context.staticPlot;
var fullLayout = gd._fullLayout;
var svg = fullLayout._toppaper;
var glContainer = fullLayout._glcontainer;
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
var paperColor = gd._fullLayout.paper_bgcolor;
calcAllTicks(cdModule);
var state = parcoordsInteractionState();
var vm = cdModule.filter(function (d) {
return unwrap(d).trace.visible;
}).map(model.bind(0, layout)).map(viewModel.bind(0, state, callbacks));
glContainer.each(function (d, i) {
return Lib.extendFlat(d, vm[i]);
});
var glLayers = glContainer.selectAll('.gl-canvas').each(function (d) {
// FIXME: figure out how to handle multiple instances
d.viewModel = vm[0];
d.viewModel.plotGlPixelRatio = plotGlPixelRatio;
d.viewModel.paperColor = paperColor;
d.model = d.viewModel ? d.viewModel.model : null;
});
var lastHovered = null;
var pickLayer = glLayers.filter(function (d) {
return d.pick;
});
// emit hover / unhover event
pickLayer.style('pointer-events', isStatic ? 'none' : 'auto').on('mousemove', function (d) {
if (state.linePickActive() && d.lineLayer && callbacks && callbacks.hover) {
var event = d3.event;
var cw = this.width;
var ch = this.height;
var pointer = d3.mouse(this);
var x = pointer[0];
var y = pointer[1];
if (x < 0 || y < 0 || x >= cw || y >= ch) {
return;
}
var pixel = d.lineLayer.readPixel(x, ch - 1 - y);
var found = pixel[3] !== 0;
// inverse of the calcPickColor in `lines.js`; detailed comment there
var curveNumber = found ? pixel[2] + 256 * (pixel[1] + 256 * pixel[0]) : null;
var eventData = {
x: x,
y: y,
clientX: event.clientX,
clientY: event.clientY,
dataIndex: d.model.key,
curveNumber: curveNumber
};
if (curveNumber !== lastHovered) {
// don't unnecessarily repeat the same hit (or miss)
if (found) {
callbacks.hover(eventData);
} else if (callbacks.unhover) {
callbacks.unhover(eventData);
}
lastHovered = curveNumber;
}
}
});
glLayers.style('opacity', function (d) {
return d.pick ? 0 : 1;
});
svg.style('background', 'rgba(255, 255, 255, 0)');
var controlOverlay = svg.selectAll('.' + c.cn.parcoords).data(vm, keyFun);
controlOverlay.exit().remove();
controlOverlay.enter().append('g').classed(c.cn.parcoords, true).style('shape-rendering', 'crispEdges').style('pointer-events', 'none');
controlOverlay.attr('transform', function (d) {
return strTranslate(d.model.translateX, d.model.translateY);
});
var parcoordsControlView = controlOverlay.selectAll('.' + c.cn.parcoordsControlView).data(repeat, keyFun);
parcoordsControlView.enter().append('g').classed(c.cn.parcoordsControlView, true);
parcoordsControlView.attr('transform', function (d) {
return strTranslate(d.model.pad.l, d.model.pad.t);
});
var yAxis = parcoordsControlView.selectAll('.' + c.cn.yAxis).data(function (p) {
return p.dimensions;
}, keyFun);
yAxis.enter().append('g').classed(c.cn.yAxis, true);
parcoordsControlView.each(function (p) {
updatePanelLayout(yAxis, p, plotGlPixelRatio);
});
glLayers.each(function (d) {
if (d.viewModel) {
if (!d.lineLayer || callbacks) {
// recreate in case of having callbacks e.g. restyle. Should we test for callback to be a restyle?
d.lineLayer = lineLayerMaker(this, d);
} else d.lineLayer.update(d);
if (d.key || d.key === 0) d.viewModel[d.key] = d.lineLayer;
var setChanged = !d.context ||
// don't update background
callbacks; // unless there is a callback on the context layer. Should we test the callback?
d.lineLayer.render(d.viewModel.panels, setChanged);
}
});
yAxis.attr('transform', function (d) {
return strTranslate(d.xScale(d.xIndex), 0);
});
// drag column for reordering columns
yAxis.call(d3.behavior.drag().origin(function (d) {
return d;
}).on('drag', function (d) {
var p = d.parent;
state.linePickActive(false);
d.x = Math.max(-c.overdrag, Math.min(d.model.width + c.overdrag, d3.event.x));
d.canvasX = d.x * d.model.canvasPixelRatio;
yAxis.sort(function (a, b) {
return a.x - b.x;
}).each(function (e, i) {
e.xIndex = i;
e.x = d === e ? e.x : e.xScale(e.xIndex);
e.canvasX = e.x * e.model.canvasPixelRatio;
});
updatePanelLayout(yAxis, p, plotGlPixelRatio);
yAxis.filter(function (e) {
return Math.abs(d.xIndex - e.xIndex) !== 0;
}).attr('transform', function (d) {
return strTranslate(d.xScale(d.xIndex), 0);
});
d3.select(this).attr('transform', strTranslate(d.x, 0));
yAxis.each(function (e, i0, i1) {
if (i1 === d.parent.key) p.dimensions[i0] = e;
});
p.contextLayer && p.contextLayer.render(p.panels, false, !someFiltersActive(p));
p.focusLayer.render && p.focusLayer.render(p.panels);
}).on('dragend', function (d) {
var p = d.parent;
d.x = d.xScale(d.xIndex);
d.canvasX = d.x * d.model.canvasPixelRatio;
updatePanelLayout(yAxis, p, plotGlPixelRatio);
d3.select(this).attr('transform', function (d) {
return strTranslate(d.x, 0);
});
p.contextLayer && p.contextLayer.render(p.panels, false, !someFiltersActive(p));
p.focusLayer && p.focusLayer.render(p.panels);
p.pickLayer && p.pickLayer.render(p.panels, true);
state.linePickActive(true);
if (callbacks && callbacks.axesMoved) {
callbacks.axesMoved(p.key, p.dimensions.map(function (e) {
return e.crossfilterDimensionIndex;
}));
}
}));
yAxis.exit().remove();
var axisOverlays = yAxis.selectAll('.' + c.cn.axisOverlays).data(repeat, keyFun);
axisOverlays.enter().append('g').classed(c.cn.axisOverlays, true);
axisOverlays.selectAll('.' + c.cn.axis).remove();
var axis = axisOverlays.selectAll('.' + c.cn.axis).data(repeat, keyFun);
axis.enter().append('g').classed(c.cn.axis, true);
axis.each(function (d) {
var wantedTickCount = d.model.height / d.model.tickDistance;
var scale = d.domainScale;
var sdom = scale.domain();
d3.select(this).call(d3.svg.axis().orient('left').tickSize(4).outerTickSize(2).ticks(wantedTickCount, d.tickFormat) // works for continuous scales only...
.tickValues(d.ordinal ?
// and this works for ordinal scales
sdom : null).tickFormat(function (v) {
return helpers.isOrdinal(d) ? v : linearFormat(d.model.dimensions[d.visibleIndex], v);
}).scale(scale));
Drawing.font(axis.selectAll('text'), d.model.tickFont);
});
axis.selectAll('.domain, .tick>line').attr('fill', 'none').attr('stroke', 'black').attr('stroke-opacity', 0.25).attr('stroke-width', '1px');
axis.selectAll('text').style('text-shadow', svgTextUtils.makeTextShadow(paperColor)).style('cursor', 'default');
var axisHeading = axisOverlays.selectAll('.' + c.cn.axisHeading).data(repeat, keyFun);
axisHeading.enter().append('g').classed(c.cn.axisHeading, true);
var axisTitle = axisHeading.selectAll('.' + c.cn.axisTitle).data(repeat, keyFun);
axisTitle.enter().append('text').classed(c.cn.axisTitle, true).attr('text-anchor', 'middle').style('cursor', 'ew-resize').style('pointer-events', isStatic ? 'none' : 'auto');
axisTitle.text(function (d) {
return d.label;
}).each(function (d) {
var e = d3.select(this);
Drawing.font(e, d.model.labelFont);
svgTextUtils.convertToTspans(e, gd);
}).attr('transform', function (d) {
var tilt = calcTilt(d.model.labelAngle, d.model.labelSide);
var r = c.axisTitleOffset;
return (tilt.dir > 0 ? '' : strTranslate(0, 2 * r + d.model.height)) + strRotate(tilt.degrees) + strTranslate(-r * tilt.dx, -r * tilt.dy);
}).attr('text-anchor', function (d) {
var tilt = calcTilt(d.model.labelAngle, d.model.labelSide);
var adx = Math.abs(tilt.dx);
var ady = Math.abs(tilt.dy);
if (2 * adx > ady) {
return tilt.dir * tilt.dx < 0 ? 'start' : 'end';
} else {
return 'middle';
}
});
var axisExtent = axisOverlays.selectAll('.' + c.cn.axisExtent).data(repeat, keyFun);
axisExtent.enter().append('g').classed(c.cn.axisExtent, true);
var axisExtentTop = axisExtent.selectAll('.' + c.cn.axisExtentTop).data(repeat, keyFun);
axisExtentTop.enter().append('g').classed(c.cn.axisExtentTop, true);
axisExtentTop.attr('transform', strTranslate(0, -c.axisExtentOffset));
var axisExtentTopText = axisExtentTop.selectAll('.' + c.cn.axisExtentTopText).data(repeat, keyFun);
axisExtentTopText.enter().append('text').classed(c.cn.axisExtentTopText, true).call(styleExtentTexts);
axisExtentTopText.text(function (d) {
return extremeText(d, true);
}).each(function (d) {
Drawing.font(d3.select(this), d.model.rangeFont);
});
var axisExtentBottom = axisExtent.selectAll('.' + c.cn.axisExtentBottom).data(repeat, keyFun);
axisExtentBottom.enter().append('g').classed(c.cn.axisExtentBottom, true);
axisExtentBottom.attr('transform', function (d) {
return strTranslate(0, d.model.height + c.axisExtentOffset);
});
var axisExtentBottomText = axisExtentBottom.selectAll('.' + c.cn.axisExtentBottomText).data(repeat, keyFun);
axisExtentBottomText.enter().append('text').classed(c.cn.axisExtentBottomText, true).attr('dy', '0.75em').call(styleExtentTexts);
axisExtentBottomText.text(function (d) {
return extremeText(d, false);
}).each(function (d) {
Drawing.font(d3.select(this), d.model.rangeFont);
});
brush.ensureAxisBrush(axisOverlays, paperColor, gd);
};
/***/ }),
/***/ 24196:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var parcoords = __webpack_require__(36336);
var prepareRegl = __webpack_require__(5048);
var isVisible = (__webpack_require__(95724).isVisible);
var reglPrecompiled = {};
function newIndex(visibleIndices, orig, dim) {
var origIndex = orig.indexOf(dim);
var currentIndex = visibleIndices.indexOf(origIndex);
if (currentIndex === -1) {
// invisible dimensions initially go to the end
currentIndex += orig.length;
}
return currentIndex;
}
function sorter(visibleIndices, orig) {
return function sorter(d1, d2) {
return newIndex(visibleIndices, orig, d1) - newIndex(visibleIndices, orig, d2);
};
}
var exports = module.exports = function plot(gd, cdModule) {
var fullLayout = gd._fullLayout;
var success = prepareRegl(gd, [], reglPrecompiled);
if (!success) return;
var currentDims = {};
var initialDims = {};
var fullIndices = {};
var inputIndices = {};
var size = fullLayout._size;
cdModule.forEach(function (d, i) {
var trace = d[0].trace;
fullIndices[i] = trace.index;
var iIn = inputIndices[i] = trace._fullInput.index;
currentDims[i] = gd.data[iIn].dimensions;
initialDims[i] = gd.data[iIn].dimensions.slice();
});
var filterChanged = function (i, initialDimIndex, newRanges) {
// Have updated `constraintrange` data on `gd.data` and raise `Plotly.restyle` event
// without having to incur heavy UI blocking due to an actual `Plotly.restyle` call
var dim = initialDims[i][initialDimIndex];
var newConstraints = newRanges.map(function (r) {
return r.slice();
});
// Store constraint range in preGUI
// This one doesn't work if it's stored in pieces in _storeDirectGUIEdit
// because it's an array of variable dimensionality. So store the whole
// thing at once manually.
var aStr = 'dimensions[' + initialDimIndex + '].constraintrange';
var preGUI = fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid];
if (preGUI[aStr] === undefined) {
var initialVal = dim.constraintrange;
preGUI[aStr] = initialVal || null;
}
var fullDimension = gd._fullData[fullIndices[i]].dimensions[initialDimIndex];
if (!newConstraints.length) {
delete dim.constraintrange;
delete fullDimension.constraintrange;
newConstraints = null;
} else {
if (newConstraints.length === 1) newConstraints = newConstraints[0];
dim.constraintrange = newConstraints;
fullDimension.constraintrange = newConstraints.slice();
// wrap in another array for restyle event data
newConstraints = [newConstraints];
}
var restyleData = {};
restyleData[aStr] = newConstraints;
gd.emit('plotly_restyle', [restyleData, [inputIndices[i]]]);
};
var hover = function (eventData) {
gd.emit('plotly_hover', eventData);
};
var unhover = function (eventData) {
gd.emit('plotly_unhover', eventData);
};
var axesMoved = function (i, visibleIndices) {
// Have updated order data on `gd.data` and raise `Plotly.restyle` event
// without having to incur heavy UI blocking due to an actual `Plotly.restyle` call
// drag&drop sorting of the visible dimensions
var orig = sorter(visibleIndices, initialDims[i].filter(isVisible));
currentDims[i].sort(orig);
// invisible dimensions are not interpreted in the context of drag&drop sorting as an invisible dimension
// cannot be dragged; they're interspersed into their original positions by this subsequent merging step
initialDims[i].filter(function (d) {
return !isVisible(d);
}).sort(function (d) {
// subsequent splicing to be done left to right, otherwise indices may be incorrect
return initialDims[i].indexOf(d);
}).forEach(function (d) {
currentDims[i].splice(currentDims[i].indexOf(d), 1); // remove from the end
currentDims[i].splice(initialDims[i].indexOf(d), 0, d); // insert at original index
});
// TODO: we can't really store this part of the interaction state
// directly as below, since it incudes data arrays. If we want to
// persist column order we may have to do something special for this
// case to just store the order itself.
// Registry.call('_storeDirectGUIEdit',
// gd.data[inputIndices[i]],
// fullLayout._tracePreGUI[gd._fullData[fullIndices[i]]._fullInput.uid],
// {dimensions: currentDims[i]}
// );
gd.emit('plotly_restyle', [{
dimensions: [currentDims[i]]
}, [inputIndices[i]]]);
};
parcoords(gd, cdModule, {
// layout
width: size.w,
height: size.h,
margin: {
t: size.t,
r: size.r,
b: size.b,
l: size.l
}
}, {
// callbacks
filterChanged: filterChanged,
hover: hover,
unhover: unhover,
axesMoved: axesMoved
});
};
exports.reglPrecompiled = reglPrecompiled;
/***/ }),
/***/ 21552:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Drawing = __webpack_require__(43616);
var Color = __webpack_require__(76308);
module.exports = function fillOne(s, pt, trace, gd) {
var pattern = trace.marker.pattern;
if (pattern && pattern.shape) {
Drawing.pointStyle(s, trace, gd, pt);
} else {
Color.fill(s, pt.color);
}
};
/***/ }),
/***/ 69656:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
function format(vRounded) {
return vRounded.indexOf('e') !== -1 ? vRounded.replace(/[.]?0+e/, 'e') : vRounded.indexOf('.') !== -1 ? vRounded.replace(/[.]?0+$/, '') : vRounded;
}
exports.formatPiePercent = function formatPiePercent(v, separators) {
var vRounded = format((v * 100).toPrecision(3));
return Lib.numSeparate(vRounded, separators) + '%';
};
exports.formatPieValue = function formatPieValue(v, separators) {
var vRounded = format(v.toPrecision(10));
return Lib.numSeparate(vRounded, separators);
};
exports.getFirstFilled = function getFirstFilled(array, indices) {
if (!Lib.isArrayOrTypedArray(array)) return;
for (var i = 0; i < indices.length; i++) {
var v = array[indices[i]];
if (v || v === 0 || v === '') return v;
}
};
exports.castOption = function castOption(item, indices) {
if (Lib.isArrayOrTypedArray(item)) return exports.getFirstFilled(item, indices);else if (item) return item;
};
exports.getRotationAngle = function (rotation) {
return (rotation === 'auto' ? 0 : rotation) * Math.PI / 180;
};
/***/ }),
/***/ 10528:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Color = __webpack_require__(76308);
var castOption = (__webpack_require__(69656).castOption);
var fillOne = __webpack_require__(21552);
module.exports = function styleOne(s, pt, trace, gd) {
var line = trace.marker.line;
var lineColor = castOption(line.color, pt.pts) || Color.defaultLine;
var lineWidth = castOption(line.width, pt.pts) || 0;
s.call(fillOne, pt, trace, gd).style('stroke-width', lineWidth).call(Color.stroke, lineColor);
};
/***/ }),
/***/ 35484:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var scatterglAttrs = __webpack_require__(52904);
module.exports = {
x: scatterglAttrs.x,
y: scatterglAttrs.y,
xy: {
valType: 'data_array',
editType: 'calc'
},
indices: {
valType: 'data_array',
editType: 'calc'
},
xbounds: {
valType: 'data_array',
editType: 'calc'
},
ybounds: {
valType: 'data_array',
editType: 'calc'
},
text: scatterglAttrs.text,
marker: {
color: {
valType: 'color',
arrayOk: false,
editType: 'calc'
},
opacity: {
valType: 'number',
min: 0,
max: 1,
dflt: 1,
arrayOk: false,
editType: 'calc'
},
blend: {
valType: 'boolean',
dflt: null,
editType: 'calc'
},
sizemin: {
valType: 'number',
min: 0.1,
max: 2,
dflt: 0.5,
editType: 'calc'
},
sizemax: {
valType: 'number',
min: 0.1,
dflt: 20,
editType: 'calc'
},
border: {
color: {
valType: 'color',
arrayOk: false,
editType: 'calc'
},
arearatio: {
valType: 'number',
min: 0,
max: 1,
dflt: 0,
editType: 'calc'
},
editType: 'calc'
},
editType: 'calc'
},
transforms: undefined
};
/***/ }),
/***/ 11072:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var createPointCloudRenderer = (__webpack_require__(67792).gl_pointcloud2d);
var isArrayOrTypedArray = (__webpack_require__(3400).isArrayOrTypedArray);
var str2RGBArray = __webpack_require__(43080);
var findExtremes = (__webpack_require__(19280).findExtremes);
var getTraceColor = __webpack_require__(44928);
function Pointcloud(scene, uid) {
this.scene = scene;
this.uid = uid;
this.type = 'pointcloud';
this.pickXData = [];
this.pickYData = [];
this.xData = [];
this.yData = [];
this.textLabels = [];
this.color = 'rgb(0, 0, 0)';
this.name = '';
this.hoverinfo = 'all';
this.idToIndex = new Int32Array(0);
this.bounds = [0, 0, 0, 0];
this.pointcloudOptions = {
positions: new Float32Array(0),
idToIndex: this.idToIndex,
sizemin: 0.5,
sizemax: 12,
color: [0, 0, 0, 1],
areaRatio: 1,
borderColor: [0, 0, 0, 1]
};
this.pointcloud = createPointCloudRenderer(scene.glplot, this.pointcloudOptions);
this.pointcloud._trace = this; // scene2d requires this prop
}
var proto = Pointcloud.prototype;
proto.handlePick = function (pickResult) {
var index = this.idToIndex[pickResult.pointId];
// prefer the readout from XY, if present
return {
trace: this,
dataCoord: pickResult.dataCoord,
traceCoord: this.pickXYData ? [this.pickXYData[index * 2], this.pickXYData[index * 2 + 1]] : [this.pickXData[index], this.pickYData[index]],
textLabel: isArrayOrTypedArray(this.textLabels) ? this.textLabels[index] : this.textLabels,
color: this.color,
name: this.name,
pointIndex: index,
hoverinfo: this.hoverinfo
};
};
proto.update = function (options) {
this.index = options.index;
this.textLabels = options.text;
this.name = options.name;
this.hoverinfo = options.hoverinfo;
this.bounds = [Infinity, Infinity, -Infinity, -Infinity];
this.updateFast(options);
this.color = getTraceColor(options, {});
};
proto.updateFast = function (options) {
var x = this.xData = this.pickXData = options.x;
var y = this.yData = this.pickYData = options.y;
var xy = this.pickXYData = options.xy;
var userBounds = options.xbounds && options.ybounds;
var index = options.indices;
var len;
var idToIndex;
var positions;
var bounds = this.bounds;
var xx, yy, i;
if (xy) {
positions = xy;
// dividing xy.length by 2 and truncating to integer if xy.length was not even
len = xy.length >>> 1;
if (userBounds) {
bounds[0] = options.xbounds[0];
bounds[2] = options.xbounds[1];
bounds[1] = options.ybounds[0];
bounds[3] = options.ybounds[1];
} else {
for (i = 0; i < len; i++) {
xx = positions[i * 2];
yy = positions[i * 2 + 1];
if (xx < bounds[0]) bounds[0] = xx;
if (xx > bounds[2]) bounds[2] = xx;
if (yy < bounds[1]) bounds[1] = yy;
if (yy > bounds[3]) bounds[3] = yy;
}
}
if (index) {
idToIndex = index;
} else {
idToIndex = new Int32Array(len);
for (i = 0; i < len; i++) {
idToIndex[i] = i;
}
}
} else {
len = x.length;
positions = new Float32Array(2 * len);
idToIndex = new Int32Array(len);
for (i = 0; i < len; i++) {
xx = x[i];
yy = y[i];
idToIndex[i] = i;
positions[i * 2] = xx;
positions[i * 2 + 1] = yy;
if (xx < bounds[0]) bounds[0] = xx;
if (xx > bounds[2]) bounds[2] = xx;
if (yy < bounds[1]) bounds[1] = yy;
if (yy > bounds[3]) bounds[3] = yy;
}
}
this.idToIndex = idToIndex;
this.pointcloudOptions.idToIndex = idToIndex;
this.pointcloudOptions.positions = positions;
var markerColor = str2RGBArray(options.marker.color);
var borderColor = str2RGBArray(options.marker.border.color);
var opacity = options.opacity * options.marker.opacity;
markerColor[3] *= opacity;
this.pointcloudOptions.color = markerColor;
// detect blending from the number of points, if undefined
// because large data with blending hits performance
var blend = options.marker.blend;
if (blend === null) {
var maxPoints = 100;
blend = x.length < maxPoints || y.length < maxPoints;
}
this.pointcloudOptions.blend = blend;
borderColor[3] *= opacity;
this.pointcloudOptions.borderColor = borderColor;
var markerSizeMin = options.marker.sizemin;
var markerSizeMax = Math.max(options.marker.sizemax, options.marker.sizemin);
this.pointcloudOptions.sizeMin = markerSizeMin;
this.pointcloudOptions.sizeMax = markerSizeMax;
this.pointcloudOptions.areaRatio = options.marker.border.arearatio;
this.pointcloud.update(this.pointcloudOptions);
// add item for autorange routine
var xa = this.scene.xaxis;
var ya = this.scene.yaxis;
var pad = markerSizeMax / 2 || 0.5;
options._extremes[xa._id] = findExtremes(xa, [bounds[0], bounds[2]], {
ppad: pad
});
options._extremes[ya._id] = findExtremes(ya, [bounds[1], bounds[3]], {
ppad: pad
});
};
proto.dispose = function () {
this.pointcloud.dispose();
};
function createPointcloud(scene, data) {
var plot = new Pointcloud(scene, data.uid);
plot.update(data);
return plot;
}
module.exports = createPointcloud;
/***/ }),
/***/ 41904:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var attributes = __webpack_require__(35484);
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
coerce('x');
coerce('y');
coerce('xbounds');
coerce('ybounds');
if (traceIn.xy && traceIn.xy instanceof Float32Array) {
traceOut.xy = traceIn.xy;
}
if (traceIn.indices && traceIn.indices instanceof Int32Array) {
traceOut.indices = traceIn.indices;
}
coerce('text');
coerce('marker.color', defaultColor);
coerce('marker.opacity');
coerce('marker.blend');
coerce('marker.sizemin');
coerce('marker.sizemax');
coerce('marker.border.color', defaultColor);
coerce('marker.border.arearatio');
// disable 1D transforms - that would defeat the purpose of this trace type, performance!
traceOut._length = null;
};
/***/ }),
/***/ 156:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var deprecationWarning = ['*pointcloud* trace is deprecated!', 'Please consider switching to the *scattergl* trace type.'].join(' ');
module.exports = {
attributes: __webpack_require__(35484),
supplyDefaults: __webpack_require__(41904),
// reuse the Scatter3D 'dummy' calc step so that legends know what to do
calc: __webpack_require__(41484),
plot: __webpack_require__(11072),
moduleType: 'trace',
name: 'pointcloud',
basePlotModule: __webpack_require__(39952),
categories: ['gl', 'gl2d', 'showLegend'],
meta: {}
};
/***/ }),
/***/ 20148:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
// arrayOk attributes, merge them into calcdata array
module.exports = function arraysToCalcdata(cd, trace) {
// so each point knows which index it originally came from
for (var i = 0; i < cd.length; i++) cd[i].i = i;
Lib.mergeArray(trace.text, cd, 'tx');
Lib.mergeArray(trace.texttemplate, cd, 'txt');
Lib.mergeArray(trace.hovertext, cd, 'htx');
Lib.mergeArray(trace.customdata, cd, 'data');
Lib.mergeArray(trace.textposition, cd, 'tp');
if (trace.textfont) {
Lib.mergeArrayCastPositive(trace.textfont.size, cd, 'ts');
Lib.mergeArray(trace.textfont.color, cd, 'tc');
Lib.mergeArray(trace.textfont.family, cd, 'tf');
}
var marker = trace.marker;
if (marker) {
Lib.mergeArrayCastPositive(marker.size, cd, 'ms');
Lib.mergeArrayCastPositive(marker.opacity, cd, 'mo');
Lib.mergeArray(marker.symbol, cd, 'mx');
Lib.mergeArray(marker.angle, cd, 'ma');
Lib.mergeArray(marker.standoff, cd, 'mf');
Lib.mergeArray(marker.color, cd, 'mc');
var markerLine = marker.line;
if (marker.line) {
Lib.mergeArray(markerLine.color, cd, 'mlc');
Lib.mergeArrayCastPositive(markerLine.width, cd, 'mlw');
}
var markerGradient = marker.gradient;
if (markerGradient && markerGradient.type !== 'none') {
Lib.mergeArray(markerGradient.type, cd, 'mgt');
Lib.mergeArray(markerGradient.color, cd, 'mgc');
}
}
};
/***/ }),
/***/ 52904:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var axisHoverFormat = (__webpack_require__(29736).axisHoverFormat);
var texttemplateAttrs = (__webpack_require__(21776)/* .texttemplateAttrs */ .Gw);
var hovertemplateAttrs = (__webpack_require__(21776)/* .hovertemplateAttrs */ .Ks);
var colorScaleAttrs = __webpack_require__(49084);
var fontAttrs = __webpack_require__(25376);
var dash = (__webpack_require__(98192)/* .dash */ .u);
var pattern = (__webpack_require__(98192)/* .pattern */ .c);
var Drawing = __webpack_require__(43616);
var constants = __webpack_require__(88200);
var extendFlat = (__webpack_require__(92880).extendFlat);
var makeFillcolorAttr = __webpack_require__(98304);
function axisPeriod(axis) {
return {
valType: 'any',
dflt: 0,
editType: 'calc'
};
}
function axisPeriod0(axis) {
return {
valType: 'any',
editType: 'calc'
};
}
function axisPeriodAlignment(axis) {
return {
valType: 'enumerated',
values: ['start', 'middle', 'end'],
dflt: 'middle',
editType: 'calc'
};
}
module.exports = {
x: {
valType: 'data_array',
editType: 'calc+clearAxisTypes',
anim: true
},
x0: {
valType: 'any',
dflt: 0,
editType: 'calc+clearAxisTypes',
anim: true
},
dx: {
valType: 'number',
dflt: 1,
editType: 'calc',
anim: true
},
y: {
valType: 'data_array',
editType: 'calc+clearAxisTypes',
anim: true
},
y0: {
valType: 'any',
dflt: 0,
editType: 'calc+clearAxisTypes',
anim: true
},
dy: {
valType: 'number',
dflt: 1,
editType: 'calc',
anim: true
},
xperiod: axisPeriod('x'),
yperiod: axisPeriod('y'),
xperiod0: axisPeriod0('x0'),
yperiod0: axisPeriod0('y0'),
xperiodalignment: axisPeriodAlignment('x'),
yperiodalignment: axisPeriodAlignment('y'),
xhoverformat: axisHoverFormat('x'),
yhoverformat: axisHoverFormat('y'),
offsetgroup: {
valType: 'string',
dflt: '',
editType: 'calc'
},
alignmentgroup: {
valType: 'string',
dflt: '',
editType: 'calc'
},
stackgroup: {
valType: 'string',
dflt: '',
editType: 'calc'
},
orientation: {
valType: 'enumerated',
values: ['v', 'h'],
editType: 'calc'
},
groupnorm: {
valType: 'enumerated',
values: ['', 'fraction', 'percent'],
dflt: '',
editType: 'calc'
},
stackgaps: {
valType: 'enumerated',
values: ['infer zero', 'interpolate'],
dflt: 'infer zero',
editType: 'calc'
},
text: {
valType: 'string',
dflt: '',
arrayOk: true,
editType: 'calc'
},
texttemplate: texttemplateAttrs({}, {}),
hovertext: {
valType: 'string',
dflt: '',
arrayOk: true,
editType: 'style'
},
mode: {
valType: 'flaglist',
flags: ['lines', 'markers', 'text'],
extras: ['none'],
editType: 'calc'
},
hoveron: {
valType: 'flaglist',
flags: ['points', 'fills'],
editType: 'style'
},
hovertemplate: hovertemplateAttrs({}, {
keys: constants.eventDataKeys
}),
line: {
color: {
valType: 'color',
editType: 'style',
anim: true
},
width: {
valType: 'number',
min: 0,
dflt: 2,
editType: 'style',
anim: true
},
shape: {
valType: 'enumerated',
values: ['linear', 'spline', 'hv', 'vh', 'hvh', 'vhv'],
dflt: 'linear',
editType: 'plot'
},
smoothing: {
valType: 'number',
min: 0,
max: 1.3,
dflt: 1,
editType: 'plot'
},
dash: extendFlat({}, dash, {
editType: 'style'
}),
backoff: {
// we want to have a similar option for the start of the line
valType: 'number',
min: 0,
dflt: 'auto',
arrayOk: true,
editType: 'plot'
},
simplify: {
valType: 'boolean',
dflt: true,
editType: 'plot'
},
editType: 'plot'
},
connectgaps: {
valType: 'boolean',
dflt: false,
editType: 'calc'
},
cliponaxis: {
valType: 'boolean',
dflt: true,
editType: 'plot'
},
fill: {
valType: 'enumerated',
values: ['none', 'tozeroy', 'tozerox', 'tonexty', 'tonextx', 'toself', 'tonext'],
editType: 'calc'
},
fillcolor: makeFillcolorAttr(true),
fillgradient: extendFlat({
type: {
valType: 'enumerated',
values: ['radial', 'horizontal', 'vertical', 'none'],
dflt: 'none',
editType: 'calc'
},
start: {
valType: 'number',
editType: 'calc'
},
stop: {
valType: 'number',
editType: 'calc'
},
colorscale: {
valType: 'colorscale',
editType: 'style'
},
editType: 'calc'
}),
fillpattern: pattern,
marker: extendFlat({
symbol: {
valType: 'enumerated',
values: Drawing.symbolList,
dflt: 'circle',
arrayOk: true,
editType: 'style'
},
opacity: {
valType: 'number',
min: 0,
max: 1,
arrayOk: true,
editType: 'style',
anim: true
},
angle: {
valType: 'angle',
dflt: 0,
arrayOk: true,
editType: 'plot',
anim: false // TODO: possibly set to true in future
},
angleref: {
valType: 'enumerated',
values: ['previous', 'up'],
dflt: 'up',
editType: 'plot',
anim: false
},
standoff: {
valType: 'number',
min: 0,
dflt: 0,
arrayOk: true,
editType: 'plot',
anim: true
},
size: {
valType: 'number',
min: 0,
dflt: 6,
arrayOk: true,
editType: 'calc',
anim: true
},
maxdisplayed: {
valType: 'number',
min: 0,
dflt: 0,
editType: 'plot'
},
sizeref: {
valType: 'number',
dflt: 1,
editType: 'calc'
},
sizemin: {
valType: 'number',
min: 0,
dflt: 0,
editType: 'calc'
},
sizemode: {
valType: 'enumerated',
values: ['diameter', 'area'],
dflt: 'diameter',
editType: 'calc'
},
line: extendFlat({
width: {
valType: 'number',
min: 0,
arrayOk: true,
editType: 'style',
anim: true
},
editType: 'calc'
}, colorScaleAttrs('marker.line', {
anim: true
})),
gradient: {
type: {
valType: 'enumerated',
values: ['radial', 'horizontal', 'vertical', 'none'],
arrayOk: true,
dflt: 'none',
editType: 'calc'
},
color: {
valType: 'color',
arrayOk: true,
editType: 'calc'
},
editType: 'calc'
},
editType: 'calc'
}, colorScaleAttrs('marker', {
anim: true
})),
selected: {
marker: {
opacity: {
valType: 'number',
min: 0,
max: 1,
editType: 'style'
},
color: {
valType: 'color',
editType: 'style'
},
size: {
valType: 'number',
min: 0,
editType: 'style'
},
editType: 'style'
},
textfont: {
color: {
valType: 'color',
editType: 'style'
},
editType: 'style'
},
editType: 'style'
},
unselected: {
marker: {
opacity: {
valType: 'number',
min: 0,
max: 1,
editType: 'style'
},
color: {
valType: 'color',
editType: 'style'
},
size: {
valType: 'number',
min: 0,
editType: 'style'
},
editType: 'style'
},
textfont: {
color: {
valType: 'color',
editType: 'style'
},
editType: 'style'
},
editType: 'style'
},
textposition: {
valType: 'enumerated',
values: ['top left', 'top center', 'top right', 'middle left', 'middle center', 'middle right', 'bottom left', 'bottom center', 'bottom right'],
dflt: 'middle center',
arrayOk: true,
editType: 'calc'
},
textfont: fontAttrs({
editType: 'calc',
colorEditType: 'style',
arrayOk: true
}),
zorder: {
valType: 'integer',
dflt: 0,
editType: 'plot'
}
};
/***/ }),
/***/ 16356:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
var Lib = __webpack_require__(3400);
var Axes = __webpack_require__(54460);
var alignPeriod = __webpack_require__(1220);
var BADNUM = (__webpack_require__(39032).BADNUM);
var subTypes = __webpack_require__(43028);
var calcColorscale = __webpack_require__(90136);
var arraysToCalcdata = __webpack_require__(20148);
var calcSelection = __webpack_require__(4500);
function calc(gd, trace) {
var fullLayout = gd._fullLayout;
var xa = trace._xA = Axes.getFromId(gd, trace.xaxis || 'x', 'x');
var ya = trace._yA = Axes.getFromId(gd, trace.yaxis || 'y', 'y');
var origX = xa.makeCalcdata(trace, 'x');
var origY = ya.makeCalcdata(trace, 'y');
var xObj = alignPeriod(trace, xa, 'x', origX);
var yObj = alignPeriod(trace, ya, 'y', origY);
var x = xObj.vals;
var y = yObj.vals;
var serieslen = trace._length;
var cd = new Array(serieslen);
var ids = trace.ids;
var stackGroupOpts = getStackOpts(trace, fullLayout, xa, ya);
var interpolateGaps = false;
var isV, i, j, k, interpolate, vali;
setFirstScatter(fullLayout, trace);
var xAttr = 'x';
var yAttr = 'y';
var posAttr;
if (stackGroupOpts) {
Lib.pushUnique(stackGroupOpts.traceIndices, trace._expandedIndex);
isV = stackGroupOpts.orientation === 'v';
// size, like we use for bar
if (isV) {
yAttr = 's';
posAttr = 'x';
} else {
xAttr = 's';
posAttr = 'y';
}
interpolate = stackGroupOpts.stackgaps === 'interpolate';
} else {
var ppad = calcMarkerSize(trace, serieslen);
calcAxisExpansion(gd, trace, xa, ya, x, y, ppad);
}
var hasPeriodX = !!trace.xperiodalignment;
var hasPeriodY = !!trace.yperiodalignment;
for (i = 0; i < serieslen; i++) {
var cdi = cd[i] = {};
var xValid = isNumeric(x[i]);
var yValid = isNumeric(y[i]);
if (xValid && yValid) {
cdi[xAttr] = x[i];
cdi[yAttr] = y[i];
if (hasPeriodX) {
cdi.orig_x = origX[i]; // used by hover
cdi.xEnd = xObj.ends[i];
cdi.xStart = xObj.starts[i];
}
if (hasPeriodY) {
cdi.orig_y = origY[i]; // used by hover
cdi.yEnd = yObj.ends[i];
cdi.yStart = yObj.starts[i];
}
} else if (stackGroupOpts && (isV ? xValid : yValid)) {
// if we're stacking we need to hold on to all valid positions
// even with invalid sizes
cdi[posAttr] = isV ? x[i] : y[i];
cdi.gap = true;
if (interpolate) {
cdi.s = BADNUM;
interpolateGaps = true;
} else {
cdi.s = 0;
}
} else {
cdi[xAttr] = cdi[yAttr] = BADNUM;
}
if (ids) {
cdi.id = String(ids[i]);
}
}
arraysToCalcdata(cd, trace);
calcColorscale(gd, trace);
calcSelection(cd, trace);
if (stackGroupOpts) {
// remove bad positions and sort
// note that original indices get added to cd in arraysToCalcdata
i = 0;
while (i < cd.length) {
if (cd[i][posAttr] === BADNUM) {
cd.splice(i, 1);
} else i++;
}
Lib.sort(cd, function (a, b) {
return a[posAttr] - b[posAttr] || a.i - b.i;
});
if (interpolateGaps) {
// first fill the beginning with constant from the first point
i = 0;
while (i < cd.length - 1 && cd[i].gap) {
i++;
}
vali = cd[i].s;
if (!vali) vali = cd[i].s = 0; // in case of no data AT ALL in this trace - use 0
for (j = 0; j < i; j++) {
cd[j].s = vali;
}
// then fill the end with constant from the last point
k = cd.length - 1;
while (k > i && cd[k].gap) {
k--;
}
vali = cd[k].s;
for (j = cd.length - 1; j > k; j--) {
cd[j].s = vali;
}
// now interpolate internal gaps linearly
while (i < k) {
i++;
if (cd[i].gap) {
j = i + 1;
while (cd[j].gap) {
j++;
}
var pos0 = cd[i - 1][posAttr];
var size0 = cd[i - 1].s;
var m = (cd[j].s - size0) / (cd[j][posAttr] - pos0);
while (i < j) {
cd[i].s = size0 + (cd[i][posAttr] - pos0) * m;
i++;
}
}
}
}
}
return cd;
}
function calcAxisExpansion(gd, trace, xa, ya, x, y, ppad) {
var serieslen = trace._length;
var fullLayout = gd._fullLayout;
var xId = xa._id;
var yId = ya._id;
var firstScatter = fullLayout._firstScatter[firstScatterGroup(trace)] === trace.uid;
var stackOrientation = (getStackOpts(trace, fullLayout, xa, ya) || {}).orientation;
var fill = trace.fill;
// cancel minimum tick spacings (only applies to bars and boxes)
xa._minDtick = 0;
ya._minDtick = 0;
// check whether bounds should be tight, padded, extended to zero...
// most cases both should be padded on both ends, so start with that.
var xOptions = {
padded: true
};
var yOptions = {
padded: true
};
if (ppad) {
xOptions.ppad = yOptions.ppad = ppad;
}
// TODO: text size
var openEnded = serieslen < 2 || x[0] !== x[serieslen - 1] || y[0] !== y[serieslen - 1];
if (openEnded && (fill === 'tozerox' || fill === 'tonextx' && (firstScatter || stackOrientation === 'h'))) {
// include zero (tight) and extremes (padded) if fill to zero
// (unless the shape is closed, then it's just filling the shape regardless)
xOptions.tozero = true;
} else if (!(trace.error_y || {}).visible && (
// if no error bars, markers or text, or fill to y=0 remove x padding
fill === 'tonexty' || fill === 'tozeroy' || !subTypes.hasMarkers(trace) && !subTypes.hasText(trace))) {
xOptions.padded = false;
xOptions.ppad = 0;
}
if (openEnded && (fill === 'tozeroy' || fill === 'tonexty' && (firstScatter || stackOrientation === 'v'))) {
// now check for y - rather different logic, though still mostly padded both ends
// include zero (tight) and extremes (padded) if fill to zero
// (unless the shape is closed, then it's just filling the shape regardless)
yOptions.tozero = true;
} else if (fill === 'tonextx' || fill === 'tozerox') {
// tight y: any x fill
yOptions.padded = false;
}
// N.B. asymmetric splom traces call this with blank {} xa or ya
if (xId) trace._extremes[xId] = Axes.findExtremes(xa, x, xOptions);
if (yId) trace._extremes[yId] = Axes.findExtremes(ya, y, yOptions);
}
function calcMarkerSize(trace, serieslen) {
if (!subTypes.hasMarkers(trace)) return;
// Treat size like x or y arrays --- Run d2c
// this needs to go before ppad computation
var marker = trace.marker;
var sizeref = 1.6 * (trace.marker.sizeref || 1);
var markerTrans;
if (trace.marker.sizemode === 'area') {
markerTrans = function (v) {
return Math.max(Math.sqrt((v || 0) / sizeref), 3);
};
} else {
markerTrans = function (v) {
return Math.max((v || 0) / sizeref, 3);
};
}
if (Lib.isArrayOrTypedArray(marker.size)) {
// I tried auto-type but category and dates dont make much sense.
var ax = {
type: 'linear'
};
Axes.setConvert(ax);
var s = ax.makeCalcdata(trace.marker, 'size');
var sizeOut = new Array(serieslen);
for (var i = 0; i < serieslen; i++) {
sizeOut[i] = markerTrans(s[i]);
}
return sizeOut;
} else {
return markerTrans(marker.size);
}
}
/**
* mark the first scatter trace for each subplot
* note that scatter and scattergl each get their own first trace
* note also that I'm doing this during calc rather than supplyDefaults
* so I don't need to worry about transforms, but if we ever do
* per-trace calc this will get confused.
*/
function setFirstScatter(fullLayout, trace) {
var group = firstScatterGroup(trace);
var firstScatter = fullLayout._firstScatter;
if (!firstScatter[group]) firstScatter[group] = trace.uid;
}
function firstScatterGroup(trace) {
var stackGroup = trace.stackgroup;
return trace.xaxis + trace.yaxis + trace.type + (stackGroup ? '-' + stackGroup : '');
}
function getStackOpts(trace, fullLayout, xa, ya) {
var stackGroup = trace.stackgroup;
if (!stackGroup) return;
var stackOpts = fullLayout._scatterStackOpts[xa._id + ya._id][stackGroup];
var stackAx = stackOpts.orientation === 'v' ? ya : xa;
// Allow stacking only on numeric axes
// calc is a little late to be figuring this out, but during supplyDefaults
// we don't know the axis type yet
if (stackAx.type === 'linear' || stackAx.type === 'log') return stackOpts;
}
module.exports = {
calc: calc,
calcMarkerSize: calcMarkerSize,
calcAxisExpansion: calcAxisExpansion,
setFirstScatter: setFirstScatter,
getStackOpts: getStackOpts
};
/***/ }),
/***/ 4500:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
module.exports = function calcSelection(cd, trace) {
if (Lib.isArrayOrTypedArray(trace.selectedpoints)) {
Lib.tagSelected(cd, trace);
}
};
/***/ }),
/***/ 90136:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var hasColorscale = (__webpack_require__(94288).hasColorscale);
var calcColorscale = __webpack_require__(47128);
var subTypes = __webpack_require__(43028);
module.exports = function calcMarkerColorscale(gd, trace) {
if (subTypes.hasLines(trace) && hasColorscale(trace, 'line')) {
calcColorscale(gd, trace, {
vals: trace.line.color,
containerStr: 'line',
cLetter: 'c'
});
}
if (subTypes.hasMarkers(trace)) {
if (hasColorscale(trace, 'marker')) {
calcColorscale(gd, trace, {
vals: trace.marker.color,
containerStr: 'marker',
cLetter: 'c'
});
}
if (hasColorscale(trace, 'marker.line')) {
calcColorscale(gd, trace, {
vals: trace.marker.line.color,
containerStr: 'marker.line',
cLetter: 'c'
});
}
}
};
/***/ }),
/***/ 88200:
/***/ (function(module) {
"use strict";
module.exports = {
PTS_LINESONLY: 20,
// fixed parameters of clustering and clipping algorithms
// fraction of clustering tolerance "so close we don't even consider it a new point"
minTolerance: 0.2,
// how fast does clustering tolerance increase as you get away from the visible region
toleranceGrowth: 10,
// number of viewport sizes away from the visible region
// at which we clip all lines to the perimeter
maxScreensAway: 20,
eventDataKeys: []
};
/***/ }),
/***/ 96664:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var calc = __webpack_require__(16356);
var setGroupPositions = (__webpack_require__(96376).setGroupPositions);
function groupCrossTraceCalc(gd, plotinfo) {
var xa = plotinfo.xaxis;
var ya = plotinfo.yaxis;
var fullLayout = gd._fullLayout;
var fullTraces = gd._fullData;
var calcTraces = gd.calcdata;
var calcTracesHorz = [];
var calcTracesVert = [];
for (var i = 0; i < fullTraces.length; i++) {
var fullTrace = fullTraces[i];
if (fullTrace.visible === true && fullTrace.type === 'scatter' && fullTrace.xaxis === xa._id && fullTrace.yaxis === ya._id) {
if (fullTrace.orientation === 'h') {
calcTracesHorz.push(calcTraces[i]);
} else if (fullTrace.orientation === 'v') {
// check for v since certain scatter traces may not have an orientation
calcTracesVert.push(calcTraces[i]);
}
}
}
var opts = {
mode: fullLayout.scattermode,
gap: fullLayout.scattergap
};
setGroupPositions(gd, xa, ya, calcTracesVert, opts);
setGroupPositions(gd, ya, xa, calcTracesHorz, opts);
}
/*
* Scatter stacking & normalization calculations
* runs per subplot, and can handle multiple stacking groups
*/
module.exports = function crossTraceCalc(gd, plotinfo) {
if (gd._fullLayout.scattermode === 'group') {
groupCrossTraceCalc(gd, plotinfo);
}
var xa = plotinfo.xaxis;
var ya = plotinfo.yaxis;
var subplot = xa._id + ya._id;
var subplotStackOpts = gd._fullLayout._scatterStackOpts[subplot];
if (!subplotStackOpts) return;
var calcTraces = gd.calcdata;
var i, j, k, i2, cd, cd0, posj, sumj, norm;
var groupOpts, interpolate, groupnorm, posAttr, valAttr;
var hasAnyBlanks;
for (var stackGroup in subplotStackOpts) {
groupOpts = subplotStackOpts[stackGroup];
var indices = groupOpts.traceIndices;
// can get here with no indices if the stack axis is non-numeric
if (!indices.length) continue;
interpolate = groupOpts.stackgaps === 'interpolate';
groupnorm = groupOpts.groupnorm;
if (groupOpts.orientation === 'v') {
posAttr = 'x';
valAttr = 'y';
} else {
posAttr = 'y';
valAttr = 'x';
}
hasAnyBlanks = new Array(indices.length);
for (i = 0; i < hasAnyBlanks.length; i++) {
hasAnyBlanks[i] = false;
}
// Collect the complete set of all positions across ALL traces.
// Start with the first trace, then interleave items from later traces
// as needed.
// Fill in mising items as we go.
cd0 = calcTraces[indices[0]];
var allPositions = new Array(cd0.length);
for (i = 0; i < cd0.length; i++) {
allPositions[i] = cd0[i][posAttr];
}
for (i = 1; i < indices.length; i++) {
cd = calcTraces[indices[i]];
for (j = k = 0; j < cd.length; j++) {
posj = cd[j][posAttr];
for (; posj > allPositions[k] && k < allPositions.length; k++) {
// the current trace is missing a position from some previous trace(s)
insertBlank(cd, j, allPositions[k], i, hasAnyBlanks, interpolate, posAttr);
j++;
}
if (posj !== allPositions[k]) {
// previous trace(s) are missing a position from the current trace
for (i2 = 0; i2 < i; i2++) {
insertBlank(calcTraces[indices[i2]], k, posj, i2, hasAnyBlanks, interpolate, posAttr);
}
allPositions.splice(k, 0, posj);
}
k++;
}
for (; k < allPositions.length; k++) {
insertBlank(cd, j, allPositions[k], i, hasAnyBlanks, interpolate, posAttr);
j++;
}
}
var serieslen = allPositions.length;
// stack (and normalize)!
for (j = 0; j < cd0.length; j++) {
sumj = cd0[j][valAttr] = cd0[j].s;
for (i = 1; i < indices.length; i++) {
cd = calcTraces[indices[i]];
cd[0].trace._rawLength = cd[0].trace._length;
cd[0].trace._length = serieslen;
sumj += cd[j].s;
cd[j][valAttr] = sumj;
}
if (groupnorm) {
norm = (groupnorm === 'fraction' ? sumj : sumj / 100) || 1;
for (i = 0; i < indices.length; i++) {
var cdj = calcTraces[indices[i]][j];
cdj[valAttr] /= norm;
cdj.sNorm = cdj.s / norm;
}
}
}
// autorange
for (i = 0; i < indices.length; i++) {
cd = calcTraces[indices[i]];
var trace = cd[0].trace;
var ppad = calc.calcMarkerSize(trace, trace._rawLength);
var arrayPad = Array.isArray(ppad);
if (ppad && hasAnyBlanks[i] || arrayPad) {
var ppadRaw = ppad;
ppad = new Array(serieslen);
for (j = 0; j < serieslen; j++) {
ppad[j] = cd[j].gap ? 0 : arrayPad ? ppadRaw[cd[j].i] : ppadRaw;
}
}
var x = new Array(serieslen);
var y = new Array(serieslen);
for (j = 0; j < serieslen; j++) {
x[j] = cd[j].x;
y[j] = cd[j].y;
}
calc.calcAxisExpansion(gd, trace, xa, ya, x, y, ppad);
// while we're here (in a loop over all traces in the stack)
// record the orientation, so hover can find it easily
cd[0].t.orientation = groupOpts.orientation;
}
}
};
function insertBlank(calcTrace, index, position, traceIndex, hasAnyBlanks, interpolate, posAttr) {
hasAnyBlanks[traceIndex] = true;
var newEntry = {
i: null,
gap: true,
s: 0
};
newEntry[posAttr] = position;
calcTrace.splice(index, 0, newEntry);
// Even if we're not interpolating, if one trace has multiple
// values at the same position and this trace only has one value there,
// we just duplicate that one value rather than insert a zero.
// We also make it look like a real point - because it's ambiguous which
// one really is the real one!
if (index && position === calcTrace[index - 1][posAttr]) {
var prevEntry = calcTrace[index - 1];
newEntry.s = prevEntry.s;
// TODO is it going to cause any problems to have multiple
// calcdata points with the same index?
newEntry.i = prevEntry.i;
newEntry.gap = prevEntry.gap;
} else if (interpolate) {
newEntry.s = getInterp(calcTrace, index, position, posAttr);
}
if (!index) {
// t and trace need to stay on the first cd entry
calcTrace[0].t = calcTrace[1].t;
calcTrace[0].trace = calcTrace[1].trace;
delete calcTrace[1].t;
delete calcTrace[1].trace;
}
}
function getInterp(calcTrace, index, position, posAttr) {
var pt0 = calcTrace[index - 1];
var pt1 = calcTrace[index + 1];
if (!pt1) return pt0.s;
if (!pt0) return pt1.s;
return pt0.s + (pt1.s - pt0.s) * (position - pt0[posAttr]) / (pt1[posAttr] - pt0[posAttr]);
}
/***/ }),
/***/ 35036:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var handleGroupingDefaults = __webpack_require__(20011);
var attributes = __webpack_require__(52904);
// remove opacity for any trace that has a fill or is filled to
module.exports = function crossTraceDefaults(fullData, fullLayout) {
var traceIn, traceOut, i;
function coerce(attr) {
return Lib.coerce(traceOut._input, traceOut, attributes, attr);
}
if (fullLayout.scattermode === 'group') {
for (i = 0; i < fullData.length; i++) {
traceOut = fullData[i];
if (traceOut.type === 'scatter') {
traceIn = traceOut._input;
handleGroupingDefaults(traceIn, traceOut, fullLayout, coerce);
}
}
}
for (i = 0; i < fullData.length; i++) {
var tracei = fullData[i];
if (tracei.type !== 'scatter') continue;
var filli = tracei.fill;
if (filli === 'none' || filli === 'toself') continue;
tracei.opacity = undefined;
if (filli === 'tonexty' || filli === 'tonextx') {
for (var j = i - 1; j >= 0; j--) {
var tracej = fullData[j];
if (tracej.type === 'scatter' && tracej.xaxis === tracei.xaxis && tracej.yaxis === tracei.yaxis) {
tracej.opacity = undefined;
break;
}
}
}
}
};
/***/ }),
/***/ 18800:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Registry = __webpack_require__(24040);
var attributes = __webpack_require__(52904);
var constants = __webpack_require__(88200);
var subTypes = __webpack_require__(43028);
var handleXYDefaults = __webpack_require__(43980);
var handlePeriodDefaults = __webpack_require__(31147);
var handleStackDefaults = __webpack_require__(43912);
var handleMarkerDefaults = __webpack_require__(74428);
var handleLineDefaults = __webpack_require__(66828);
var handleLineShapeDefaults = __webpack_require__(11731);
var handleTextDefaults = __webpack_require__(124);
var handleFillColorDefaults = __webpack_require__(70840);
var coercePattern = (__webpack_require__(3400).coercePattern);
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var len = handleXYDefaults(traceIn, traceOut, layout, coerce);
if (!len) traceOut.visible = false;
if (!traceOut.visible) return;
handlePeriodDefaults(traceIn, traceOut, layout, coerce);
coerce('xhoverformat');
coerce('yhoverformat');
coerce('zorder');
var stackGroupOpts = handleStackDefaults(traceIn, traceOut, layout, coerce);
if (layout.scattermode === 'group' && traceOut.orientation === undefined) {
coerce('orientation', 'v');
}
var defaultMode = !stackGroupOpts && len < constants.PTS_LINESONLY ? 'lines+markers' : 'lines';
coerce('text');
coerce('hovertext');
coerce('mode', defaultMode);
if (subTypes.hasMarkers(traceOut)) {
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, {
gradient: true
});
}
if (subTypes.hasLines(traceOut)) {
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce, {
backoff: true
});
handleLineShapeDefaults(traceIn, traceOut, coerce);
coerce('connectgaps');
coerce('line.simplify');
}
if (subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}
var dfltHoverOn = [];
if (subTypes.hasMarkers(traceOut) || subTypes.hasText(traceOut)) {
coerce('cliponaxis');
coerce('marker.maxdisplayed');
dfltHoverOn.push('points');
}
// It's possible for this default to be changed by a later trace.
// We handle that case in some hacky code inside handleStackDefaults.
coerce('fill', stackGroupOpts ? stackGroupOpts.fillDflt : 'none');
if (traceOut.fill !== 'none') {
handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce, {
moduleHasFillgradient: true
});
if (!subTypes.hasLines(traceOut)) handleLineShapeDefaults(traceIn, traceOut, coerce);
coercePattern(coerce, 'fillpattern', traceOut.fillcolor, false);
}
var lineColor = (traceOut.line || {}).color;
var markerColor = (traceOut.marker || {}).color;
if (traceOut.fill === 'tonext' || traceOut.fill === 'toself') {
dfltHoverOn.push('fills');
}
coerce('hoveron', dfltHoverOn.join('+') || 'points');
if (traceOut.hoveron !== 'fills') coerce('hovertemplate');
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {
axis: 'y'
});
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {
axis: 'x',
inherit: 'y'
});
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
};
/***/ }),
/***/ 98304:
/***/ (function(module) {
"use strict";
module.exports = function makeFillcolorAttr(hasFillgradient) {
return {
valType: 'color',
editType: 'style',
anim: true
};
};
/***/ }),
/***/ 70840:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Color = __webpack_require__(76308);
var isArrayOrTypedArray = (__webpack_require__(3400).isArrayOrTypedArray);
function averageColors(colorscale) {
var color = Color.interpolate(colorscale[0][1], colorscale[1][1], 0.5);
for (var i = 2; i < colorscale.length; i++) {
var averageColorI = Color.interpolate(colorscale[i - 1][1], colorscale[i][1], 0.5);
color = Color.interpolate(color, averageColorI, colorscale[i - 1][0] / colorscale[i][0]);
}
return color;
}
module.exports = function fillColorDefaults(traceIn, traceOut, defaultColor, coerce, opts) {
if (!opts) opts = {};
var inheritColorFromMarker = false;
if (traceOut.marker) {
// don't try to inherit a color array
var markerColor = traceOut.marker.color;
var markerLineColor = (traceOut.marker.line || {}).color;
if (markerColor && !isArrayOrTypedArray(markerColor)) {
inheritColorFromMarker = markerColor;
} else if (markerLineColor && !isArrayOrTypedArray(markerLineColor)) {
inheritColorFromMarker = markerLineColor;
}
}
var averageGradientColor;
if (opts.moduleHasFillgradient) {
var gradientOrientation = coerce('fillgradient.type');
if (gradientOrientation !== 'none') {
coerce('fillgradient.start');
coerce('fillgradient.stop');
var gradientColorscale = coerce('fillgradient.colorscale');
// if a fillgradient is specified, we use the average gradient color
// to specify fillcolor after all other more specific candidates
// are considered, but before the global default color.
// fillcolor affects the background color of the hoverlabel in this case.
if (gradientColorscale) {
averageGradientColor = averageColors(gradientColorscale);
}
}
}
coerce('fillcolor', Color.addOpacity((traceOut.line || {}).color || inheritColorFromMarker || averageGradientColor || defaultColor, 0.5));
};
/***/ }),
/***/ 76688:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Axes = __webpack_require__(54460);
module.exports = function formatLabels(cdi, trace, fullLayout) {
var labels = {};
var mockGd = {
_fullLayout: fullLayout
};
var xa = Axes.getFromTrace(mockGd, trace, 'x');
var ya = Axes.getFromTrace(mockGd, trace, 'y');
var x = cdi.orig_x;
if (x === undefined) x = cdi.x;
var y = cdi.orig_y;
if (y === undefined) y = cdi.y;
labels.xLabel = Axes.tickText(xa, xa.c2l(x), true).text;
labels.yLabel = Axes.tickText(ya, ya.c2l(y), true).text;
return labels;
};
/***/ }),
/***/ 44928:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Color = __webpack_require__(76308);
var subtypes = __webpack_require__(43028);
module.exports = function getTraceColor(trace, di) {
var lc, tc;
// TODO: text modes
if (trace.mode === 'lines') {
lc = trace.line.color;
return lc && Color.opacity(lc) ? lc : trace.fillcolor;
} else if (trace.mode === 'none') {
return trace.fill ? trace.fillcolor : '';
} else {
var mc = di.mcc || (trace.marker || {}).color;
var mlc = di.mlcc || ((trace.marker || {}).line || {}).color;
tc = mc && Color.opacity(mc) ? mc : mlc && Color.opacity(mlc) && (di.mlw || ((trace.marker || {}).line || {}).width) ? mlc : '';
if (tc) {
// make sure the points aren't TOO transparent
if (Color.opacity(tc) < 0.3) {
return Color.addOpacity(tc, 0.3);
} else return tc;
} else {
lc = (trace.line || {}).color;
return lc && Color.opacity(lc) && subtypes.hasLines(trace) && trace.line.width ? lc : trace.fillcolor;
}
}
};
/***/ }),
/***/ 20011:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var getAxisGroup = (__webpack_require__(71888).getAxisGroup);
module.exports = function handleGroupingDefaults(traceIn, traceOut, fullLayout, coerce) {
var orientation = traceOut.orientation;
// N.B. grouping is done across all trace types that support it
var posAxId = traceOut[{
v: 'x',
h: 'y'
}[orientation] + 'axis'];
var groupId = getAxisGroup(fullLayout, posAxId) + orientation;
var alignmentOpts = fullLayout._alignmentOpts || {};
var alignmentgroup = coerce('alignmentgroup');
var alignmentGroups = alignmentOpts[groupId];
if (!alignmentGroups) alignmentGroups = alignmentOpts[groupId] = {};
var alignmentGroupOpts = alignmentGroups[alignmentgroup];
if (alignmentGroupOpts) {
alignmentGroupOpts.traces.push(traceOut);
} else {
alignmentGroupOpts = alignmentGroups[alignmentgroup] = {
traces: [traceOut],
alignmentIndex: Object.keys(alignmentGroups).length,
offsetGroups: {}
};
}
var offsetgroup = coerce('offsetgroup');
var offsetGroups = alignmentGroupOpts.offsetGroups;
var offsetGroupOpts = offsetGroups[offsetgroup];
if (offsetgroup) {
if (!offsetGroupOpts) {
offsetGroupOpts = offsetGroups[offsetgroup] = {
offsetIndex: Object.keys(offsetGroups).length
};
}
traceOut._offsetIndex = offsetGroupOpts.offsetIndex;
}
};
/***/ }),
/***/ 98723:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Fx = __webpack_require__(93024);
var Registry = __webpack_require__(24040);
var getTraceColor = __webpack_require__(44928);
var Color = __webpack_require__(76308);
var fillText = Lib.fillText;
module.exports = function hoverPoints(pointData, xval, yval, hovermode) {
var cd = pointData.cd;
var trace = cd[0].trace;
var xa = pointData.xa;
var ya = pointData.ya;
var xpx = xa.c2p(xval);
var ypx = ya.c2p(yval);
var pt = [xpx, ypx];
var hoveron = trace.hoveron || '';
var minRad = trace.mode.indexOf('markers') !== -1 ? 3 : 0.5;
var xPeriod = !!trace.xperiodalignment;
var yPeriod = !!trace.yperiodalignment;
// look for points to hover on first, then take fills only if we
// didn't find a point
if (hoveron.indexOf('points') !== -1) {
// dx and dy are used in compare modes - here we want to always
// prioritize the closest data point, at least as long as markers are
// the same size or nonexistent, but still try to prioritize small markers too.
var dx = function (di) {
if (xPeriod) {
var x0 = xa.c2p(di.xStart);
var x1 = xa.c2p(di.xEnd);
return xpx >= Math.min(x0, x1) && xpx <= Math.max(x0, x1) ? 0 : Infinity;
}
var rad = Math.max(3, di.mrc || 0);
var kink = 1 - 1 / rad;
var dxRaw = Math.abs(xa.c2p(di.x) - xpx);
return dxRaw < rad ? kink * dxRaw / rad : dxRaw - rad + kink;
};
var dy = function (di) {
if (yPeriod) {
var y0 = ya.c2p(di.yStart);
var y1 = ya.c2p(di.yEnd);
return ypx >= Math.min(y0, y1) && ypx <= Math.max(y0, y1) ? 0 : Infinity;
}
var rad = Math.max(3, di.mrc || 0);
var kink = 1 - 1 / rad;
var dyRaw = Math.abs(ya.c2p(di.y) - ypx);
return dyRaw < rad ? kink * dyRaw / rad : dyRaw - rad + kink;
};
// scatter points: d.mrc is the calculated marker radius
// adjust the distance so if you're inside the marker it
// always will show up regardless of point size, but
// prioritize smaller points
var dxy = function (di) {
var rad = Math.max(minRad, di.mrc || 0);
var dx = xa.c2p(di.x) - xpx;
var dy = ya.c2p(di.y) - ypx;
return Math.max(Math.sqrt(dx * dx + dy * dy) - rad, 1 - minRad / rad);
};
var distfn = Fx.getDistanceFunction(hovermode, dx, dy, dxy);
Fx.getClosest(cd, distfn, pointData);
// skip the rest (for this trace) if we didn't find a close point
if (pointData.index !== false) {
// the closest data point
var di = cd[pointData.index];
var xc = xa.c2p(di.x, true);
var yc = ya.c2p(di.y, true);
var rad = di.mrc || 1;
// now we're done using the whole `calcdata` array, replace the
// index with the original index (in case of inserted point from
// stacked area)
pointData.index = di.i;
var orientation = cd[0].t.orientation;
// TODO: for scatter and bar, option to show (sub)totals and
// raw data? Currently stacked and/or normalized bars just show
// the normalized individual sizes, so that's what I'm doing here
// for now.
var sizeVal = orientation && (di.sNorm || di.s);
var xLabelVal = orientation === 'h' ? sizeVal : di.orig_x !== undefined ? di.orig_x : di.x;
var yLabelVal = orientation === 'v' ? sizeVal : di.orig_y !== undefined ? di.orig_y : di.y;
Lib.extendFlat(pointData, {
color: getTraceColor(trace, di),
x0: xc - rad,
x1: xc + rad,
xLabelVal: xLabelVal,
y0: yc - rad,
y1: yc + rad,
yLabelVal: yLabelVal,
spikeDistance: dxy(di),
hovertemplate: trace.hovertemplate
});
fillText(di, trace, pointData);
Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData);
return [pointData];
}
}
function isHoverPointInFillElement(el) {
// Uses SVGElement.isPointInFill to accurately determine wether
// the hover point / cursor is contained in the fill, taking
// curved or jagged edges into account, which the Polygon-based
// approach does not.
if (!el) {
return false;
}
var svgElement = el.node();
try {
var domPoint = new DOMPoint(pt[0], pt[1]);
return svgElement.isPointInFill(domPoint);
} catch (TypeError) {
var svgPoint = svgElement.ownerSVGElement.createSVGPoint();
svgPoint.x = pt[0];
svgPoint.y = pt[1];
return svgElement.isPointInFill(svgPoint);
}
}
function getHoverLabelPosition(polygons) {
// Uses Polygon s to determine the left- and right-most x-coordinates
// of the subshape of the fill that contains the hover point / cursor.
// Doing this with the SVGElement directly is quite tricky, so this falls
// back to the existing relatively simple code, accepting some small inaccuracies
// of label positioning for curved/jagged edges.
var i;
var polygonsIn = [];
var xmin = Infinity;
var xmax = -Infinity;
var ymin = Infinity;
var ymax = -Infinity;
var yPos;
for (i = 0; i < polygons.length; i++) {
var polygon = polygons[i];
// This is not going to work right for curved or jagged edges, it will
// act as though they're straight.
if (polygon.contains(pt)) {
polygonsIn.push(polygon);
ymin = Math.min(ymin, polygon.ymin);
ymax = Math.max(ymax, polygon.ymax);
}
}
// The above found no polygon that contains the cursor, but we know that
// the cursor must be inside the fill as determined by the SVGElement
// (so we are probably close to a curved/jagged edge...).
if (polygonsIn.length === 0) {
return null;
}
// constrain ymin/max to the visible plot, so the label goes
// at the middle of the piece you can see
ymin = Math.max(ymin, 0);
ymax = Math.min(ymax, ya._length);
yPos = (ymin + ymax) / 2;
// find the overall left-most and right-most points of the
// polygon(s) we're inside at their combined vertical midpoint.
// This is where we will draw the hover label.
// Note that this might not be the vertical midpoint of the
// whole trace, if it's disjoint.
var j, pts, xAtYPos, x0, x1, y0, y1;
for (i = 0; i < polygonsIn.length; i++) {
pts = polygonsIn[i].pts;
for (j = 1; j < pts.length; j++) {
y0 = pts[j - 1][1];
y1 = pts[j][1];
if (y0 > yPos !== y1 >= yPos) {
x0 = pts[j - 1][0];
x1 = pts[j][0];
if (y1 - y0) {
xAtYPos = x0 + (x1 - x0) * (yPos - y0) / (y1 - y0);
xmin = Math.min(xmin, xAtYPos);
xmax = Math.max(xmax, xAtYPos);
}
}
}
}
// constrain xmin/max to the visible plot now too
xmin = Math.max(xmin, 0);
xmax = Math.min(xmax, xa._length);
return {
x0: xmin,
x1: xmax,
y0: yPos,
y1: yPos
};
}
// even if hoveron is 'fills', only use it if we have a fill element too
if (hoveron.indexOf('fills') !== -1 && trace._fillElement) {
var inside = isHoverPointInFillElement(trace._fillElement) && !isHoverPointInFillElement(trace._fillExclusionElement);
if (inside) {
var hoverLabelCoords = getHoverLabelPosition(trace._polygons);
// getHoverLabelPosition may return null if the cursor / hover point is not contained
// in any of the trace's polygons, which can happen close to curved edges. in that
// case we fall back to displaying the hover label at the cursor position.
if (hoverLabelCoords === null) {
hoverLabelCoords = {
x0: pt[0],
x1: pt[0],
y0: pt[1],
y1: pt[1]
};
}
// get only fill or line color for the hover color
var color = Color.defaultLine;
if (Color.opacity(trace.fillcolor)) color = trace.fillcolor;else if (Color.opacity((trace.line || {}).color)) {
color = trace.line.color;
}
Lib.extendFlat(pointData, {
// never let a 2D override 1D type as closest point
// also: no spikeDistance, it's not allowed for fills
distance: pointData.maxHoverDistance,
x0: hoverLabelCoords.x0,
x1: hoverLabelCoords.x1,
y0: hoverLabelCoords.y0,
y1: hoverLabelCoords.y1,
color: color,
hovertemplate: false
});
delete pointData.index;
if (trace.text && !Lib.isArrayOrTypedArray(trace.text)) {
pointData.text = String(trace.text);
} else pointData.text = trace.name;
return [pointData];
}
}
};
/***/ }),
/***/ 65875:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var subtypes = __webpack_require__(43028);
module.exports = {
hasLines: subtypes.hasLines,
hasMarkers: subtypes.hasMarkers,
hasText: subtypes.hasText,
isBubble: subtypes.isBubble,
attributes: __webpack_require__(52904),
layoutAttributes: __webpack_require__(55308),
supplyDefaults: __webpack_require__(18800),
crossTraceDefaults: __webpack_require__(35036),
supplyLayoutDefaults: __webpack_require__(59748),
calc: (__webpack_require__(16356).calc),
crossTraceCalc: __webpack_require__(96664),
arraysToCalcdata: __webpack_require__(20148),
plot: __webpack_require__(96504),
colorbar: __webpack_require__(5528),
formatLabels: __webpack_require__(76688),
style: (__webpack_require__(49224).style),
styleOnSelect: (__webpack_require__(49224).styleOnSelect),
hoverPoints: __webpack_require__(98723),
selectPoints: __webpack_require__(91560),
animatable: true,
moduleType: 'trace',
name: 'scatter',
basePlotModule: __webpack_require__(57952),
categories: ['cartesian', 'svg', 'symbols', 'errorBarsOK', 'showLegend', 'scatter-like', 'zoomScale'],
meta: {}
};
/***/ }),
/***/ 55308:
/***/ (function(module) {
"use strict";
module.exports = {
scattermode: {
valType: 'enumerated',
values: ['group', 'overlay'],
dflt: 'overlay',
editType: 'calc'
},
scattergap: {
valType: 'number',
min: 0,
max: 1,
editType: 'calc'
}
};
/***/ }),
/***/ 59748:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var layoutAttributes = __webpack_require__(55308);
module.exports = function (layoutIn, layoutOut) {
function coerce(attr, dflt) {
return Lib.coerce(layoutIn, layoutOut, layoutAttributes, attr, dflt);
}
var groupBarmode = layoutOut.barmode === 'group';
if (layoutOut.scattermode === 'group') {
coerce('scattergap', groupBarmode ? layoutOut.bargap : 0.2);
}
};
/***/ }),
/***/ 66828:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isArrayOrTypedArray = (__webpack_require__(3400).isArrayOrTypedArray);
var hasColorscale = (__webpack_require__(94288).hasColorscale);
var colorscaleDefaults = __webpack_require__(27260);
module.exports = function lineDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) {
if (!opts) opts = {};
var markerColor = (traceIn.marker || {}).color;
if (markerColor && markerColor._inputArray) markerColor = markerColor._inputArray;
coerce('line.color', defaultColor);
if (hasColorscale(traceIn, 'line')) {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {
prefix: 'line.',
cLetter: 'c'
});
} else {
var lineColorDflt = (isArrayOrTypedArray(markerColor) ? false : markerColor) || defaultColor;
coerce('line.color', lineColorDflt);
}
coerce('line.width');
if (!opts.noDash) coerce('line.dash');
if (opts.backoff) coerce('line.backoff');
};
/***/ }),
/***/ 52340:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Drawing = __webpack_require__(43616);
var numConstants = __webpack_require__(39032);
var BADNUM = numConstants.BADNUM;
var LOG_CLIP = numConstants.LOG_CLIP;
var LOG_CLIP_PLUS = LOG_CLIP + 0.5;
var LOG_CLIP_MINUS = LOG_CLIP - 0.5;
var Lib = __webpack_require__(3400);
var segmentsIntersect = Lib.segmentsIntersect;
var constrain = Lib.constrain;
var constants = __webpack_require__(88200);
module.exports = function linePoints(d, opts) {
var trace = opts.trace || {};
var xa = opts.xaxis;
var ya = opts.yaxis;
var xLog = xa.type === 'log';
var yLog = ya.type === 'log';
var xLen = xa._length;
var yLen = ya._length;
var backoff = opts.backoff;
var marker = trace.marker;
var connectGaps = opts.connectGaps;
var baseTolerance = opts.baseTolerance;
var shape = opts.shape;
var linear = shape === 'linear';
var fill = trace.fill && trace.fill !== 'none';
var segments = [];
var minTolerance = constants.minTolerance;
var len = d.length;
var pts = new Array(len);
var pti = 0;
var i;
// pt variables are pixel coordinates [x,y] of one point
// these four are the outputs of clustering on a line
var clusterStartPt, clusterEndPt, clusterHighPt, clusterLowPt;
// "this" is the next point we're considering adding to the cluster
var thisPt;
// did we encounter the high point first, then a low point, or vice versa?
var clusterHighFirst;
// the first two points in the cluster determine its unit vector
// so the second is always in the "High" direction
var clusterUnitVector;
// the pixel delta from clusterStartPt
var thisVector;
// val variables are (signed) pixel distances along the cluster vector
var clusterRefDist, clusterHighVal, clusterLowVal, thisVal;
// deviation variables are (signed) pixel distances normal to the cluster vector
var clusterMinDeviation, clusterMaxDeviation, thisDeviation;
// turn one calcdata point into pixel coordinates
function getPt(index) {
var di = d[index];
if (!di) return false;
var x = opts.linearized ? xa.l2p(di.x) : xa.c2p(di.x);
var y = opts.linearized ? ya.l2p(di.y) : ya.c2p(di.y);
// if non-positive log values, set them VERY far off-screen
// so the line looks essentially straight from the previous point.
if (x === BADNUM) {
if (xLog) x = xa.c2p(di.x, true);
if (x === BADNUM) return false;
// If BOTH were bad log values, make the line follow a constant
// exponent rather than a constant slope
if (yLog && y === BADNUM) {
x *= Math.abs(xa._m * yLen * (xa._m > 0 ? LOG_CLIP_PLUS : LOG_CLIP_MINUS) / (ya._m * xLen * (ya._m > 0 ? LOG_CLIP_PLUS : LOG_CLIP_MINUS)));
}
x *= 1000;
}
if (y === BADNUM) {
if (yLog) y = ya.c2p(di.y, true);
if (y === BADNUM) return false;
y *= 1000;
}
return [x, y];
}
function crossesViewport(xFrac0, yFrac0, xFrac1, yFrac1) {
var dx = xFrac1 - xFrac0;
var dy = yFrac1 - yFrac0;
var dx0 = 0.5 - xFrac0;
var dy0 = 0.5 - yFrac0;
var norm2 = dx * dx + dy * dy;
var dot = dx * dx0 + dy * dy0;
if (dot > 0 && dot < norm2) {
var cross = dx0 * dy - dy0 * dx;
if (cross * cross < norm2) return true;
}
}
var latestXFrac, latestYFrac;
// if we're off-screen, increase tolerance over baseTolerance
function getTolerance(pt, nextPt) {
var xFrac = pt[0] / xLen;
var yFrac = pt[1] / yLen;
var offScreenFraction = Math.max(0, -xFrac, xFrac - 1, -yFrac, yFrac - 1);
if (offScreenFraction && latestXFrac !== undefined && crossesViewport(xFrac, yFrac, latestXFrac, latestYFrac)) {
offScreenFraction = 0;
}
if (offScreenFraction && nextPt && crossesViewport(xFrac, yFrac, nextPt[0] / xLen, nextPt[1] / yLen)) {
offScreenFraction = 0;
}
return (1 + constants.toleranceGrowth * offScreenFraction) * baseTolerance;
}
function ptDist(pt1, pt2) {
var dx = pt1[0] - pt2[0];
var dy = pt1[1] - pt2[1];
return Math.sqrt(dx * dx + dy * dy);
}
// last bit of filtering: clip paths that are VERY far off-screen
// so we don't get near the browser's hard limit (+/- 2^29 px in Chrome and FF)
var maxScreensAway = constants.maxScreensAway;
// find the intersections between the segment from pt1 to pt2
// and the large rectangle maxScreensAway around the viewport
// if one of pt1 and pt2 is inside and the other outside, there
// will be only one intersection.
// if both are outside there will be 0 or 2 intersections
// (or 1 if it's right at a corner - we'll treat that like 0)
// returns an array of intersection pts
var xEdge0 = -xLen * maxScreensAway;
var xEdge1 = xLen * (1 + maxScreensAway);
var yEdge0 = -yLen * maxScreensAway;
var yEdge1 = yLen * (1 + maxScreensAway);
var edges = [[xEdge0, yEdge0, xEdge1, yEdge0], [xEdge1, yEdge0, xEdge1, yEdge1], [xEdge1, yEdge1, xEdge0, yEdge1], [xEdge0, yEdge1, xEdge0, yEdge0]];
var xEdge, yEdge, lastXEdge, lastYEdge, lastFarPt, edgePt;
// for linear line shape, edge intersections should be linearly interpolated
// spline uses this too, which isn't precisely correct but is actually pretty
// good, because Catmull-Rom weights far-away points less in creating the curvature
function getLinearEdgeIntersections(pt1, pt2) {
var out = [];
var ptCount = 0;
for (var i = 0; i < 4; i++) {
var edge = edges[i];
var ptInt = segmentsIntersect(pt1[0], pt1[1], pt2[0], pt2[1], edge[0], edge[1], edge[2], edge[3]);
if (ptInt && (!ptCount || Math.abs(ptInt.x - out[0][0]) > 1 || Math.abs(ptInt.y - out[0][1]) > 1)) {
ptInt = [ptInt.x, ptInt.y];
// if we have 2 intersections, make sure the closest one to pt1 comes first
if (ptCount && ptDist(ptInt, pt1) < ptDist(out[0], pt1)) out.unshift(ptInt);else out.push(ptInt);
ptCount++;
}
}
return out;
}
function onlyConstrainedPoint(pt) {
if (pt[0] < xEdge0 || pt[0] > xEdge1 || pt[1] < yEdge0 || pt[1] > yEdge1) {
return [constrain(pt[0], xEdge0, xEdge1), constrain(pt[1], yEdge0, yEdge1)];
}
}
function sameEdge(pt1, pt2) {
if (pt1[0] === pt2[0] && (pt1[0] === xEdge0 || pt1[0] === xEdge1)) return true;
if (pt1[1] === pt2[1] && (pt1[1] === yEdge0 || pt1[1] === yEdge1)) return true;
}
// for line shapes hv and vh, movement in the two dimensions is decoupled,
// so all we need to do is constrain each dimension independently
function getHVEdgeIntersections(pt1, pt2) {
var out = [];
var ptInt1 = onlyConstrainedPoint(pt1);
var ptInt2 = onlyConstrainedPoint(pt2);
if (ptInt1 && ptInt2 && sameEdge(ptInt1, ptInt2)) return out;
if (ptInt1) out.push(ptInt1);
if (ptInt2) out.push(ptInt2);
return out;
}
// hvh and vhv we sometimes have to move one of the intersection points
// out BEYOND the clipping rect, by a maximum of a factor of 2, so that
// the midpoint line is drawn in the right place
function getABAEdgeIntersections(dim, limit0, limit1) {
return function (pt1, pt2) {
var ptInt1 = onlyConstrainedPoint(pt1);
var ptInt2 = onlyConstrainedPoint(pt2);
var out = [];
if (ptInt1 && ptInt2 && sameEdge(ptInt1, ptInt2)) return out;
if (ptInt1) out.push(ptInt1);
if (ptInt2) out.push(ptInt2);
var midShift = 2 * Lib.constrain((pt1[dim] + pt2[dim]) / 2, limit0, limit1) - ((ptInt1 || pt1)[dim] + (ptInt2 || pt2)[dim]);
if (midShift) {
var ptToAlter;
if (ptInt1 && ptInt2) {
ptToAlter = midShift > 0 === ptInt1[dim] > ptInt2[dim] ? ptInt1 : ptInt2;
} else ptToAlter = ptInt1 || ptInt2;
ptToAlter[dim] += midShift;
}
return out;
};
}
var getEdgeIntersections;
if (shape === 'linear' || shape === 'spline') {
getEdgeIntersections = getLinearEdgeIntersections;
} else if (shape === 'hv' || shape === 'vh') {
getEdgeIntersections = getHVEdgeIntersections;
} else if (shape === 'hvh') getEdgeIntersections = getABAEdgeIntersections(0, xEdge0, xEdge1);else if (shape === 'vhv') getEdgeIntersections = getABAEdgeIntersections(1, yEdge0, yEdge1);
// a segment pt1->pt2 entirely outside the nearby region:
// find the corner it gets closest to touching
function getClosestCorner(pt1, pt2) {
var dx = pt2[0] - pt1[0];
var m = (pt2[1] - pt1[1]) / dx;
var b = (pt1[1] * pt2[0] - pt2[1] * pt1[0]) / dx;
if (b > 0) return [m > 0 ? xEdge0 : xEdge1, yEdge1];else return [m > 0 ? xEdge1 : xEdge0, yEdge0];
}
function updateEdge(pt) {
var x = pt[0];
var y = pt[1];
var xSame = x === pts[pti - 1][0];
var ySame = y === pts[pti - 1][1];
// duplicate point?
if (xSame && ySame) return;
if (pti > 1) {
// backtracking along an edge?
var xSame2 = x === pts[pti - 2][0];
var ySame2 = y === pts[pti - 2][1];
if (xSame && (x === xEdge0 || x === xEdge1) && xSame2) {
if (ySame2) pti--; // backtracking exactly - drop prev pt and don't add
else pts[pti - 1] = pt; // not exact: replace the prev pt
} else if (ySame && (y === yEdge0 || y === yEdge1) && ySame2) {
if (xSame2) pti--;else pts[pti - 1] = pt;
} else pts[pti++] = pt;
} else pts[pti++] = pt;
}
function updateEdgesForReentry(pt) {
// if we're outside the nearby region and going back in,
// we may need to loop around a corner point
if (pts[pti - 1][0] !== pt[0] && pts[pti - 1][1] !== pt[1]) {
updateEdge([lastXEdge, lastYEdge]);
}
updateEdge(pt);
lastFarPt = null;
lastXEdge = lastYEdge = 0;
}
var arrayMarker = Lib.isArrayOrTypedArray(marker);
function addPt(pt) {
if (pt && backoff) {
pt.i = i;
pt.d = d;
pt.trace = trace;
pt.marker = arrayMarker ? marker[pt.i] : marker;
pt.backoff = backoff;
}
latestXFrac = pt[0] / xLen;
latestYFrac = pt[1] / yLen;
// Are we more than maxScreensAway off-screen any direction?
// if so, clip to this box, but in such a way that on-screen
// drawing is unchanged
xEdge = pt[0] < xEdge0 ? xEdge0 : pt[0] > xEdge1 ? xEdge1 : 0;
yEdge = pt[1] < yEdge0 ? yEdge0 : pt[1] > yEdge1 ? yEdge1 : 0;
if (xEdge || yEdge) {
if (!pti) {
// to get fills right - if first point is far, push it toward the
// screen in whichever direction(s) are far
pts[pti++] = [xEdge || pt[0], yEdge || pt[1]];
} else if (lastFarPt) {
// both this point and the last are outside the nearby region
// check if we're crossing the nearby region
var intersections = getEdgeIntersections(lastFarPt, pt);
if (intersections.length > 1) {
updateEdgesForReentry(intersections[0]);
pts[pti++] = intersections[1];
}
} else {
// we're leaving the nearby region - add the point where we left it
edgePt = getEdgeIntersections(pts[pti - 1], pt)[0];
pts[pti++] = edgePt;
}
var lastPt = pts[pti - 1];
if (xEdge && yEdge && (lastPt[0] !== xEdge || lastPt[1] !== yEdge)) {
// we've gone out beyond a new corner: add the corner too
// so that the next point will take the right winding
if (lastFarPt) {
if (lastXEdge !== xEdge && lastYEdge !== yEdge) {
if (lastXEdge && lastYEdge) {
// we've gone around to an opposite corner - we
// need to add the correct extra corner
// in order to get the right winding
updateEdge(getClosestCorner(lastFarPt, pt));
} else {
// we're coming from a far edge - the extra corner
// we need is determined uniquely by the sectors
updateEdge([lastXEdge || xEdge, lastYEdge || yEdge]);
}
} else if (lastXEdge && lastYEdge) {
updateEdge([lastXEdge, lastYEdge]);
}
}
updateEdge([xEdge, yEdge]);
} else if (lastXEdge - xEdge && lastYEdge - yEdge) {
// we're coming from an edge or far corner to an edge - again the
// extra corner we need is uniquely determined by the sectors
updateEdge([xEdge || lastXEdge, yEdge || lastYEdge]);
}
lastFarPt = pt;
lastXEdge = xEdge;
lastYEdge = yEdge;
} else {
if (lastFarPt) {
// this point is in range but the previous wasn't: add its entry pt first
updateEdgesForReentry(getEdgeIntersections(lastFarPt, pt)[0]);
}
pts[pti++] = pt;
}
}
// loop over ALL points in this trace
for (i = 0; i < len; i++) {
clusterStartPt = getPt(i);
if (!clusterStartPt) continue;
pti = 0;
lastFarPt = null;
addPt(clusterStartPt);
// loop over one segment of the trace
for (i++; i < len; i++) {
clusterHighPt = getPt(i);
if (!clusterHighPt) {
if (connectGaps) continue;else break;
}
// can't decimate if nonlinear line shape
// TODO: we *could* decimate [hv]{2,3} shapes if we restricted clusters to horz or vert again
// but spline would be verrry awkward to decimate
if (!linear || !opts.simplify) {
addPt(clusterHighPt);
continue;
}
var nextPt = getPt(i + 1);
clusterRefDist = ptDist(clusterHighPt, clusterStartPt);
// #3147 - always include the very first and last points for fills
if (!(fill && (pti === 0 || pti === len - 1)) && clusterRefDist < getTolerance(clusterHighPt, nextPt) * minTolerance) continue;
clusterUnitVector = [(clusterHighPt[0] - clusterStartPt[0]) / clusterRefDist, (clusterHighPt[1] - clusterStartPt[1]) / clusterRefDist];
clusterLowPt = clusterStartPt;
clusterHighVal = clusterRefDist;
clusterLowVal = clusterMinDeviation = clusterMaxDeviation = 0;
clusterHighFirst = false;
clusterEndPt = clusterHighPt;
// loop over one cluster of points that collapse onto one line
for (i++; i < d.length; i++) {
thisPt = nextPt;
nextPt = getPt(i + 1);
if (!thisPt) {
if (connectGaps) continue;else break;
}
thisVector = [thisPt[0] - clusterStartPt[0], thisPt[1] - clusterStartPt[1]];
// cross product (or dot with normal to the cluster vector)
thisDeviation = thisVector[0] * clusterUnitVector[1] - thisVector[1] * clusterUnitVector[0];
clusterMinDeviation = Math.min(clusterMinDeviation, thisDeviation);
clusterMaxDeviation = Math.max(clusterMaxDeviation, thisDeviation);
if (clusterMaxDeviation - clusterMinDeviation > getTolerance(thisPt, nextPt)) break;
clusterEndPt = thisPt;
thisVal = thisVector[0] * clusterUnitVector[0] + thisVector[1] * clusterUnitVector[1];
if (thisVal > clusterHighVal) {
clusterHighVal = thisVal;
clusterHighPt = thisPt;
clusterHighFirst = false;
} else if (thisVal < clusterLowVal) {
clusterLowVal = thisVal;
clusterLowPt = thisPt;
clusterHighFirst = true;
}
}
// insert this cluster into pts
// we've already inserted the start pt, now check if we have high and low pts
if (clusterHighFirst) {
addPt(clusterHighPt);
if (clusterEndPt !== clusterLowPt) addPt(clusterLowPt);
} else {
if (clusterLowPt !== clusterStartPt) addPt(clusterLowPt);
if (clusterEndPt !== clusterHighPt) addPt(clusterHighPt);
}
// and finally insert the end pt
addPt(clusterEndPt);
// have we reached the end of this segment?
if (i >= d.length || !thisPt) break;
// otherwise we have an out-of-cluster point to insert as next clusterStartPt
addPt(thisPt);
clusterStartPt = thisPt;
}
// to get fills right - repeat what we did at the start
if (lastFarPt) updateEdge([lastXEdge || lastFarPt[0], lastYEdge || lastFarPt[1]]);
segments.push(pts.slice(0, pti));
}
var lastShapeChar = shape.slice(shape.length - 1);
if (backoff && lastShapeChar !== 'h' && lastShapeChar !== 'v') {
var trimmed = false;
var n = -1;
var newSegments = [];
for (var j = 0; j < segments.length; j++) {
for (var k = 0; k < segments[j].length - 1; k++) {
var start = segments[j][k];
var end = segments[j][k + 1];
var xy = Drawing.applyBackoff(end, start);
if (xy[0] !== end[0] || xy[1] !== end[1]) {
trimmed = true;
}
if (!newSegments[n + 1]) {
n++;
newSegments[n] = [start, [xy[0], xy[1]]];
}
}
}
return trimmed ? newSegments : segments;
}
return segments;
};
/***/ }),
/***/ 11731:
/***/ (function(module) {
"use strict";
// common to 'scatter' and 'scatterternary'
module.exports = function handleLineShapeDefaults(traceIn, traceOut, coerce) {
var shape = coerce('line.shape');
if (shape === 'spline') coerce('line.smoothing');
};
/***/ }),
/***/ 14328:
/***/ (function(module) {
"use strict";
var LINKEDFILLS = {
tonextx: 1,
tonexty: 1,
tonext: 1
};
module.exports = function linkTraces(gd, plotinfo, cdscatter) {
var trace, i, group, prevtrace, groupIndex;
// first sort traces to keep stacks & filled-together groups together
var groupIndices = {};
var needsSort = false;
var prevGroupIndex = -1;
var nextGroupIndex = 0;
var prevUnstackedGroupIndex = -1;
for (i = 0; i < cdscatter.length; i++) {
trace = cdscatter[i][0].trace;
group = trace.stackgroup || '';
if (group) {
if (group in groupIndices) {
groupIndex = groupIndices[group];
} else {
groupIndex = groupIndices[group] = nextGroupIndex;
nextGroupIndex++;
}
} else if (trace.fill in LINKEDFILLS && prevUnstackedGroupIndex >= 0) {
groupIndex = prevUnstackedGroupIndex;
} else {
groupIndex = prevUnstackedGroupIndex = nextGroupIndex;
nextGroupIndex++;
}
if (groupIndex < prevGroupIndex) needsSort = true;
trace._groupIndex = prevGroupIndex = groupIndex;
}
var cdscatterSorted = cdscatter.slice();
if (needsSort) {
cdscatterSorted.sort(function (a, b) {
var traceA = a[0].trace;
var traceB = b[0].trace;
return traceA._groupIndex - traceB._groupIndex || traceA.index - traceB.index;
});
}
// now link traces to each other
var prevtraces = {};
for (i = 0; i < cdscatterSorted.length; i++) {
trace = cdscatterSorted[i][0].trace;
group = trace.stackgroup || '';
// Note: The check which ensures all cdscatter here are for the same axis and
// are either cartesian or scatterternary has been removed. This code assumes
// the passed scattertraces have been filtered to the proper plot types and
// the proper subplots.
if (trace.visible === true) {
trace._nexttrace = null;
if (trace.fill in LINKEDFILLS) {
prevtrace = prevtraces[group];
trace._prevtrace = prevtrace || null;
if (prevtrace) {
prevtrace._nexttrace = trace;
}
}
trace._ownfill = trace.fill && (trace.fill.substr(0, 6) === 'tozero' || trace.fill === 'toself' || trace.fill.substr(0, 2) === 'to' && !trace._prevtrace);
prevtraces[group] = trace;
} else {
trace._prevtrace = trace._nexttrace = trace._ownfill = null;
}
}
return cdscatterSorted;
};
/***/ }),
/***/ 7152:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
// used in the drawing step for 'scatter' and 'scattegeo' and
// in the convert step for 'scatter3d'
module.exports = function makeBubbleSizeFn(trace, factor) {
if (!factor) {
factor = 2;
}
var marker = trace.marker;
var sizeRef = marker.sizeref || 1;
var sizeMin = marker.sizemin || 0;
// for bubble charts, allow scaling the provided value linearly
// and by area or diameter.
// Note this only applies to the array-value sizes
var baseFn = marker.sizemode === 'area' ? function (v) {
return Math.sqrt(v / sizeRef);
} : function (v) {
return v / sizeRef;
};
// TODO add support for position/negative bubbles?
// TODO add 'sizeoffset' attribute?
return function (v) {
var baseSize = baseFn(v / factor);
// don't show non-numeric and negative sizes
return isNumeric(baseSize) && baseSize > 0 ? Math.max(baseSize, sizeMin) : 0;
};
};
/***/ }),
/***/ 5528:
/***/ (function(module) {
"use strict";
module.exports = {
container: 'marker',
min: 'cmin',
max: 'cmax'
};
/***/ }),
/***/ 74428:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Color = __webpack_require__(76308);
var hasColorscale = (__webpack_require__(94288).hasColorscale);
var colorscaleDefaults = __webpack_require__(27260);
var subTypes = __webpack_require__(43028);
/*
* opts: object of flags to control features not all marker users support
* noLine: caller does not support marker lines
* gradient: caller supports gradients
* noSelect: caller does not support selected/unselected attribute containers
*/
module.exports = function markerDefaults(traceIn, traceOut, defaultColor, layout, coerce, opts) {
var isBubble = subTypes.isBubble(traceIn);
var lineColor = (traceIn.line || {}).color;
var defaultMLC;
opts = opts || {};
// marker.color inherit from line.color (even if line.color is an array)
if (lineColor) defaultColor = lineColor;
coerce('marker.symbol');
coerce('marker.opacity', isBubble ? 0.7 : 1);
coerce('marker.size');
if (!opts.noAngle) {
coerce('marker.angle');
if (!opts.noAngleRef) {
coerce('marker.angleref');
}
if (!opts.noStandOff) {
coerce('marker.standoff');
}
}
coerce('marker.color', defaultColor);
if (hasColorscale(traceIn, 'marker')) {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {
prefix: 'marker.',
cLetter: 'c'
});
}
if (!opts.noSelect) {
coerce('selected.marker.color');
coerce('unselected.marker.color');
coerce('selected.marker.size');
coerce('unselected.marker.size');
}
if (!opts.noLine) {
// if there's a line with a different color than the marker, use
// that line color as the default marker line color
// (except when it's an array)
// mostly this is for transparent markers to behave nicely
if (lineColor && !Array.isArray(lineColor) && traceOut.marker.color !== lineColor) {
defaultMLC = lineColor;
} else if (isBubble) defaultMLC = Color.background;else defaultMLC = Color.defaultLine;
coerce('marker.line.color', defaultMLC);
if (hasColorscale(traceIn, 'marker.line')) {
colorscaleDefaults(traceIn, traceOut, layout, coerce, {
prefix: 'marker.line.',
cLetter: 'c'
});
}
coerce('marker.line.width', isBubble ? 1 : 0);
}
if (isBubble) {
coerce('marker.sizeref');
coerce('marker.sizemin');
coerce('marker.sizemode');
}
if (opts.gradient) {
var gradientType = coerce('marker.gradient.type');
if (gradientType !== 'none') {
coerce('marker.gradient.color');
}
}
};
/***/ }),
/***/ 31147:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var dateTick0 = (__webpack_require__(3400).dateTick0);
var numConstants = __webpack_require__(39032);
var ONEWEEK = numConstants.ONEWEEK;
function getPeriod0Dflt(period, calendar) {
if (period % ONEWEEK === 0) {
return dateTick0(calendar, 1); // Sunday
}
return dateTick0(calendar, 0);
}
module.exports = function handlePeriodDefaults(traceIn, traceOut, layout, coerce, opts) {
if (!opts) {
opts = {
x: true,
y: true
};
}
if (opts.x) {
var xperiod = coerce('xperiod');
if (xperiod) {
coerce('xperiod0', getPeriod0Dflt(xperiod, traceOut.xcalendar));
coerce('xperiodalignment');
}
}
if (opts.y) {
var yperiod = coerce('yperiod');
if (yperiod) {
coerce('yperiod0', getPeriod0Dflt(yperiod, traceOut.ycalendar));
coerce('yperiodalignment');
}
}
};
/***/ }),
/***/ 96504:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var d3 = __webpack_require__(33428);
var Registry = __webpack_require__(24040);
var Lib = __webpack_require__(3400);
var ensureSingle = Lib.ensureSingle;
var identity = Lib.identity;
var Drawing = __webpack_require__(43616);
var subTypes = __webpack_require__(43028);
var linePoints = __webpack_require__(52340);
var linkTraces = __webpack_require__(14328);
var polygonTester = (__webpack_require__(92065).tester);
module.exports = function plot(gd, plotinfo, cdscatter, scatterLayer, transitionOpts, makeOnCompleteCallback) {
var join, onComplete;
// If transition config is provided, then it is only a partial replot and traces not
// updated are removed.
var isFullReplot = !transitionOpts;
var hasTransition = !!transitionOpts && transitionOpts.duration > 0;
// Link traces so the z-order of fill layers is correct
var cdscatterSorted = linkTraces(gd, plotinfo, cdscatter);
join = scatterLayer.selectAll('g.trace').data(cdscatterSorted, function (d) {
return d[0].trace.uid;
});
// Append new traces:
join.enter().append('g').attr('class', function (d) {
return 'trace scatter trace' + d[0].trace.uid;
}).style('stroke-miterlimit', 2);
join.order();
createFills(gd, join, plotinfo);
if (hasTransition) {
if (makeOnCompleteCallback) {
// If it was passed a callback to register completion, make a callback. If
// this is created, then it must be executed on completion, otherwise the
// pos-transition redraw will not execute:
onComplete = makeOnCompleteCallback();
}
var transition = d3.transition().duration(transitionOpts.duration).ease(transitionOpts.easing).each('end', function () {
onComplete && onComplete();
}).each('interrupt', function () {
onComplete && onComplete();
});
transition.each(function () {
// Must run the selection again since otherwise enters/updates get grouped together
// and these get executed out of order. Except we need them in order!
scatterLayer.selectAll('g.trace').each(function (d, i) {
plotOne(gd, i, plotinfo, d, cdscatterSorted, this, transitionOpts);
});
});
} else {
join.each(function (d, i) {
plotOne(gd, i, plotinfo, d, cdscatterSorted, this, transitionOpts);
});
}
if (isFullReplot) {
join.exit().remove();
}
// remove paths that didn't get used
scatterLayer.selectAll('path:not([d])').remove();
};
function createFills(gd, traceJoin, plotinfo) {
traceJoin.each(function (d) {
var fills = ensureSingle(d3.select(this), 'g', 'fills');
Drawing.setClipUrl(fills, plotinfo.layerClipId, gd);
var trace = d[0].trace;
var fillData = [];
if (trace._ownfill) fillData.push('_ownFill');
if (trace._nexttrace) fillData.push('_nextFill');
var fillJoin = fills.selectAll('g').data(fillData, identity);
fillJoin.enter().append('g');
fillJoin.exit().each(function (d) {
trace[d] = null;
}).remove();
fillJoin.order().each(function (d) {
// make a path element inside the fill group, just so
// we can give it its own data later on and the group can
// keep its simple '_*Fill' data
trace[d] = ensureSingle(d3.select(this), 'path', 'js-fill');
});
});
}
function plotOne(gd, idx, plotinfo, cdscatter, cdscatterAll, element, transitionOpts) {
var isStatic = gd._context.staticPlot;
var i;
// Since this has been reorganized and we're executing this on individual traces,
// we need to pass it the full list of cdscatter as well as this trace's index (idx)
// since it does an internal n^2 loop over comparisons with other traces:
selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll);
var hasTransition = !!transitionOpts && transitionOpts.duration > 0;
function transition(selection) {
return hasTransition ? selection.transition() : selection;
}
var xa = plotinfo.xaxis;
var ya = plotinfo.yaxis;
var trace = cdscatter[0].trace;
var line = trace.line;
var tr = d3.select(element);
var errorBarGroup = ensureSingle(tr, 'g', 'errorbars');
var lines = ensureSingle(tr, 'g', 'lines');
var points = ensureSingle(tr, 'g', 'points');
var text = ensureSingle(tr, 'g', 'text');
// error bars are at the bottom
Registry.getComponentMethod('errorbars', 'plot')(gd, errorBarGroup, plotinfo, transitionOpts);
if (trace.visible !== true) return;
transition(tr).style('opacity', trace.opacity);
// BUILD LINES AND FILLS
var ownFillEl3, tonext;
var ownFillDir = trace.fill.charAt(trace.fill.length - 1);
if (ownFillDir !== 'x' && ownFillDir !== 'y') ownFillDir = '';
var fillAxisIndex, fillAxisZero;
if (ownFillDir === 'y') {
fillAxisIndex = 1;
fillAxisZero = ya.c2p(0, true);
} else if (ownFillDir === 'x') {
fillAxisIndex = 0;
fillAxisZero = xa.c2p(0, true);
}
// store node for tweaking by selectPoints
cdscatter[0][plotinfo.isRangePlot ? 'nodeRangePlot3' : 'node3'] = tr;
var prevRevpath = '';
var prevPolygons = [];
var prevtrace = trace._prevtrace;
var prevFillsegments = null;
var prevFillElement = null;
if (prevtrace) {
prevRevpath = prevtrace._prevRevpath || '';
tonext = prevtrace._nextFill;
prevPolygons = prevtrace._ownPolygons;
prevFillsegments = prevtrace._fillsegments;
prevFillElement = prevtrace._fillElement;
}
var thispath;
var thisrevpath;
// fullpath is all paths for this curve, joined together straight
// across gaps, for filling
var fullpath = '';
// revpath is fullpath reversed, for fill-to-next
var revpath = '';
// functions for converting a point array to a path
var pathfn, revpathbase, revpathfn;
// variables used before and after the data join
var pt0, lastSegment, pt1;
// thisPolygons always contains only the polygons of this trace only
// whereas trace._polygons may be extended to include those of the previous
// trace as well for exclusion during hover detection
var thisPolygons = [];
trace._polygons = [];
var fillsegments = [];
// initialize line join data / method
var segments = [];
var makeUpdate = Lib.noop;
ownFillEl3 = trace._ownFill;
if (subTypes.hasLines(trace) || trace.fill !== 'none') {
if (tonext) {
// This tells .style which trace to use for fill information:
tonext.datum(cdscatter);
}
if (['hv', 'vh', 'hvh', 'vhv'].indexOf(line.shape) !== -1) {
pathfn = Drawing.steps(line.shape);
revpathbase = Drawing.steps(line.shape.split('').reverse().join(''));
} else if (line.shape === 'spline') {
pathfn = revpathbase = function (pts) {
var pLast = pts[pts.length - 1];
if (pts.length > 1 && pts[0][0] === pLast[0] && pts[0][1] === pLast[1]) {
// identical start and end points: treat it as a
// closed curve so we don't get a kink
return Drawing.smoothclosed(pts.slice(1), line.smoothing);
} else {
return Drawing.smoothopen(pts, line.smoothing);
}
};
} else {
pathfn = revpathbase = function (pts) {
return 'M' + pts.join('L');
};
}
revpathfn = function (pts) {
// note: this is destructive (reverses pts in place) so can't use pts after this
return revpathbase(pts.reverse());
};
segments = linePoints(cdscatter, {
xaxis: xa,
yaxis: ya,
trace: trace,
connectGaps: trace.connectgaps,
baseTolerance: Math.max(line.width || 1, 3) / 4,
shape: line.shape,
backoff: line.backoff,
simplify: line.simplify,
fill: trace.fill
});
// since we already have the pixel segments here, use them to make
// polygons for hover on fill; we first merge segments where the fill
// is connected into "fillsegments"; the actual polygon construction
// is deferred to later to distinguish between self and tonext/tozero fills.
// TODO: can we skip this if hoveron!=fills? That would mean we
// need to redraw when you change hoveron...
fillsegments = new Array(segments.length);
var fillsegmentCount = 0;
for (i = 0; i < segments.length; i++) {
var curpoints;
var pts = segments[i];
if (!curpoints || !ownFillDir) {
curpoints = pts.slice();
fillsegments[fillsegmentCount] = curpoints;
fillsegmentCount++;
} else {
curpoints.push.apply(curpoints, pts);
}
}
trace._fillElement = null;
trace._fillExclusionElement = prevFillElement;
trace._fillsegments = fillsegments.slice(0, fillsegmentCount);
fillsegments = trace._fillsegments;
if (segments.length) {
pt0 = segments[0][0].slice();
lastSegment = segments[segments.length - 1];
pt1 = lastSegment[lastSegment.length - 1].slice();
}
makeUpdate = function (isEnter) {
return function (pts) {
thispath = pathfn(pts);
thisrevpath = revpathfn(pts); // side-effect: reverses input
// calculate SVG path over all segments for fills
if (!fullpath) {
fullpath = thispath;
revpath = thisrevpath;
} else if (ownFillDir) {
// for fills with fill direction: ignore gaps
fullpath += 'L' + thispath.substr(1);
revpath = thisrevpath + ('L' + revpath.substr(1));
} else {
fullpath += 'Z' + thispath;
revpath = thisrevpath + 'Z' + revpath;
}
// actual lines get drawn here, with gaps between segments if requested
if (subTypes.hasLines(trace)) {
var el = d3.select(this);
// This makes the coloring work correctly:
el.datum(cdscatter);
if (isEnter) {
transition(el.style('opacity', 0).attr('d', thispath).call(Drawing.lineGroupStyle)).style('opacity', 1);
} else {
var sel = transition(el);
sel.attr('d', thispath);
Drawing.singleLineStyle(cdscatter, sel);
}
}
};
};
}
var lineJoin = lines.selectAll('.js-line').data(segments);
transition(lineJoin.exit()).style('opacity', 0).remove();
lineJoin.each(makeUpdate(false));
lineJoin.enter().append('path').classed('js-line', true).style('vector-effect', isStatic ? 'none' : 'non-scaling-stroke').call(Drawing.lineGroupStyle).each(makeUpdate(true));
Drawing.setClipUrl(lineJoin, plotinfo.layerClipId, gd);
function clearFill(selection) {
transition(selection).attr('d', 'M0,0Z');
}
// helper functions to create polygons for hoveron fill detection
var makeSelfPolygons = function () {
var polygons = new Array(fillsegments.length);
for (i = 0; i < fillsegments.length; i++) {
polygons[i] = polygonTester(fillsegments[i]);
}
return polygons;
};
var makePolygonsToPrevious = function (prevFillsegments) {
var polygons, i;
if (!prevFillsegments || prevFillsegments.length === 0) {
// if there are no fill segments of a previous trace, stretch the
// polygon to the relevant axis
polygons = new Array(fillsegments.length);
for (i = 0; i < fillsegments.length; i++) {
var pt0 = fillsegments[i][0].slice();
var pt1 = fillsegments[i][fillsegments[i].length - 1].slice();
pt0[fillAxisIndex] = pt1[fillAxisIndex] = fillAxisZero;
var zeropoints = [pt1, pt0];
var polypoints = zeropoints.concat(fillsegments[i]);
polygons[i] = polygonTester(polypoints);
}
} else {
// if there are more than one previous fill segment, the
// way that fills work is to "self" fill all but the last segments
// of the previous and then fill from the new trace to the last
// segment of the previous.
polygons = new Array(prevFillsegments.length - 1 + fillsegments.length);
for (i = 0; i < prevFillsegments.length - 1; i++) {
polygons[i] = polygonTester(prevFillsegments[i]);
}
var reversedPrevFillsegment = prevFillsegments[prevFillsegments.length - 1].slice();
reversedPrevFillsegment.reverse();
for (i = 0; i < fillsegments.length; i++) {
polygons[prevFillsegments.length - 1 + i] = polygonTester(fillsegments[i].concat(reversedPrevFillsegment));
}
}
return polygons;
};
// draw fills and create hover detection polygons
if (segments.length) {
if (ownFillEl3) {
ownFillEl3.datum(cdscatter);
if (pt0 && pt1) {
// TODO(2023-12-10): this is always true if segments is not empty (?)
if (ownFillDir) {
pt0[fillAxisIndex] = pt1[fillAxisIndex] = fillAxisZero;
// fill to zero: full trace path, plus extension of
// the endpoints to the appropriate axis
// For the sake of animations, wrap the points around so that
// the points on the axes are the first two points. Otherwise
// animations get a little crazy if the number of points changes.
transition(ownFillEl3).attr('d', 'M' + pt1 + 'L' + pt0 + 'L' + fullpath.substr(1)).call(Drawing.singleFillStyle, gd);
// create hover polygons that extend to the axis as well.
thisPolygons = makePolygonsToPrevious(null); // polygon to axis
} else {
// fill to self: just join the path to itself
transition(ownFillEl3).attr('d', fullpath + 'Z').call(Drawing.singleFillStyle, gd);
// and simply emit hover polygons for each segment
thisPolygons = makeSelfPolygons();
}
}
trace._polygons = thisPolygons;
trace._fillElement = ownFillEl3;
} else if (tonext) {
if (trace.fill.substr(0, 6) === 'tonext' && fullpath && prevRevpath) {
// fill to next: full trace path, plus the previous path reversed
if (trace.fill === 'tonext') {
// tonext: for use by concentric shapes, like manually constructed
// contours, we just add the two paths closed on themselves.
// This makes strange results if one path is *not* entirely
// inside the other, but then that is a strange usage.
transition(tonext).attr('d', fullpath + 'Z' + prevRevpath + 'Z').call(Drawing.singleFillStyle, gd);
// and simply emit hover polygons for each segment
thisPolygons = makeSelfPolygons();
// we add the polygons of the previous trace which causes hover
// detection to ignore points contained in them.
trace._polygons = thisPolygons.concat(prevPolygons); // this does not modify thisPolygons, on purpose
} else {
// tonextx/y: for now just connect endpoints with lines. This is
// the correct behavior if the endpoints are at the same value of
// y/x, but if they *aren't*, we should ideally do more complicated
// things depending on whether the new endpoint projects onto the
// existing curve or off the end of it
transition(tonext).attr('d', fullpath + 'L' + prevRevpath.substr(1) + 'Z').call(Drawing.singleFillStyle, gd);
// create hover polygons that extend to the previous trace.
thisPolygons = makePolygonsToPrevious(prevFillsegments);
// in this case our polygons do not cover that of previous traces,
// so must not include previous trace polygons for hover detection.
trace._polygons = thisPolygons;
}
trace._fillElement = tonext;
} else {
clearFill(tonext);
}
}
trace._prevRevpath = revpath;
} else {
if (ownFillEl3) clearFill(ownFillEl3);else if (tonext) clearFill(tonext);
trace._prevRevpath = null;
}
trace._ownPolygons = thisPolygons;
function visFilter(d) {
return d.filter(function (v) {
return !v.gap && v.vis;
});
}
function visFilterWithGaps(d) {
return d.filter(function (v) {
return v.vis;
});
}
function gapFilter(d) {
return d.filter(function (v) {
return !v.gap;
});
}
function keyFunc(d) {
return d.id;
}
// Returns a function if the trace is keyed, otherwise returns undefined
function getKeyFunc(trace) {
if (trace.ids) {
return keyFunc;
}
}
function hideFilter() {
return false;
}
function makePoints(points, text, cdscatter) {
var join, selection, hasNode;
var trace = cdscatter[0].trace;
var showMarkers = subTypes.hasMarkers(trace);
var showText = subTypes.hasText(trace);
var keyFunc = getKeyFunc(trace);
var markerFilter = hideFilter;
var textFilter = hideFilter;
if (showMarkers || showText) {
var showFilter = identity;
// if we're stacking, "infer zero" gap mode gets markers in the
// gap points - because we've inferred a zero there - but other
// modes (currently "interpolate", later "interrupt" hopefully)
// we don't draw generated markers
var stackGroup = trace.stackgroup;
var isInferZero = stackGroup && gd._fullLayout._scatterStackOpts[xa._id + ya._id][stackGroup].stackgaps === 'infer zero';
if (trace.marker.maxdisplayed || trace._needsCull) {
showFilter = isInferZero ? visFilterWithGaps : visFilter;
} else if (stackGroup && !isInferZero) {
showFilter = gapFilter;
}
if (showMarkers) markerFilter = showFilter;
if (showText) textFilter = showFilter;
}
// marker points
selection = points.selectAll('path.point');
join = selection.data(markerFilter, keyFunc);
var enter = join.enter().append('path').classed('point', true);
if (hasTransition) {
enter.call(Drawing.pointStyle, trace, gd).call(Drawing.translatePoints, xa, ya).style('opacity', 0).transition().style('opacity', 1);
}
join.order();
var styleFns;
if (showMarkers) {
styleFns = Drawing.makePointStyleFns(trace);
}
join.each(function (d) {
var el = d3.select(this);
var sel = transition(el);
hasNode = Drawing.translatePoint(d, sel, xa, ya);
if (hasNode) {
Drawing.singlePointStyle(d, sel, trace, styleFns, gd);
if (plotinfo.layerClipId) {
Drawing.hideOutsideRangePoint(d, sel, xa, ya, trace.xcalendar, trace.ycalendar);
}
if (trace.customdata) {
el.classed('plotly-customdata', d.data !== null && d.data !== undefined);
}
} else {
sel.remove();
}
});
if (hasTransition) {
join.exit().transition().style('opacity', 0).remove();
} else {
join.exit().remove();
}
// text points
selection = text.selectAll('g');
join = selection.data(textFilter, keyFunc);
// each text needs to go in its own 'g' in case
// it gets converted to mathjax
join.enter().append('g').classed('textpoint', true).append('text');
join.order();
join.each(function (d) {
var g = d3.select(this);
var sel = transition(g.select('text'));
hasNode = Drawing.translatePoint(d, sel, xa, ya);
if (hasNode) {
if (plotinfo.layerClipId) {
Drawing.hideOutsideRangePoint(d, g, xa, ya, trace.xcalendar, trace.ycalendar);
}
} else {
g.remove();
}
});
join.selectAll('text').call(Drawing.textPointStyle, trace, gd).each(function (d) {
// This just *has* to be totally custom because of SVG text positioning :(
// It's obviously copied from translatePoint; we just can't use that
var x = xa.c2p(d.x);
var y = ya.c2p(d.y);
d3.select(this).selectAll('tspan.line').each(function () {
transition(d3.select(this)).attr({
x: x,
y: y
});
});
});
join.exit().remove();
}
points.datum(cdscatter);
text.datum(cdscatter);
makePoints(points, text, cdscatter);
// lastly, clip points groups of `cliponaxis !== false` traces
// on `plotinfo._hasClipOnAxisFalse === true` subplots
var hasClipOnAxisFalse = trace.cliponaxis === false;
var clipUrl = hasClipOnAxisFalse ? null : plotinfo.layerClipId;
Drawing.setClipUrl(points, clipUrl, gd);
Drawing.setClipUrl(text, clipUrl, gd);
}
function selectMarkers(gd, idx, plotinfo, cdscatter, cdscatterAll) {
var xa = plotinfo.xaxis;
var ya = plotinfo.yaxis;
var xr = d3.extent(Lib.simpleMap(xa.range, xa.r2c));
var yr = d3.extent(Lib.simpleMap(ya.range, ya.r2c));
var trace = cdscatter[0].trace;
if (!subTypes.hasMarkers(trace)) return;
// if marker.maxdisplayed is used, select a maximum of
// mnum markers to show, from the set that are in the viewport
var mnum = trace.marker.maxdisplayed;
// TODO: remove some as we get away from the viewport?
if (mnum === 0) return;
var cd = cdscatter.filter(function (v) {
return v.x >= xr[0] && v.x <= xr[1] && v.y >= yr[0] && v.y <= yr[1];
});
var inc = Math.ceil(cd.length / mnum);
var tnum = 0;
cdscatterAll.forEach(function (cdj, j) {
var tracei = cdj[0].trace;
if (subTypes.hasMarkers(tracei) && tracei.marker.maxdisplayed > 0 && j < idx) {
tnum++;
}
});
// if multiple traces use maxdisplayed, stagger which markers we
// display this formula offsets successive traces by 1/3 of the
// increment, adding an extra small amount after each triplet so
// it's not quite periodic
var i0 = Math.round(tnum * inc / 3 + Math.floor(tnum / 3) * inc / 7.1);
// for error bars: save in cd which markers to show
// so we don't have to repeat this
cdscatter.forEach(function (v) {
delete v.vis;
});
cd.forEach(function (v, i) {
if (Math.round((i + i0) % inc) === 0) v.vis = true;
});
}
/***/ }),
/***/ 91560:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var subtypes = __webpack_require__(43028);
module.exports = function selectPoints(searchInfo, selectionTester) {
var cd = searchInfo.cd;
var xa = searchInfo.xaxis;
var ya = searchInfo.yaxis;
var selection = [];
var trace = cd[0].trace;
var i;
var di;
var x;
var y;
var hasOnlyLines = !subtypes.hasMarkers(trace) && !subtypes.hasText(trace);
if (hasOnlyLines) return [];
if (selectionTester === false) {
// clear selection
for (i = 0; i < cd.length; i++) {
cd[i].selected = 0;
}
} else {
for (i = 0; i < cd.length; i++) {
di = cd[i];
x = xa.c2p(di.x);
y = ya.c2p(di.y);
if (di.i !== null && selectionTester.contains([x, y], false, i, searchInfo)) {
selection.push({
pointNumber: di.i,
x: xa.c2d(di.x),
y: ya.c2d(di.y)
});
di.selected = 1;
} else {
di.selected = 0;
}
}
}
return selection;
};
/***/ }),
/***/ 43912:
/***/ (function(module) {
"use strict";
var perStackAttrs = ['orientation', 'groupnorm', 'stackgaps'];
module.exports = function handleStackDefaults(traceIn, traceOut, layout, coerce) {
var stackOpts = layout._scatterStackOpts;
var stackGroup = coerce('stackgroup');
if (stackGroup) {
// use independent stacking options per subplot
var subplot = traceOut.xaxis + traceOut.yaxis;
var subplotStackOpts = stackOpts[subplot];
if (!subplotStackOpts) subplotStackOpts = stackOpts[subplot] = {};
var groupOpts = subplotStackOpts[stackGroup];
var firstTrace = false;
if (groupOpts) {
groupOpts.traces.push(traceOut);
} else {
groupOpts = subplotStackOpts[stackGroup] = {
// keep track of trace indices for use during stacking calculations
// this will be filled in during `calc` and used during `crossTraceCalc`
// so it's OK if we don't recreate it during a non-calc edit
traceIndices: [],
// Hold on to the whole set of prior traces
// First one is most important, so we can clear defaults
// there if we find explicit values only in later traces.
// We're only going to *use* the values stored in groupOpts,
// but for the editor and validate we want things self-consistent
// The full set of traces is used only to fix `fill` default if
// we find `orientation: 'h'` beyond the first trace
traces: [traceOut]
};
firstTrace = true;
}
// TODO: how is this going to work with groupby transforms?
// in principle it should be OK I guess, as long as explicit group styles
// don't override explicit base-trace styles?
var dflts = {
orientation: traceOut.x && !traceOut.y ? 'h' : 'v'
};
for (var i = 0; i < perStackAttrs.length; i++) {
var attr = perStackAttrs[i];
var attrFound = attr + 'Found';
if (!groupOpts[attrFound]) {
var traceHasAttr = traceIn[attr] !== undefined;
var isOrientation = attr === 'orientation';
if (traceHasAttr || firstTrace) {
groupOpts[attr] = coerce(attr, dflts[attr]);
if (isOrientation) {
groupOpts.fillDflt = groupOpts[attr] === 'h' ? 'tonextx' : 'tonexty';
}
if (traceHasAttr) {
// Note: this will show a value here even if it's invalid
// in which case it will revert to default.
groupOpts[attrFound] = true;
// Note: only one trace in the stack will get a _fullData
// entry for a given stack-wide attribute. If no traces
// (or the first trace) specify that attribute, the
// first trace will get it. If the first trace does NOT
// specify it but some later trace does, then it gets
// removed from the first trace and only included in the
// one that specified it. This is mostly important for
// editors (that want to see the full values to know
// what settings are available) and Plotly.react diffing.
// Editors may want to use fullLayout._scatterStackOpts
// directly and make these settings available from all
// traces in the stack... then set the new value into
// the first trace, and clear all later traces.
if (!firstTrace) {
delete groupOpts.traces[0][attr];
// orientation can affect default fill of previous traces
if (isOrientation) {
for (var j = 0; j < groupOpts.traces.length - 1; j++) {
var trace2 = groupOpts.traces[j];
if (trace2._input.fill !== trace2.fill) {
trace2.fill = groupOpts.fillDflt;
}
}
}
}
}
}
}
}
return groupOpts;
}
};
/***/ }),
/***/ 49224:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var d3 = __webpack_require__(33428);
var Drawing = __webpack_require__(43616);
var Registry = __webpack_require__(24040);
function style(gd) {
var s = d3.select(gd).selectAll('g.trace.scatter');
s.style('opacity', function (d) {
return d[0].trace.opacity;
});
s.selectAll('g.points').each(function (d) {
var sel = d3.select(this);
var trace = d.trace || d[0].trace;
stylePoints(sel, trace, gd);
});
s.selectAll('g.text').each(function (d) {
var sel = d3.select(this);
var trace = d.trace || d[0].trace;
styleText(sel, trace, gd);
});
s.selectAll('g.trace path.js-line').call(Drawing.lineGroupStyle);
s.selectAll('g.trace path.js-fill').call(Drawing.fillGroupStyle, gd, false);
Registry.getComponentMethod('errorbars', 'style')(s);
}
function stylePoints(sel, trace, gd) {
Drawing.pointStyle(sel.selectAll('path.point'), trace, gd);
}
function styleText(sel, trace, gd) {
Drawing.textPointStyle(sel.selectAll('text'), trace, gd);
}
function styleOnSelect(gd, cd, sel) {
var trace = cd[0].trace;
if (trace.selectedpoints) {
Drawing.selectedPointStyle(sel.selectAll('path.point'), trace);
Drawing.selectedTextStyle(sel.selectAll('text'), trace);
} else {
stylePoints(sel, trace, gd);
styleText(sel, trace, gd);
}
}
module.exports = {
style: style,
stylePoints: stylePoints,
styleText: styleText,
styleOnSelect: styleOnSelect
};
/***/ }),
/***/ 43028:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var isTypedArraySpec = (__webpack_require__(38116).isTypedArraySpec);
module.exports = {
hasLines: function (trace) {
return trace.visible && trace.mode && trace.mode.indexOf('lines') !== -1;
},
hasMarkers: function (trace) {
return trace.visible && (trace.mode && trace.mode.indexOf('markers') !== -1 ||
// until splom implements 'mode'
trace.type === 'splom');
},
hasText: function (trace) {
return trace.visible && trace.mode && trace.mode.indexOf('text') !== -1;
},
isBubble: function (trace) {
var marker = trace.marker;
return Lib.isPlainObject(marker) && (Lib.isArrayOrTypedArray(marker.size) || isTypedArraySpec(marker.size));
}
};
/***/ }),
/***/ 124:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
/*
* opts: object of flags to control features not all text users support
* noSelect: caller does not support selected/unselected attribute containers
*/
module.exports = function (traceIn, traceOut, layout, coerce, opts) {
opts = opts || {};
coerce('textposition');
Lib.coerceFont(coerce, 'textfont', opts.font || layout.font);
if (!opts.noSelect) {
coerce('selected.textfont.color');
coerce('unselected.textfont.color');
}
};
/***/ }),
/***/ 43980:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Registry = __webpack_require__(24040);
module.exports = function handleXYDefaults(traceIn, traceOut, layout, coerce) {
var x = coerce('x');
var y = coerce('y');
var len;
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleTraceDefaults');
handleCalendarDefaults(traceIn, traceOut, ['x', 'y'], layout);
if (x) {
var xlen = Lib.minRowLength(x);
if (y) {
len = Math.min(xlen, Lib.minRowLength(y));
} else {
len = xlen;
coerce('y0');
coerce('dy');
}
} else {
if (!y) return 0;
len = Lib.minRowLength(y);
coerce('x0');
coerce('dx');
}
traceOut._length = len;
return len;
};
/***/ }),
/***/ 41484:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var arraysToCalcdata = __webpack_require__(20148);
var calcColorscale = __webpack_require__(90136);
/**
* This is a kludge to put the array attributes into
* calcdata the way Scatter.plot does, so that legends and
* popovers know what to do with them.
*/
module.exports = function calc(gd, trace) {
var cd = [{
x: false,
y: false,
trace: trace,
t: {}
}];
arraysToCalcdata(cd, trace);
calcColorscale(gd, trace);
return cd;
};
/***/ }),
/***/ 2876:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var baseAttrs = __webpack_require__(45464);
var makeFillcolorAttr = __webpack_require__(98304);
var scatterAttrs = __webpack_require__(52904);
var axisHoverFormat = (__webpack_require__(29736).axisHoverFormat);
var colorScaleAttrs = __webpack_require__(49084);
var sortObjectKeys = __webpack_require__(95376);
var extendFlat = (__webpack_require__(92880).extendFlat);
var overrideAll = (__webpack_require__(67824).overrideAll);
var DASHES = (__webpack_require__(67072).DASHES);
var scatterLineAttrs = scatterAttrs.line;
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
var attrs = module.exports = overrideAll({
x: scatterAttrs.x,
x0: scatterAttrs.x0,
dx: scatterAttrs.dx,
y: scatterAttrs.y,
y0: scatterAttrs.y0,
dy: scatterAttrs.dy,
xperiod: scatterAttrs.xperiod,
yperiod: scatterAttrs.yperiod,
xperiod0: scatterAttrs.xperiod0,
yperiod0: scatterAttrs.yperiod0,
xperiodalignment: scatterAttrs.xperiodalignment,
yperiodalignment: scatterAttrs.yperiodalignment,
xhoverformat: axisHoverFormat('x'),
yhoverformat: axisHoverFormat('y'),
text: scatterAttrs.text,
hovertext: scatterAttrs.hovertext,
textposition: scatterAttrs.textposition,
textfont: scatterAttrs.textfont,
mode: {
valType: 'flaglist',
flags: ['lines', 'markers', 'text'],
extras: ['none']
},
line: {
color: scatterLineAttrs.color,
width: scatterLineAttrs.width,
shape: {
valType: 'enumerated',
values: ['linear', 'hv', 'vh', 'hvh', 'vhv'],
dflt: 'linear',
editType: 'plot'
},
dash: {
valType: 'enumerated',
values: sortObjectKeys(DASHES),
dflt: 'solid'
}
},
marker: extendFlat({}, colorScaleAttrs('marker'), {
symbol: scatterMarkerAttrs.symbol,
angle: scatterMarkerAttrs.angle,
size: scatterMarkerAttrs.size,
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
opacity: scatterMarkerAttrs.opacity,
colorbar: scatterMarkerAttrs.colorbar,
line: extendFlat({}, colorScaleAttrs('marker.line'), {
width: scatterMarkerLineAttrs.width
})
}),
connectgaps: scatterAttrs.connectgaps,
fill: extendFlat({}, scatterAttrs.fill, {
dflt: 'none'
}),
fillcolor: makeFillcolorAttr(),
// no hoveron
selected: {
marker: scatterAttrs.selected.marker,
textfont: scatterAttrs.selected.textfont
},
unselected: {
marker: scatterAttrs.unselected.marker,
textfont: scatterAttrs.unselected.textfont
},
opacity: baseAttrs.opacity
}, 'calc', 'nested');
attrs.x.editType = attrs.y.editType = attrs.x0.editType = attrs.y0.editType = 'calc+clearAxisTypes';
attrs.hovertemplate = scatterAttrs.hovertemplate;
attrs.texttemplate = scatterAttrs.texttemplate;
/***/ }),
/***/ 64628:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var hover = __webpack_require__(41272);
module.exports = {
moduleType: 'trace',
name: 'scattergl',
basePlotModule: __webpack_require__(57952),
categories: ['gl', 'regl', 'cartesian', 'symbols', 'errorBarsOK', 'showLegend', 'scatter-like'],
attributes: __webpack_require__(2876),
supplyDefaults: __webpack_require__(80220),
crossTraceDefaults: __webpack_require__(35036),
colorbar: __webpack_require__(5528),
formatLabels: __webpack_require__(99396),
calc: __webpack_require__(24856),
hoverPoints: hover.hoverPoints,
selectPoints: __webpack_require__(73224),
meta: {}
};
/***/ }),
/***/ 24856:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var cluster = __webpack_require__(3108);
var Lib = __webpack_require__(3400);
var AxisIDs = __webpack_require__(79811);
var findExtremes = (__webpack_require__(19280).findExtremes);
var alignPeriod = __webpack_require__(1220);
var scatterCalc = __webpack_require__(16356);
var calcMarkerSize = scatterCalc.calcMarkerSize;
var calcAxisExpansion = scatterCalc.calcAxisExpansion;
var setFirstScatter = scatterCalc.setFirstScatter;
var calcColorscale = __webpack_require__(90136);
var convert = __webpack_require__(6616);
var sceneUpdate = __webpack_require__(74588);
var BADNUM = (__webpack_require__(39032).BADNUM);
var TOO_MANY_POINTS = (__webpack_require__(67072).TOO_MANY_POINTS);
module.exports = function calc(gd, trace) {
var fullLayout = gd._fullLayout;
var xa = trace._xA = AxisIDs.getFromId(gd, trace.xaxis, 'x');
var ya = trace._yA = AxisIDs.getFromId(gd, trace.yaxis, 'y');
var subplot = fullLayout._plots[trace.xaxis + trace.yaxis];
var len = trace._length;
var hasTooManyPoints = len >= TOO_MANY_POINTS;
var len2 = len * 2;
var stash = {};
var i;
var origX = xa.makeCalcdata(trace, 'x');
var origY = ya.makeCalcdata(trace, 'y');
var xObj = alignPeriod(trace, xa, 'x', origX);
var yObj = alignPeriod(trace, ya, 'y', origY);
var x = xObj.vals;
var y = yObj.vals;
trace._x = x;
trace._y = y;
if (trace.xperiodalignment) {
trace._origX = origX;
trace._xStarts = xObj.starts;
trace._xEnds = xObj.ends;
}
if (trace.yperiodalignment) {
trace._origY = origY;
trace._yStarts = yObj.starts;
trace._yEnds = yObj.ends;
}
// we need hi-precision for scatter2d,
// regl-scatter2d uses NaNs for bad/missing values
var positions = new Array(len2);
var _ids = new Array(len);
for (i = 0; i < len; i++) {
positions[i * 2] = x[i] === BADNUM ? NaN : x[i];
positions[i * 2 + 1] = y[i] === BADNUM ? NaN : y[i];
// Pre-compute ids.
_ids[i] = i;
}
if (xa.type === 'log') {
for (i = 0; i < len2; i += 2) {
positions[i] = xa.c2l(positions[i]);
}
}
if (ya.type === 'log') {
for (i = 1; i < len2; i += 2) {
positions[i] = ya.c2l(positions[i]);
}
}
// we don't build a tree for log axes since it takes long to convert log2px
// and it is also
if (hasTooManyPoints && xa.type !== 'log' && ya.type !== 'log') {
// FIXME: delegate this to webworker
stash.tree = cluster(positions);
} else {
stash.ids = _ids;
}
// create scene options and scene
calcColorscale(gd, trace);
var opts = sceneOptions(gd, subplot, trace, positions, x, y);
var scene = sceneUpdate(gd, subplot);
// Reuse SVG scatter axis expansion routine.
// For graphs with very large number of points and array marker.size,
// use average marker size instead to speed things up.
setFirstScatter(fullLayout, trace);
var ppad;
if (!hasTooManyPoints) {
ppad = calcMarkerSize(trace, len);
} else if (opts.marker) {
ppad = opts.marker.sizeAvg || Math.max(opts.marker.size, 3);
}
calcAxisExpansion(gd, trace, xa, ya, x, y, ppad);
if (opts.errorX) expandForErrorBars(trace, xa, opts.errorX);
if (opts.errorY) expandForErrorBars(trace, ya, opts.errorY);
// set flags to create scene renderers
if (opts.fill && !scene.fill2d) scene.fill2d = true;
if (opts.marker && !scene.scatter2d) scene.scatter2d = true;
if (opts.line && !scene.line2d) scene.line2d = true;
if ((opts.errorX || opts.errorY) && !scene.error2d) scene.error2d = true;
if (opts.text && !scene.glText) scene.glText = true;
if (opts.marker) opts.marker.snap = len;
scene.lineOptions.push(opts.line);
scene.errorXOptions.push(opts.errorX);
scene.errorYOptions.push(opts.errorY);
scene.fillOptions.push(opts.fill);
scene.markerOptions.push(opts.marker);
scene.markerSelectedOptions.push(opts.markerSel);
scene.markerUnselectedOptions.push(opts.markerUnsel);
scene.textOptions.push(opts.text);
scene.textSelectedOptions.push(opts.textSel);
scene.textUnselectedOptions.push(opts.textUnsel);
scene.selectBatch.push([]);
scene.unselectBatch.push([]);
stash._scene = scene;
stash.index = scene.count;
stash.x = x;
stash.y = y;
stash.positions = positions;
scene.count++;
return [{
x: false,
y: false,
t: stash,
trace: trace
}];
};
function expandForErrorBars(trace, ax, opts) {
var extremes = trace._extremes[ax._id];
var errExt = findExtremes(ax, opts._bnds, {
padded: true
});
extremes.min = extremes.min.concat(errExt.min);
extremes.max = extremes.max.concat(errExt.max);
}
function sceneOptions(gd, subplot, trace, positions, x, y) {
var opts = convert.style(gd, trace);
if (opts.marker) {
opts.marker.positions = positions;
}
if (opts.line && positions.length > 1) {
Lib.extendFlat(opts.line, convert.linePositions(gd, trace, positions));
}
if (opts.errorX || opts.errorY) {
var errors = convert.errorBarPositions(gd, trace, positions, x, y);
if (opts.errorX) {
Lib.extendFlat(opts.errorX, errors.x);
}
if (opts.errorY) {
Lib.extendFlat(opts.errorY, errors.y);
}
}
if (opts.text) {
Lib.extendFlat(opts.text, {
positions: positions
}, convert.textPosition(gd, trace, opts.text, opts.marker));
Lib.extendFlat(opts.textSel, {
positions: positions
}, convert.textPosition(gd, trace, opts.text, opts.markerSel));
Lib.extendFlat(opts.textUnsel, {
positions: positions
}, convert.textPosition(gd, trace, opts.text, opts.markerUnsel));
}
return opts;
}
/***/ }),
/***/ 67072:
/***/ (function(module) {
"use strict";
var SYMBOL_SIZE = 20;
module.exports = {
TOO_MANY_POINTS: 1e5,
SYMBOL_SDF_SIZE: 200,
SYMBOL_SIZE: SYMBOL_SIZE,
SYMBOL_STROKE: SYMBOL_SIZE / 20,
DOT_RE: /-dot/,
OPEN_RE: /-open/,
DASHES: {
solid: [1],
dot: [1, 1],
dash: [4, 1],
longdash: [8, 1],
dashdot: [4, 1, 1, 1],
longdashdot: [8, 1, 1, 1]
}
};
/***/ }),
/***/ 6616:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var isNumeric = __webpack_require__(38248);
var svgSdf = __webpack_require__(20472);
var rgba = __webpack_require__(72160);
var Registry = __webpack_require__(24040);
var Lib = __webpack_require__(3400);
var isArrayOrTypedArray = Lib.isArrayOrTypedArray;
var Drawing = __webpack_require__(43616);
var AxisIDs = __webpack_require__(79811);
var formatColor = (__webpack_require__(33040).formatColor);
var subTypes = __webpack_require__(43028);
var makeBubbleSizeFn = __webpack_require__(7152);
var helpers = __webpack_require__(80088);
var constants = __webpack_require__(67072);
var DESELECTDIM = (__webpack_require__(13448).DESELECTDIM);
var TEXTOFFSETSIGN = {
start: 1,
left: 1,
end: -1,
right: -1,
middle: 0,
center: 0,
bottom: 1,
top: -1
};
var appendArrayPointValue = (__webpack_require__(10624).appendArrayPointValue);
function convertStyle(gd, trace) {
var i;
var opts = {
marker: undefined,
markerSel: undefined,
markerUnsel: undefined,
line: undefined,
fill: undefined,
errorX: undefined,
errorY: undefined,
text: undefined,
textSel: undefined,
textUnsel: undefined
};
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
if (trace.visible !== true) return opts;
if (subTypes.hasText(trace)) {
opts.text = convertTextStyle(gd, trace);
opts.textSel = convertTextSelection(gd, trace, trace.selected);
opts.textUnsel = convertTextSelection(gd, trace, trace.unselected);
}
if (subTypes.hasMarkers(trace)) {
opts.marker = convertMarkerStyle(gd, trace);
opts.markerSel = convertMarkerSelection(gd, trace, trace.selected);
opts.markerUnsel = convertMarkerSelection(gd, trace, trace.unselected);
if (!trace.unselected && isArrayOrTypedArray(trace.marker.opacity)) {
var mo = trace.marker.opacity;
opts.markerUnsel.opacity = new Array(mo.length);
for (i = 0; i < mo.length; i++) {
opts.markerUnsel.opacity[i] = DESELECTDIM * mo[i];
}
}
}
if (subTypes.hasLines(trace)) {
opts.line = {
overlay: true,
thickness: trace.line.width * plotGlPixelRatio,
color: trace.line.color,
opacity: trace.opacity
};
var dashes = (constants.DASHES[trace.line.dash] || [1]).slice();
for (i = 0; i < dashes.length; ++i) {
dashes[i] *= trace.line.width * plotGlPixelRatio;
}
opts.line.dashes = dashes;
}
if (trace.error_x && trace.error_x.visible) {
opts.errorX = convertErrorBarStyle(trace, trace.error_x, plotGlPixelRatio);
}
if (trace.error_y && trace.error_y.visible) {
opts.errorY = convertErrorBarStyle(trace, trace.error_y, plotGlPixelRatio);
}
if (!!trace.fill && trace.fill !== 'none') {
opts.fill = {
closed: true,
fill: trace.fillcolor,
thickness: 0
};
}
return opts;
}
function convertTextStyle(gd, trace) {
var fullLayout = gd._fullLayout;
var count = trace._length;
var textfontIn = trace.textfont;
var textpositionIn = trace.textposition;
var textPos = isArrayOrTypedArray(textpositionIn) ? textpositionIn : [textpositionIn];
var tfc = textfontIn.color;
var tfs = textfontIn.size;
var tff = textfontIn.family;
var optsOut = {};
var i;
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
var texttemplate = trace.texttemplate;
if (texttemplate) {
optsOut.text = [];
var d3locale = fullLayout._d3locale;
var isArray = Array.isArray(texttemplate);
var N = isArray ? Math.min(texttemplate.length, count) : count;
var txt = isArray ? function (i) {
return texttemplate[i];
} : function () {
return texttemplate;
};
for (i = 0; i < N; i++) {
var d = {
i: i
};
var labels = trace._module.formatLabels(d, trace, fullLayout);
var pointValues = {};
appendArrayPointValue(pointValues, trace, i);
var meta = trace._meta || {};
optsOut.text.push(Lib.texttemplateString(txt(i), labels, d3locale, pointValues, d, meta));
}
} else {
if (isArrayOrTypedArray(trace.text) && trace.text.length < count) {
// if text array is shorter, we'll need to append to it, so let's slice to prevent mutating
optsOut.text = trace.text.slice();
} else {
optsOut.text = trace.text;
}
}
// pad text array with empty strings
if (isArrayOrTypedArray(optsOut.text)) {
for (i = optsOut.text.length; i < count; i++) {
optsOut.text[i] = '';
}
}
optsOut.opacity = trace.opacity;
optsOut.font = {};
optsOut.align = [];
optsOut.baseline = [];
for (i = 0; i < textPos.length; i++) {
var tp = textPos[i].split(/\s+/);
switch (tp[1]) {
case 'left':
optsOut.align.push('right');
break;
case 'right':
optsOut.align.push('left');
break;
default:
optsOut.align.push(tp[1]);
}
switch (tp[0]) {
case 'top':
optsOut.baseline.push('bottom');
break;
case 'bottom':
optsOut.baseline.push('top');
break;
default:
optsOut.baseline.push(tp[0]);
}
}
if (isArrayOrTypedArray(tfc)) {
optsOut.color = new Array(count);
for (i = 0; i < count; i++) {
optsOut.color[i] = tfc[i];
}
} else {
optsOut.color = tfc;
}
if (isArrayOrTypedArray(tfs) || isArrayOrTypedArray(tff)) {
// if any textfont param is array - make render a batch
optsOut.font = new Array(count);
for (i = 0; i < count; i++) {
var fonti = optsOut.font[i] = {};
fonti.size = (Lib.isTypedArray(tfs) ? tfs[i] : isArrayOrTypedArray(tfs) ? isNumeric(tfs[i]) ? tfs[i] : 0 : tfs) * plotGlPixelRatio;
fonti.family = isArrayOrTypedArray(tff) ? tff[i] : tff;
}
} else {
// if both are single values, make render fast single-value
optsOut.font = {
size: tfs * plotGlPixelRatio,
family: tff
};
}
return optsOut;
}
function convertMarkerStyle(gd, trace) {
var count = trace._length;
var optsIn = trace.marker;
var optsOut = {};
var i;
var multiSymbol = isArrayOrTypedArray(optsIn.symbol);
var multiAngle = isArrayOrTypedArray(optsIn.angle);
var multiColor = isArrayOrTypedArray(optsIn.color);
var multiLineColor = isArrayOrTypedArray(optsIn.line.color);
var multiOpacity = isArrayOrTypedArray(optsIn.opacity);
var multiSize = isArrayOrTypedArray(optsIn.size);
var multiLineWidth = isArrayOrTypedArray(optsIn.line.width);
var isOpen;
if (!multiSymbol) isOpen = helpers.isOpenSymbol(optsIn.symbol);
// prepare colors
if (multiSymbol || multiColor || multiLineColor || multiOpacity || multiAngle) {
optsOut.symbols = new Array(count);
optsOut.angles = new Array(count);
optsOut.colors = new Array(count);
optsOut.borderColors = new Array(count);
var symbols = optsIn.symbol;
var angles = optsIn.angle;
var colors = formatColor(optsIn, optsIn.opacity, count);
var borderColors = formatColor(optsIn.line, optsIn.opacity, count);
if (!isArrayOrTypedArray(borderColors[0])) {
var borderColor = borderColors;
borderColors = Array(count);
for (i = 0; i < count; i++) {
borderColors[i] = borderColor;
}
}
if (!isArrayOrTypedArray(colors[0])) {
var color = colors;
colors = Array(count);
for (i = 0; i < count; i++) {
colors[i] = color;
}
}
if (!isArrayOrTypedArray(symbols)) {
var symbol = symbols;
symbols = Array(count);
for (i = 0; i < count; i++) {
symbols[i] = symbol;
}
}
if (!isArrayOrTypedArray(angles)) {
var angle = angles;
angles = Array(count);
for (i = 0; i < count; i++) {
angles[i] = angle;
}
}
optsOut.symbols = symbols;
optsOut.angles = angles;
optsOut.colors = colors;
optsOut.borderColors = borderColors;
for (i = 0; i < count; i++) {
if (multiSymbol) {
isOpen = helpers.isOpenSymbol(optsIn.symbol[i]);
}
if (isOpen) {
borderColors[i] = colors[i].slice();
colors[i] = colors[i].slice();
colors[i][3] = 0;
}
}
optsOut.opacity = trace.opacity;
optsOut.markers = new Array(count);
for (i = 0; i < count; i++) {
optsOut.markers[i] = getSymbolSdf({
mx: optsOut.symbols[i],
ma: optsOut.angles[i]
}, trace);
}
} else {
if (isOpen) {
optsOut.color = rgba(optsIn.color, 'uint8');
optsOut.color[3] = 0;
optsOut.borderColor = rgba(optsIn.color, 'uint8');
} else {
optsOut.color = rgba(optsIn.color, 'uint8');
optsOut.borderColor = rgba(optsIn.line.color, 'uint8');
}
optsOut.opacity = trace.opacity * optsIn.opacity;
optsOut.marker = getSymbolSdf({
mx: optsIn.symbol,
ma: optsIn.angle
}, trace);
}
// prepare sizes
var sizeFactor = 1;
var markerSizeFunc = makeBubbleSizeFn(trace, sizeFactor);
var s;
if (multiSize || multiLineWidth) {
var sizes = optsOut.sizes = new Array(count);
var borderSizes = optsOut.borderSizes = new Array(count);
var sizeTotal = 0;
var sizeAvg;
if (multiSize) {
for (i = 0; i < count; i++) {
sizes[i] = markerSizeFunc(optsIn.size[i]);
sizeTotal += sizes[i];
}
sizeAvg = sizeTotal / count;
} else {
s = markerSizeFunc(optsIn.size);
for (i = 0; i < count; i++) {
sizes[i] = s;
}
}
// See https://github.com/plotly/plotly.js/pull/1781#discussion_r121820798
if (multiLineWidth) {
for (i = 0; i < count; i++) {
borderSizes[i] = optsIn.line.width[i];
}
} else {
s = optsIn.line.width;
for (i = 0; i < count; i++) {
borderSizes[i] = s;
}
}
optsOut.sizeAvg = sizeAvg;
} else {
optsOut.size = markerSizeFunc(optsIn && optsIn.size || 10);
optsOut.borderSizes = markerSizeFunc(optsIn.line.width);
}
return optsOut;
}
function convertMarkerSelection(gd, trace, target) {
var optsIn = trace.marker;
var optsOut = {};
if (!target) return optsOut;
if (target.marker && target.marker.symbol) {
optsOut = convertMarkerStyle(gd, Lib.extendFlat({}, optsIn, target.marker));
} else if (target.marker) {
if (target.marker.size) optsOut.size = target.marker.size;
if (target.marker.color) optsOut.colors = target.marker.color;
if (target.marker.opacity !== undefined) optsOut.opacity = target.marker.opacity;
}
return optsOut;
}
function convertTextSelection(gd, trace, target) {
var optsOut = {};
if (!target) return optsOut;
if (target.textfont) {
var optsIn = {
opacity: 1,
text: trace.text,
texttemplate: trace.texttemplate,
textposition: trace.textposition,
textfont: Lib.extendFlat({}, trace.textfont)
};
if (target.textfont) {
Lib.extendFlat(optsIn.textfont, target.textfont);
}
optsOut = convertTextStyle(gd, optsIn);
}
return optsOut;
}
function convertErrorBarStyle(trace, target, plotGlPixelRatio) {
var optsOut = {
capSize: target.width * 2 * plotGlPixelRatio,
lineWidth: target.thickness * plotGlPixelRatio,
color: target.color
};
if (target.copy_ystyle) {
optsOut = trace.error_y;
}
return optsOut;
}
var SYMBOL_SDF_SIZE = constants.SYMBOL_SDF_SIZE;
var SYMBOL_SIZE = constants.SYMBOL_SIZE;
var SYMBOL_STROKE = constants.SYMBOL_STROKE;
var SYMBOL_SDF = {};
var SYMBOL_SVG_CIRCLE = Drawing.symbolFuncs[0](SYMBOL_SIZE * 0.05);
function getSymbolSdf(d, trace) {
var symbol = d.mx;
if (symbol === 'circle') return null;
var symbolPath, symbolSdf;
var symbolNumber = Drawing.symbolNumber(symbol);
var symbolFunc = Drawing.symbolFuncs[symbolNumber % 100];
var symbolNoDot = !!Drawing.symbolNoDot[symbolNumber % 100];
var symbolNoFill = !!Drawing.symbolNoFill[symbolNumber % 100];
var isDot = helpers.isDotSymbol(symbol);
// until we may handle angles in shader?
if (d.ma) symbol += '_' + d.ma;
// get symbol sdf from cache or generate it
if (SYMBOL_SDF[symbol]) return SYMBOL_SDF[symbol];
var angle = Drawing.getMarkerAngle(d, trace);
if (isDot && !symbolNoDot) {
symbolPath = symbolFunc(SYMBOL_SIZE * 1.1, angle) + SYMBOL_SVG_CIRCLE;
} else {
symbolPath = symbolFunc(SYMBOL_SIZE, angle);
}
symbolSdf = svgSdf(symbolPath, {
w: SYMBOL_SDF_SIZE,
h: SYMBOL_SDF_SIZE,
viewBox: [-SYMBOL_SIZE, -SYMBOL_SIZE, SYMBOL_SIZE, SYMBOL_SIZE],
stroke: symbolNoFill ? SYMBOL_STROKE : -SYMBOL_STROKE
});
SYMBOL_SDF[symbol] = symbolSdf;
return symbolSdf || null;
}
function convertLinePositions(gd, trace, positions) {
var len = positions.length;
var count = len / 2;
var linePositions;
var i;
if (subTypes.hasLines(trace) && count) {
if (trace.line.shape === 'hv') {
linePositions = [];
for (i = 0; i < count - 1; i++) {
if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
linePositions.push(NaN, NaN, NaN, NaN);
} else {
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
if (!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
linePositions.push(positions[i * 2 + 2], positions[i * 2 + 1]);
} else {
linePositions.push(NaN, NaN);
}
}
}
linePositions.push(positions[len - 2], positions[len - 1]);
} else if (trace.line.shape === 'hvh') {
linePositions = [];
for (i = 0; i < count - 1; i++) {
if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
if (!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
} else {
linePositions.push(NaN, NaN);
}
linePositions.push(NaN, NaN);
} else {
var midPtX = (positions[i * 2] + positions[i * 2 + 2]) / 2;
linePositions.push(positions[i * 2], positions[i * 2 + 1], midPtX, positions[i * 2 + 1], midPtX, positions[i * 2 + 3]);
}
}
linePositions.push(positions[len - 2], positions[len - 1]);
} else if (trace.line.shape === 'vhv') {
linePositions = [];
for (i = 0; i < count - 1; i++) {
if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1]) || isNaN(positions[i * 2 + 2]) || isNaN(positions[i * 2 + 3])) {
if (!isNaN(positions[i * 2]) && !isNaN(positions[i * 2 + 1])) {
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
} else {
linePositions.push(NaN, NaN);
}
linePositions.push(NaN, NaN);
} else {
var midPtY = (positions[i * 2 + 1] + positions[i * 2 + 3]) / 2;
linePositions.push(positions[i * 2], positions[i * 2 + 1], positions[i * 2], midPtY, positions[i * 2 + 2], midPtY);
}
}
linePositions.push(positions[len - 2], positions[len - 1]);
} else if (trace.line.shape === 'vh') {
linePositions = [];
for (i = 0; i < count - 1; i++) {
if (isNaN(positions[i * 2]) || isNaN(positions[i * 2 + 1])) {
linePositions.push(NaN, NaN, NaN, NaN);
} else {
linePositions.push(positions[i * 2], positions[i * 2 + 1]);
if (!isNaN(positions[i * 2 + 2]) && !isNaN(positions[i * 2 + 3])) {
linePositions.push(positions[i * 2], positions[i * 2 + 3]);
} else {
linePositions.push(NaN, NaN);
}
}
}
linePositions.push(positions[len - 2], positions[len - 1]);
} else {
linePositions = positions;
}
}
// If we have data with gaps, we ought to use rect joins
// FIXME: get rid of this
var hasNaN = false;
for (i = 0; i < linePositions.length; i++) {
if (isNaN(linePositions[i])) {
hasNaN = true;
break;
}
}
var join = hasNaN || linePositions.length > constants.TOO_MANY_POINTS ? 'rect' : subTypes.hasMarkers(trace) ? 'rect' : 'round';
// fill gaps
if (hasNaN && trace.connectgaps) {
var lastX = linePositions[0];
var lastY = linePositions[1];
for (i = 0; i < linePositions.length; i += 2) {
if (isNaN(linePositions[i]) || isNaN(linePositions[i + 1])) {
linePositions[i] = lastX;
linePositions[i + 1] = lastY;
} else {
lastX = linePositions[i];
lastY = linePositions[i + 1];
}
}
}
return {
join: join,
positions: linePositions
};
}
function convertErrorBarPositions(gd, trace, positions, x, y) {
var makeComputeError = Registry.getComponentMethod('errorbars', 'makeComputeError');
var xa = AxisIDs.getFromId(gd, trace.xaxis, 'x');
var ya = AxisIDs.getFromId(gd, trace.yaxis, 'y');
var count = positions.length / 2;
var out = {};
function convertOneAxis(coords, ax) {
var axLetter = ax._id.charAt(0);
var opts = trace['error_' + axLetter];
if (opts && opts.visible && (ax.type === 'linear' || ax.type === 'log')) {
var computeError = makeComputeError(opts);
var pOffset = {
x: 0,
y: 1
}[axLetter];
var eOffset = {
x: [0, 1, 2, 3],
y: [2, 3, 0, 1]
}[axLetter];
var errors = new Float64Array(4 * count);
var minShoe = Infinity;
var maxHat = -Infinity;
for (var i = 0, j = 0; i < count; i++, j += 4) {
var dc = coords[i];
if (isNumeric(dc)) {
var dl = positions[i * 2 + pOffset];
var vals = computeError(dc, i);
var lv = vals[0];
var hv = vals[1];
if (isNumeric(lv) && isNumeric(hv)) {
var shoe = dc - lv;
var hat = dc + hv;
errors[j + eOffset[0]] = dl - ax.c2l(shoe);
errors[j + eOffset[1]] = ax.c2l(hat) - dl;
errors[j + eOffset[2]] = 0;
errors[j + eOffset[3]] = 0;
minShoe = Math.min(minShoe, dc - lv);
maxHat = Math.max(maxHat, dc + hv);
}
}
}
out[axLetter] = {
positions: positions,
errors: errors,
_bnds: [minShoe, maxHat]
};
}
}
convertOneAxis(x, xa);
convertOneAxis(y, ya);
return out;
}
function convertTextPosition(gd, trace, textOpts, markerOpts) {
var count = trace._length;
var out = {};
var i;
// corresponds to textPointPosition from component.drawing
if (subTypes.hasMarkers(trace)) {
var fontOpts = textOpts.font;
var align = textOpts.align;
var baseline = textOpts.baseline;
out.offset = new Array(count);
for (i = 0; i < count; i++) {
var ms = markerOpts.sizes ? markerOpts.sizes[i] : markerOpts.size;
var fs = isArrayOrTypedArray(fontOpts) ? fontOpts[i].size : fontOpts.size;
var a = isArrayOrTypedArray(align) ? align.length > 1 ? align[i] : align[0] : align;
var b = isArrayOrTypedArray(baseline) ? baseline.length > 1 ? baseline[i] : baseline[0] : baseline;
var hSign = TEXTOFFSETSIGN[a];
var vSign = TEXTOFFSETSIGN[b];
var xPad = ms ? ms / 0.8 + 1 : 0;
var yPad = -vSign * xPad - vSign * 0.5;
out.offset[i] = [hSign * xPad / fs, yPad / fs];
}
}
return out;
}
module.exports = {
style: convertStyle,
markerStyle: convertMarkerStyle,
markerSelection: convertMarkerSelection,
linePositions: convertLinePositions,
errorBarPositions: convertErrorBarPositions,
textPosition: convertTextPosition
};
/***/ }),
/***/ 80220:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Registry = __webpack_require__(24040);
var helpers = __webpack_require__(80088);
var attributes = __webpack_require__(2876);
var constants = __webpack_require__(88200);
var subTypes = __webpack_require__(43028);
var handleXYDefaults = __webpack_require__(43980);
var handlePeriodDefaults = __webpack_require__(31147);
var handleMarkerDefaults = __webpack_require__(74428);
var handleLineDefaults = __webpack_require__(66828);
var handleFillColorDefaults = __webpack_require__(70840);
var handleTextDefaults = __webpack_require__(124);
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var isOpen = traceIn.marker ? helpers.isOpenSymbol(traceIn.marker.symbol) : false;
var isBubble = subTypes.isBubble(traceIn);
var len = handleXYDefaults(traceIn, traceOut, layout, coerce);
if (!len) {
traceOut.visible = false;
return;
}
handlePeriodDefaults(traceIn, traceOut, layout, coerce);
coerce('xhoverformat');
coerce('yhoverformat');
var defaultMode = len < constants.PTS_LINESONLY ? 'lines+markers' : 'lines';
coerce('text');
coerce('hovertext');
coerce('hovertemplate');
coerce('mode', defaultMode);
if (subTypes.hasMarkers(traceOut)) {
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, {
noAngleRef: true,
noStandOff: true
});
coerce('marker.line.width', isOpen || isBubble ? 1 : 0);
}
if (subTypes.hasLines(traceOut)) {
coerce('connectgaps');
handleLineDefaults(traceIn, traceOut, defaultColor, layout, coerce);
coerce('line.shape');
}
if (subTypes.hasText(traceOut)) {
coerce('texttemplate');
handleTextDefaults(traceIn, traceOut, layout, coerce);
}
var lineColor = (traceOut.line || {}).color;
var markerColor = (traceOut.marker || {}).color;
coerce('fill');
if (traceOut.fill !== 'none') {
handleFillColorDefaults(traceIn, traceOut, defaultColor, coerce);
}
var errorBarsSupplyDefaults = Registry.getComponentMethod('errorbars', 'supplyDefaults');
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {
axis: 'y'
});
errorBarsSupplyDefaults(traceIn, traceOut, lineColor || markerColor || defaultColor, {
axis: 'x',
inherit: 'y'
});
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
};
/***/ }),
/***/ 26768:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Color = __webpack_require__(76308);
var DESELECTDIM = (__webpack_require__(13448).DESELECTDIM);
function styleTextSelection(cd) {
var cd0 = cd[0];
var trace = cd0.trace;
var stash = cd0.t;
var scene = stash._scene;
var index = stash.index;
var els = scene.selectBatch[index];
var unels = scene.unselectBatch[index];
var baseOpts = scene.textOptions[index];
var selOpts = scene.textSelectedOptions[index] || {};
var unselOpts = scene.textUnselectedOptions[index] || {};
var opts = Lib.extendFlat({}, baseOpts);
var i, j;
if (els.length || unels.length) {
var stc = selOpts.color;
var utc = unselOpts.color;
var base = baseOpts.color;
var hasArrayBase = Lib.isArrayOrTypedArray(base);
opts.color = new Array(trace._length);
for (i = 0; i < els.length; i++) {
j = els[i];
opts.color[j] = stc || (hasArrayBase ? base[j] : base);
}
for (i = 0; i < unels.length; i++) {
j = unels[i];
var basej = hasArrayBase ? base[j] : base;
opts.color[j] = utc ? utc : stc ? basej : Color.addOpacity(basej, DESELECTDIM);
}
}
scene.glText[index].update(opts);
}
module.exports = {
styleTextSelection: styleTextSelection
};
/***/ }),
/***/ 99396:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var scatterFormatLabels = __webpack_require__(76688);
module.exports = function formatLabels(cdi, trace, fullLayout) {
var i = cdi.i;
if (!('x' in cdi)) cdi.x = trace._x[i];
if (!('y' in cdi)) cdi.y = trace._y[i];
return scatterFormatLabels(cdi, trace, fullLayout);
};
/***/ }),
/***/ 80088:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var constants = __webpack_require__(67072);
exports.isOpenSymbol = function (symbol) {
return typeof symbol === 'string' ? constants.OPEN_RE.test(symbol) : symbol % 200 > 100;
};
exports.isDotSymbol = function (symbol) {
return typeof symbol === 'string' ? constants.DOT_RE.test(symbol) : symbol > 200;
};
/***/ }),
/***/ 41272:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Registry = __webpack_require__(24040);
var Lib = __webpack_require__(3400);
var getTraceColor = __webpack_require__(44928);
function hoverPoints(pointData, xval, yval, hovermode) {
var cd = pointData.cd;
var stash = cd[0].t;
var trace = cd[0].trace;
var xa = pointData.xa;
var ya = pointData.ya;
var x = stash.x;
var y = stash.y;
var xpx = xa.c2p(xval);
var ypx = ya.c2p(yval);
var maxDistance = pointData.distance;
var ids;
// FIXME: make sure this is a proper way to calc search radius
if (stash.tree) {
var xl = xa.p2c(xpx - maxDistance);
var xr = xa.p2c(xpx + maxDistance);
var yl = ya.p2c(ypx - maxDistance);
var yr = ya.p2c(ypx + maxDistance);
if (hovermode === 'x') {
ids = stash.tree.range(Math.min(xl, xr), Math.min(ya._rl[0], ya._rl[1]), Math.max(xl, xr), Math.max(ya._rl[0], ya._rl[1]));
} else {
ids = stash.tree.range(Math.min(xl, xr), Math.min(yl, yr), Math.max(xl, xr), Math.max(yl, yr));
}
} else {
ids = stash.ids;
}
// pick the id closest to the point
// note that point possibly may not be found
var k, closestId, ptx, pty, i, dx, dy, dist, dxy;
var minDist = maxDistance;
if (hovermode === 'x') {
var xPeriod = !!trace.xperiodalignment;
var yPeriod = !!trace.yperiodalignment;
for (i = 0; i < ids.length; i++) {
k = ids[i];
ptx = x[k];
dx = Math.abs(xa.c2p(ptx) - xpx);
if (xPeriod) {
var x0 = xa.c2p(trace._xStarts[k]);
var x1 = xa.c2p(trace._xEnds[k]);
dx = xpx >= Math.min(x0, x1) && xpx <= Math.max(x0, x1) ? 0 : Infinity;
}
if (dx < minDist) {
minDist = dx;
pty = y[k];
dy = ya.c2p(pty) - ypx;
if (yPeriod) {
var y0 = ya.c2p(trace._yStarts[k]);
var y1 = ya.c2p(trace._yEnds[k]);
dy = ypx >= Math.min(y0, y1) && ypx <= Math.max(y0, y1) ? 0 : Infinity;
}
dxy = Math.sqrt(dx * dx + dy * dy);
closestId = ids[i];
}
}
} else {
for (i = ids.length - 1; i > -1; i--) {
k = ids[i];
ptx = x[k];
pty = y[k];
dx = xa.c2p(ptx) - xpx;
dy = ya.c2p(pty) - ypx;
dist = Math.sqrt(dx * dx + dy * dy);
if (dist < minDist) {
minDist = dxy = dist;
closestId = k;
}
}
}
pointData.index = closestId;
pointData.distance = minDist;
pointData.dxy = dxy;
if (closestId === undefined) return [pointData];
return [calcHover(pointData, x, y, trace)];
}
function calcHover(pointData, x, y, trace) {
var xa = pointData.xa;
var ya = pointData.ya;
var minDist = pointData.distance;
var dxy = pointData.dxy;
var id = pointData.index;
// the closest data point
var di = {
pointNumber: id,
x: x[id],
y: y[id]
};
// that is single-item arrays_to_calcdata excerpt, since we are doing it for a single point and we don't have to do it beforehead for 1e6 points
di.tx = Lib.isArrayOrTypedArray(trace.text) ? trace.text[id] : trace.text;
di.htx = Array.isArray(trace.hovertext) ? trace.hovertext[id] : trace.hovertext;
di.data = Array.isArray(trace.customdata) ? trace.customdata[id] : trace.customdata;
di.tp = Array.isArray(trace.textposition) ? trace.textposition[id] : trace.textposition;
var font = trace.textfont;
if (font) {
di.ts = Lib.isArrayOrTypedArray(font.size) ? font.size[id] : font.size;
di.tc = Array.isArray(font.color) ? font.color[id] : font.color;
di.tf = Array.isArray(font.family) ? font.family[id] : font.family;
}
var marker = trace.marker;
if (marker) {
di.ms = Lib.isArrayOrTypedArray(marker.size) ? marker.size[id] : marker.size;
di.mo = Lib.isArrayOrTypedArray(marker.opacity) ? marker.opacity[id] : marker.opacity;
di.mx = Lib.isArrayOrTypedArray(marker.symbol) ? marker.symbol[id] : marker.symbol;
di.ma = Lib.isArrayOrTypedArray(marker.angle) ? marker.angle[id] : marker.angle;
di.mc = Lib.isArrayOrTypedArray(marker.color) ? marker.color[id] : marker.color;
}
var line = marker && marker.line;
if (line) {
di.mlc = Array.isArray(line.color) ? line.color[id] : line.color;
di.mlw = Lib.isArrayOrTypedArray(line.width) ? line.width[id] : line.width;
}
var grad = marker && marker.gradient;
if (grad && grad.type !== 'none') {
di.mgt = Array.isArray(grad.type) ? grad.type[id] : grad.type;
di.mgc = Array.isArray(grad.color) ? grad.color[id] : grad.color;
}
var xp = xa.c2p(di.x, true);
var yp = ya.c2p(di.y, true);
var rad = di.mrc || 1;
var hoverlabel = trace.hoverlabel;
if (hoverlabel) {
di.hbg = Array.isArray(hoverlabel.bgcolor) ? hoverlabel.bgcolor[id] : hoverlabel.bgcolor;
di.hbc = Array.isArray(hoverlabel.bordercolor) ? hoverlabel.bordercolor[id] : hoverlabel.bordercolor;
di.hts = Lib.isArrayOrTypedArray(hoverlabel.font.size) ? hoverlabel.font.size[id] : hoverlabel.font.size;
di.htc = Array.isArray(hoverlabel.font.color) ? hoverlabel.font.color[id] : hoverlabel.font.color;
di.htf = Array.isArray(hoverlabel.font.family) ? hoverlabel.font.family[id] : hoverlabel.font.family;
di.hnl = Lib.isArrayOrTypedArray(hoverlabel.namelength) ? hoverlabel.namelength[id] : hoverlabel.namelength;
}
var hoverinfo = trace.hoverinfo;
if (hoverinfo) {
di.hi = Array.isArray(hoverinfo) ? hoverinfo[id] : hoverinfo;
}
var hovertemplate = trace.hovertemplate;
if (hovertemplate) {
di.ht = Array.isArray(hovertemplate) ? hovertemplate[id] : hovertemplate;
}
var fakeCd = {};
fakeCd[pointData.index] = di;
var origX = trace._origX;
var origY = trace._origY;
var pointData2 = Lib.extendFlat({}, pointData, {
color: getTraceColor(trace, di),
x0: xp - rad,
x1: xp + rad,
xLabelVal: origX ? origX[id] : di.x,
y0: yp - rad,
y1: yp + rad,
yLabelVal: origY ? origY[id] : di.y,
cd: fakeCd,
distance: minDist,
spikeDistance: dxy,
hovertemplate: di.ht
});
if (di.htx) pointData2.text = di.htx;else if (di.tx) pointData2.text = di.tx;else if (trace.text) pointData2.text = trace.text;
Lib.fillText(di, trace, pointData2);
Registry.getComponentMethod('errorbars', 'hoverInfo')(di, trace, pointData2);
return pointData2;
}
module.exports = {
hoverPoints: hoverPoints,
calcHover: calcHover
};
/***/ }),
/***/ 38983:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var index = __webpack_require__(64628);
index.plot = __webpack_require__(89876);
module.exports = index;
/***/ }),
/***/ 89876:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var createScatter = __webpack_require__(38540);
var createLine = __webpack_require__(13472);
var createError = __webpack_require__(24544);
var Text = __webpack_require__(23352);
var Lib = __webpack_require__(3400);
var selectMode = (__webpack_require__(72760).selectMode);
var prepareRegl = __webpack_require__(5048);
var subTypes = __webpack_require__(43028);
var linkTraces = __webpack_require__(14328);
var styleTextSelection = (__webpack_require__(26768).styleTextSelection);
var reglPrecompiled = {};
function getViewport(fullLayout, xaxis, yaxis, plotGlPixelRatio) {
var gs = fullLayout._size;
var width = fullLayout.width * plotGlPixelRatio;
var height = fullLayout.height * plotGlPixelRatio;
var l = gs.l * plotGlPixelRatio;
var b = gs.b * plotGlPixelRatio;
var r = gs.r * plotGlPixelRatio;
var t = gs.t * plotGlPixelRatio;
var w = gs.w * plotGlPixelRatio;
var h = gs.h * plotGlPixelRatio;
return [l + xaxis.domain[0] * w, b + yaxis.domain[0] * h, width - r - (1 - xaxis.domain[1]) * w, height - t - (1 - yaxis.domain[1]) * h];
}
var exports = module.exports = function plot(gd, subplot, cdata) {
if (!cdata.length) return;
var fullLayout = gd._fullLayout;
var scene = subplot._scene;
var xaxis = subplot.xaxis;
var yaxis = subplot.yaxis;
var i, j;
// we may have more subplots than initialized data due to Axes.getSubplots method
if (!scene) return;
var success = prepareRegl(gd, ['ANGLE_instanced_arrays', 'OES_element_index_uint'], reglPrecompiled);
if (!success) {
scene.init();
return;
}
var count = scene.count;
var regl = fullLayout._glcanvas.data()[0].regl;
// that is needed for fills
linkTraces(gd, subplot, cdata);
if (scene.dirty) {
if ((scene.line2d || scene.error2d) && !(scene.scatter2d || scene.fill2d || scene.glText)) {
// Fixes shared WebGL context drawing lines only case
regl.clear({});
}
// make sure scenes are created
if (scene.error2d === true) {
scene.error2d = createError(regl);
}
if (scene.line2d === true) {
scene.line2d = createLine(regl);
}
if (scene.scatter2d === true) {
scene.scatter2d = createScatter(regl);
}
if (scene.fill2d === true) {
scene.fill2d = createLine(regl);
}
if (scene.glText === true) {
scene.glText = new Array(count);
for (i = 0; i < count; i++) {
scene.glText[i] = new Text(regl);
}
}
// update main marker options
if (scene.glText) {
if (count > scene.glText.length) {
// add gl text marker
var textsToAdd = count - scene.glText.length;
for (i = 0; i < textsToAdd; i++) {
scene.glText.push(new Text(regl));
}
} else if (count < scene.glText.length) {
// remove gl text marker
var textsToRemove = scene.glText.length - count;
var removedTexts = scene.glText.splice(count, textsToRemove);
removedTexts.forEach(function (text) {
text.destroy();
});
}
for (i = 0; i < count; i++) {
scene.glText[i].update(scene.textOptions[i]);
}
}
if (scene.line2d) {
scene.line2d.update(scene.lineOptions);
scene.lineOptions = scene.lineOptions.map(function (lineOptions) {
if (lineOptions && lineOptions.positions) {
var srcPos = lineOptions.positions;
var firstptdef = 0;
while (firstptdef < srcPos.length && (isNaN(srcPos[firstptdef]) || isNaN(srcPos[firstptdef + 1]))) {
firstptdef += 2;
}
var lastptdef = srcPos.length - 2;
while (lastptdef > firstptdef && (isNaN(srcPos[lastptdef]) || isNaN(srcPos[lastptdef + 1]))) {
lastptdef -= 2;
}
lineOptions.positions = srcPos.slice(firstptdef, lastptdef + 2);
}
return lineOptions;
});
scene.line2d.update(scene.lineOptions);
}
if (scene.error2d) {
var errorBatch = (scene.errorXOptions || []).concat(scene.errorYOptions || []);
scene.error2d.update(errorBatch);
}
if (scene.scatter2d) {
scene.scatter2d.update(scene.markerOptions);
}
// fill requires linked traces, so we generate it's positions here
scene.fillOrder = Lib.repeat(null, count);
if (scene.fill2d) {
scene.fillOptions = scene.fillOptions.map(function (fillOptions, i) {
var cdscatter = cdata[i];
if (!fillOptions || !cdscatter || !cdscatter[0] || !cdscatter[0].trace) return;
var cd = cdscatter[0];
var trace = cd.trace;
var stash = cd.t;
var lineOptions = scene.lineOptions[i];
var last, j;
var fillData = [];
if (trace._ownfill) fillData.push(i);
if (trace._nexttrace) fillData.push(i + 1);
if (fillData.length) scene.fillOrder[i] = fillData;
var pos = [];
var srcPos = lineOptions && lineOptions.positions || stash.positions;
var firstptdef, lastptdef;
if (trace.fill === 'tozeroy') {
firstptdef = 0;
while (firstptdef < srcPos.length && isNaN(srcPos[firstptdef + 1])) {
firstptdef += 2;
}
lastptdef = srcPos.length - 2;
while (lastptdef > firstptdef && isNaN(srcPos[lastptdef + 1])) {
lastptdef -= 2;
}
if (srcPos[firstptdef + 1] !== 0) {
pos = [srcPos[firstptdef], 0];
}
pos = pos.concat(srcPos.slice(firstptdef, lastptdef + 2));
if (srcPos[lastptdef + 1] !== 0) {
pos = pos.concat([srcPos[lastptdef], 0]);
}
} else if (trace.fill === 'tozerox') {
firstptdef = 0;
while (firstptdef < srcPos.length && isNaN(srcPos[firstptdef])) {
firstptdef += 2;
}
lastptdef = srcPos.length - 2;
while (lastptdef > firstptdef && isNaN(srcPos[lastptdef])) {
lastptdef -= 2;
}
if (srcPos[firstptdef] !== 0) {
pos = [0, srcPos[firstptdef + 1]];
}
pos = pos.concat(srcPos.slice(firstptdef, lastptdef + 2));
if (srcPos[lastptdef] !== 0) {
pos = pos.concat([0, srcPos[lastptdef + 1]]);
}
} else if (trace.fill === 'toself' || trace.fill === 'tonext') {
pos = [];
last = 0;
fillOptions.splitNull = true;
for (j = 0; j < srcPos.length; j += 2) {
if (isNaN(srcPos[j]) || isNaN(srcPos[j + 1])) {
pos = pos.concat(srcPos.slice(last, j));
pos.push(srcPos[last], srcPos[last + 1]);
pos.push(null, null); // keep null to mark end of polygon
last = j + 2;
}
}
pos = pos.concat(srcPos.slice(last));
if (last) {
pos.push(srcPos[last], srcPos[last + 1]);
}
} else {
var nextTrace = trace._nexttrace;
if (nextTrace) {
var nextOptions = scene.lineOptions[i + 1];
if (nextOptions) {
var nextPos = nextOptions.positions;
if (trace.fill === 'tonexty') {
pos = srcPos.slice();
for (i = Math.floor(nextPos.length / 2); i--;) {
var xx = nextPos[i * 2];
var yy = nextPos[i * 2 + 1];
if (isNaN(xx) || isNaN(yy)) continue;
pos.push(xx, yy);
}
fillOptions.fill = nextTrace.fillcolor;
}
}
}
}
// detect prev trace positions to exclude from current fill
if (trace._prevtrace && trace._prevtrace.fill === 'tonext') {
var prevLinePos = scene.lineOptions[i - 1].positions;
// FIXME: likely this logic should be tested better
var offset = pos.length / 2;
last = offset;
var hole = [last];
for (j = 0; j < prevLinePos.length; j += 2) {
if (isNaN(prevLinePos[j]) || isNaN(prevLinePos[j + 1])) {
hole.push(j / 2 + offset + 1);
last = j + 2;
}
}
pos = pos.concat(prevLinePos);
fillOptions.hole = hole;
}
fillOptions.fillmode = trace.fill;
fillOptions.opacity = trace.opacity;
fillOptions.positions = pos;
return fillOptions;
});
scene.fill2d.update(scene.fillOptions);
}
}
// form batch arrays, and check for selected points
var dragmode = fullLayout.dragmode;
var isSelectMode = selectMode(dragmode);
var clickSelectEnabled = fullLayout.clickmode.indexOf('select') > -1;
for (i = 0; i < count; i++) {
var cd0 = cdata[i][0];
var trace = cd0.trace;
var stash = cd0.t;
var index = stash.index;
var len = trace._length;
var x = stash.x;
var y = stash.y;
if (trace.selectedpoints || isSelectMode || clickSelectEnabled) {
if (!isSelectMode) isSelectMode = true;
// regenerate scene batch, if traces number changed during selection
if (trace.selectedpoints) {
var selPts = scene.selectBatch[index] = Lib.selIndices2selPoints(trace);
var selDict = {};
for (j = 0; j < selPts.length; j++) {
selDict[selPts[j]] = 1;
}
var unselPts = [];
for (j = 0; j < len; j++) {
if (!selDict[j]) unselPts.push(j);
}
scene.unselectBatch[index] = unselPts;
}
// precalculate px coords since we are not going to pan during select
// TODO, could do better here e.g.
// - spin that in a webworker
// - compute selection from polygons in data coordinates
// (maybe just for linear axes)
var xpx = stash.xpx = new Array(len);
var ypx = stash.ypx = new Array(len);
for (j = 0; j < len; j++) {
xpx[j] = xaxis.c2p(x[j]);
ypx[j] = yaxis.c2p(y[j]);
}
} else {
stash.xpx = stash.ypx = null;
}
}
if (isSelectMode) {
// create scatter instance by cloning scatter2d
if (!scene.select2d) {
scene.select2d = createScatter(fullLayout._glcanvas.data()[1].regl);
}
// use unselected styles on 'context' canvas
if (scene.scatter2d) {
var unselOpts = new Array(count);
for (i = 0; i < count; i++) {
unselOpts[i] = scene.selectBatch[i].length || scene.unselectBatch[i].length ? scene.markerUnselectedOptions[i] : {};
}
scene.scatter2d.update(unselOpts);
}
// use selected style on 'focus' canvas
if (scene.select2d) {
scene.select2d.update(scene.markerOptions);
scene.select2d.update(scene.markerSelectedOptions);
}
if (scene.glText) {
cdata.forEach(function (cdscatter) {
var trace = ((cdscatter || [])[0] || {}).trace || {};
if (subTypes.hasText(trace)) {
styleTextSelection(cdscatter);
}
});
}
} else {
// reset 'context' scatter2d opts to base opts,
// thus unsetting markerUnselectedOptions from selection
if (scene.scatter2d) {
scene.scatter2d.update(scene.markerOptions);
}
}
// provide viewport and range
var vpRange0 = {
viewport: getViewport(fullLayout, xaxis, yaxis, gd._context.plotGlPixelRatio),
// TODO do we need those fallbacks?
range: [(xaxis._rl || xaxis.range)[0], (yaxis._rl || yaxis.range)[0], (xaxis._rl || xaxis.range)[1], (yaxis._rl || yaxis.range)[1]]
};
var vpRange = Lib.repeat(vpRange0, scene.count);
// upload viewport/range data to GPU
if (scene.fill2d) {
scene.fill2d.update(vpRange);
}
if (scene.line2d) {
scene.line2d.update(vpRange);
}
if (scene.error2d) {
scene.error2d.update(vpRange.concat(vpRange));
}
if (scene.scatter2d) {
scene.scatter2d.update(vpRange);
}
if (scene.select2d) {
scene.select2d.update(vpRange);
}
if (scene.glText) {
scene.glText.forEach(function (text) {
text.update(vpRange0);
});
}
};
exports.reglPrecompiled = reglPrecompiled;
/***/ }),
/***/ 74588:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
// make sure scene exists on subplot, return it
module.exports = function sceneUpdate(gd, subplot) {
var scene = subplot._scene;
var resetOpts = {
// number of traces in subplot, since scene:subplot -> 1:1
count: 0,
// whether scene requires init hook in plot call (dirty plot call)
dirty: true,
// last used options
lineOptions: [],
fillOptions: [],
markerOptions: [],
markerSelectedOptions: [],
markerUnselectedOptions: [],
errorXOptions: [],
errorYOptions: [],
textOptions: [],
textSelectedOptions: [],
textUnselectedOptions: [],
// selection batches
selectBatch: [],
unselectBatch: []
};
// regl- component stubs, initialized in dirty plot call
var initOpts = {
fill2d: false,
scatter2d: false,
error2d: false,
line2d: false,
glText: false,
select2d: false
};
if (!subplot._scene) {
scene = subplot._scene = {};
scene.init = function init() {
Lib.extendFlat(scene, initOpts, resetOpts);
};
scene.init();
// apply new option to all regl components (used on drag)
scene.update = function update(opt) {
var opts = Lib.repeat(opt, scene.count);
if (scene.fill2d) scene.fill2d.update(opts);
if (scene.scatter2d) scene.scatter2d.update(opts);
if (scene.line2d) scene.line2d.update(opts);
if (scene.error2d) scene.error2d.update(opts.concat(opts));
if (scene.select2d) scene.select2d.update(opts);
if (scene.glText) {
for (var i = 0; i < scene.count; i++) {
scene.glText[i].update(opt);
}
}
};
// draw traces in proper order
scene.draw = function draw() {
var count = scene.count;
var fill2d = scene.fill2d;
var error2d = scene.error2d;
var line2d = scene.line2d;
var scatter2d = scene.scatter2d;
var glText = scene.glText;
var select2d = scene.select2d;
var selectBatch = scene.selectBatch;
var unselectBatch = scene.unselectBatch;
for (var i = 0; i < count; i++) {
if (fill2d && scene.fillOrder[i]) {
fill2d.draw(scene.fillOrder[i]);
}
if (line2d && scene.lineOptions[i]) {
line2d.draw(i);
}
if (error2d) {
if (scene.errorXOptions[i]) error2d.draw(i);
if (scene.errorYOptions[i]) error2d.draw(i + count);
}
if (scatter2d && scene.markerOptions[i]) {
if (unselectBatch[i].length) {
var arg = Lib.repeat([], scene.count);
arg[i] = unselectBatch[i];
scatter2d.draw(arg);
} else if (!selectBatch[i].length) {
scatter2d.draw(i);
}
}
if (glText[i] && scene.textOptions[i]) {
glText[i].render();
}
}
if (select2d) {
select2d.draw(selectBatch);
}
scene.dirty = false;
};
// remove scene resources
scene.destroy = function destroy() {
if (scene.fill2d && scene.fill2d.destroy) scene.fill2d.destroy();
if (scene.scatter2d && scene.scatter2d.destroy) scene.scatter2d.destroy();
if (scene.error2d && scene.error2d.destroy) scene.error2d.destroy();
if (scene.line2d && scene.line2d.destroy) scene.line2d.destroy();
if (scene.select2d && scene.select2d.destroy) scene.select2d.destroy();
if (scene.glText) {
scene.glText.forEach(function (text) {
if (text.destroy) text.destroy();
});
}
scene.lineOptions = null;
scene.fillOptions = null;
scene.markerOptions = null;
scene.markerSelectedOptions = null;
scene.markerUnselectedOptions = null;
scene.errorXOptions = null;
scene.errorYOptions = null;
scene.textOptions = null;
scene.textSelectedOptions = null;
scene.textUnselectedOptions = null;
scene.selectBatch = null;
scene.unselectBatch = null;
// we can't just delete _scene, because `destroy` is called in the
// middle of supplyDefaults, before relinkPrivateKeys which will put it back.
subplot._scene = null;
};
}
// in case if we have scene from the last calc - reset data
if (!scene.dirty) {
Lib.extendFlat(scene, resetOpts);
}
return scene;
};
/***/ }),
/***/ 73224:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var subTypes = __webpack_require__(43028);
var styleTextSelection = (__webpack_require__(26768).styleTextSelection);
module.exports = function select(searchInfo, selectionTester) {
var cd = searchInfo.cd;
var xa = searchInfo.xaxis;
var ya = searchInfo.yaxis;
var selection = [];
var trace = cd[0].trace;
var stash = cd[0].t;
var len = trace._length;
var x = stash.x;
var y = stash.y;
var scene = stash._scene;
var index = stash.index;
if (!scene) return selection;
var hasText = subTypes.hasText(trace);
var hasMarkers = subTypes.hasMarkers(trace);
var hasOnlyLines = !hasMarkers && !hasText;
if (trace.visible !== true || hasOnlyLines) return selection;
var els = [];
var unels = [];
// degenerate polygon does not enable selection
// filter out points by visible scatter ones
if (selectionTester !== false && !selectionTester.degenerate) {
for (var i = 0; i < len; i++) {
if (selectionTester.contains([stash.xpx[i], stash.ypx[i]], false, i, searchInfo)) {
els.push(i);
selection.push({
pointNumber: i,
x: xa.c2d(x[i]),
y: ya.c2d(y[i])
});
} else {
unels.push(i);
}
}
}
if (hasMarkers) {
var scatter2d = scene.scatter2d;
if (!els.length && !unels.length) {
// reset to base styles when clearing
var baseOpts = new Array(scene.count);
baseOpts[index] = scene.markerOptions[index];
scatter2d.update.apply(scatter2d, baseOpts);
} else if (!scene.selectBatch[index].length && !scene.unselectBatch[index].length) {
// set unselected styles on 'context' canvas (if not done already)
var unselOpts = new Array(scene.count);
unselOpts[index] = scene.markerUnselectedOptions[index];
scatter2d.update.apply(scatter2d, unselOpts);
}
}
scene.selectBatch[index] = els;
scene.unselectBatch[index] = unels;
if (hasText) {
styleTextSelection(cd);
}
return selection;
};
/***/ }),
/***/ 44524:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var scatterAttrs = __webpack_require__(52904);
var colorScaleAttrs = __webpack_require__(49084);
var axisHoverFormat = (__webpack_require__(29736).axisHoverFormat);
var hovertemplateAttrs = (__webpack_require__(21776)/* .hovertemplateAttrs */ .Ks);
var scatterGlAttrs = __webpack_require__(2876);
var cartesianIdRegex = (__webpack_require__(33816).idRegex);
var templatedArray = (__webpack_require__(31780).templatedArray);
var extendFlat = (__webpack_require__(92880).extendFlat);
var scatterMarkerAttrs = scatterAttrs.marker;
var scatterMarkerLineAttrs = scatterMarkerAttrs.line;
var markerLineAttrs = extendFlat(colorScaleAttrs('marker.line', {
editTypeOverride: 'calc'
}), {
width: extendFlat({}, scatterMarkerLineAttrs.width, {
editType: 'calc'
}),
editType: 'calc'
});
var markerAttrs = extendFlat(colorScaleAttrs('marker'), {
symbol: scatterMarkerAttrs.symbol,
angle: scatterMarkerAttrs.angle,
size: extendFlat({}, scatterMarkerAttrs.size, {
editType: 'markerSize'
}),
sizeref: scatterMarkerAttrs.sizeref,
sizemin: scatterMarkerAttrs.sizemin,
sizemode: scatterMarkerAttrs.sizemode,
opacity: scatterMarkerAttrs.opacity,
colorbar: scatterMarkerAttrs.colorbar,
line: markerLineAttrs,
editType: 'calc'
});
markerAttrs.color.editType = markerAttrs.cmin.editType = markerAttrs.cmax.editType = 'style';
function makeAxesValObject(axLetter) {
return {
valType: 'info_array',
freeLength: true,
editType: 'calc',
items: {
valType: 'subplotid',
regex: cartesianIdRegex[axLetter],
editType: 'plot'
}
};
}
module.exports = {
dimensions: templatedArray('dimension', {
visible: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
label: {
valType: 'string',
editType: 'calc'
},
values: {
valType: 'data_array',
editType: 'calc+clearAxisTypes'
},
axis: {
type: {
valType: 'enumerated',
values: ['linear', 'log', 'date', 'category'],
editType: 'calc+clearAxisTypes'
},
// TODO make 'true' the default in v3?
matches: {
valType: 'boolean',
dflt: false,
editType: 'calc'
},
editType: 'calc+clearAxisTypes'
},
// TODO should add an attribute to pin down x only vars and y only vars
// like https://seaborn.pydata.org/generated/seaborn.pairplot.html
// x_vars and y_vars
// maybe more axis defaulting option e.g. `showgrid: false`
editType: 'calc+clearAxisTypes'
}),
// mode: {}, (only 'markers' for now)
text: extendFlat({}, scatterGlAttrs.text, {}),
hovertext: extendFlat({}, scatterGlAttrs.hovertext, {}),
hovertemplate: hovertemplateAttrs(),
xhoverformat: axisHoverFormat('x'),
yhoverformat: axisHoverFormat('y'),
marker: markerAttrs,
xaxes: makeAxesValObject('x'),
yaxes: makeAxesValObject('y'),
diagonal: {
visible: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
// type: 'scattergl' | 'histogram' | 'box' | 'violin'
// ...
// more options
editType: 'calc'
},
showupperhalf: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
showlowerhalf: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
selected: {
marker: scatterGlAttrs.selected.marker,
editType: 'calc'
},
unselected: {
marker: scatterGlAttrs.unselected.marker,
editType: 'calc'
},
opacity: scatterGlAttrs.opacity
};
/***/ }),
/***/ 28888:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Registry = __webpack_require__(24040);
var Grid = __webpack_require__(12704);
module.exports = {
moduleType: 'trace',
name: 'splom',
categories: ['gl', 'regl', 'cartesian', 'symbols', 'showLegend', 'scatter-like'],
attributes: __webpack_require__(44524),
supplyDefaults: __webpack_require__(69544),
colorbar: __webpack_require__(5528),
calc: __webpack_require__(66821),
plot: __webpack_require__(54840),
hoverPoints: (__webpack_require__(72248).hoverPoints),
selectPoints: __webpack_require__(84880),
editStyle: __webpack_require__(83156),
meta: {}
};
// splom traces use the 'grid' component to generate their axes,
// register it here
Registry.register(Grid);
/***/ }),
/***/ 99332:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var createLine = __webpack_require__(13472);
var Registry = __webpack_require__(24040);
var prepareRegl = __webpack_require__(5048);
var getModuleCalcData = (__webpack_require__(84888)/* .getModuleCalcData */ ._M);
var Cartesian = __webpack_require__(57952);
var getFromId = (__webpack_require__(79811).getFromId);
var shouldShowZeroLine = (__webpack_require__(54460).shouldShowZeroLine);
var SPLOM = 'splom';
var reglPrecompiled = {};
function plot(gd) {
var fullLayout = gd._fullLayout;
var _module = Registry.getModule(SPLOM);
var splomCalcData = getModuleCalcData(gd.calcdata, _module)[0];
var success = prepareRegl(gd, ['ANGLE_instanced_arrays', 'OES_element_index_uint'], reglPrecompiled);
if (!success) return;
if (fullLayout._hasOnlyLargeSploms) {
updateGrid(gd);
}
_module.plot(gd, {}, splomCalcData);
}
function drag(gd) {
var cd = gd.calcdata;
var fullLayout = gd._fullLayout;
if (fullLayout._hasOnlyLargeSploms) {
updateGrid(gd);
}
for (var i = 0; i < cd.length; i++) {
var cd0 = cd[i][0];
var trace = cd0.trace;
var scene = fullLayout._splomScenes[trace.uid];
if (trace.type === 'splom' && scene && scene.matrix) {
dragOne(gd, trace, scene);
}
}
}
function dragOne(gd, trace, scene) {
var visibleLength = scene.matrixOptions.data.length;
var visibleDims = trace._visibleDims;
var ranges = scene.viewOpts.ranges = new Array(visibleLength);
for (var k = 0; k < visibleDims.length; k++) {
var i = visibleDims[k];
var rng = ranges[k] = new Array(4);
var xa = getFromId(gd, trace._diag[i][0]);
if (xa) {
rng[0] = xa.r2l(xa.range[0]);
rng[2] = xa.r2l(xa.range[1]);
}
var ya = getFromId(gd, trace._diag[i][1]);
if (ya) {
rng[1] = ya.r2l(ya.range[0]);
rng[3] = ya.r2l(ya.range[1]);
}
}
if (scene.selectBatch.length || scene.unselectBatch.length) {
scene.matrix.update({
ranges: ranges
}, {
ranges: ranges
});
} else {
scene.matrix.update({
ranges: ranges
});
}
}
function updateGrid(gd) {
var fullLayout = gd._fullLayout;
var regl = fullLayout._glcanvas.data()[0].regl;
var splomGrid = fullLayout._splomGrid;
if (!splomGrid) {
splomGrid = fullLayout._splomGrid = createLine(regl);
}
splomGrid.update(makeGridData(gd));
}
function makeGridData(gd) {
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
var fullLayout = gd._fullLayout;
var gs = fullLayout._size;
var fullView = [0, 0, fullLayout.width * plotGlPixelRatio, fullLayout.height * plotGlPixelRatio];
var lookup = {};
var k;
function push(prefix, ax, x0, x1, y0, y1) {
x0 *= plotGlPixelRatio;
x1 *= plotGlPixelRatio;
y0 *= plotGlPixelRatio;
y1 *= plotGlPixelRatio;
var lcolor = ax[prefix + 'color'];
var lwidth = ax[prefix + 'width'];
var key = String(lcolor + lwidth);
if (key in lookup) {
lookup[key].data.push(NaN, NaN, x0, x1, y0, y1);
} else {
lookup[key] = {
data: [x0, x1, y0, y1],
join: 'rect',
thickness: lwidth * plotGlPixelRatio,
color: lcolor,
viewport: fullView,
range: fullView,
overlay: false
};
}
}
for (k in fullLayout._splomSubplots) {
var sp = fullLayout._plots[k];
var xa = sp.xaxis;
var ya = sp.yaxis;
var xVals = xa._gridVals;
var yVals = ya._gridVals;
var xOffset = xa._offset;
var xLength = xa._length;
var yLength = ya._length;
// ya.l2p assumes top-to-bottom coordinate system (a la SVG),
// we need to compute bottom-to-top offsets and slopes:
var yOffset = gs.b + ya.domain[0] * gs.h;
var ym = -ya._m;
var yb = -ym * ya.r2l(ya.range[0], ya.calendar);
var x, y;
if (xa.showgrid) {
for (k = 0; k < xVals.length; k++) {
x = xOffset + xa.l2p(xVals[k].x);
push('grid', xa, x, yOffset, x, yOffset + yLength);
}
}
if (ya.showgrid) {
for (k = 0; k < yVals.length; k++) {
y = yOffset + yb + ym * yVals[k].x;
push('grid', ya, xOffset, y, xOffset + xLength, y);
}
}
if (shouldShowZeroLine(gd, xa, ya)) {
x = xOffset + xa.l2p(0);
push('zeroline', xa, x, yOffset, x, yOffset + yLength);
}
if (shouldShowZeroLine(gd, ya, xa)) {
y = yOffset + yb + 0;
push('zeroline', ya, xOffset, y, xOffset + xLength, y);
}
}
var gridBatches = [];
for (k in lookup) {
gridBatches.push(lookup[k]);
}
return gridBatches;
}
function clean(newFullData, newFullLayout, oldFullData, oldFullLayout) {
var lookup = {};
var i;
if (oldFullLayout._splomScenes) {
for (i = 0; i < newFullData.length; i++) {
var newTrace = newFullData[i];
if (newTrace.type === 'splom') {
lookup[newTrace.uid] = 1;
}
}
for (i = 0; i < oldFullData.length; i++) {
var oldTrace = oldFullData[i];
if (!lookup[oldTrace.uid]) {
var scene = oldFullLayout._splomScenes[oldTrace.uid];
if (scene && scene.destroy) scene.destroy();
// must first set scene to null in order to get garbage collected
oldFullLayout._splomScenes[oldTrace.uid] = null;
delete oldFullLayout._splomScenes[oldTrace.uid];
}
}
}
if (Object.keys(oldFullLayout._splomScenes || {}).length === 0) {
delete oldFullLayout._splomScenes;
}
if (oldFullLayout._splomGrid && !newFullLayout._hasOnlyLargeSploms && oldFullLayout._hasOnlyLargeSploms) {
// must first set scene to null in order to get garbage collected
oldFullLayout._splomGrid.destroy();
oldFullLayout._splomGrid = null;
delete oldFullLayout._splomGrid;
}
Cartesian.clean(newFullData, newFullLayout, oldFullData, oldFullLayout);
}
module.exports = {
name: SPLOM,
attr: Cartesian.attr,
attrRegex: Cartesian.attrRegex,
layoutAttributes: Cartesian.layoutAttributes,
supplyLayoutDefaults: Cartesian.supplyLayoutDefaults,
drawFramework: Cartesian.drawFramework,
plot: plot,
drag: drag,
updateGrid: updateGrid,
clean: clean,
updateFx: Cartesian.updateFx,
toSVG: Cartesian.toSVG,
reglPrecompiled: reglPrecompiled
};
/***/ }),
/***/ 66821:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var AxisIDs = __webpack_require__(79811);
var calcMarkerSize = (__webpack_require__(16356).calcMarkerSize);
var calcAxisExpansion = (__webpack_require__(16356).calcAxisExpansion);
var calcColorscale = __webpack_require__(90136);
var convertMarkerSelection = (__webpack_require__(6616).markerSelection);
var convertMarkerStyle = (__webpack_require__(6616).markerStyle);
var sceneUpdate = __webpack_require__(72308);
var BADNUM = (__webpack_require__(39032).BADNUM);
var TOO_MANY_POINTS = (__webpack_require__(67072).TOO_MANY_POINTS);
module.exports = function calc(gd, trace) {
var dimensions = trace.dimensions;
var commonLength = trace._length;
var opts = {};
// 'c' for calculated, 'l' for linear,
// only differ here for log axes, pass ldata to createMatrix as 'data'
var cdata = opts.cdata = [];
var ldata = opts.data = [];
// keep track of visible dimensions
var visibleDims = trace._visibleDims = [];
var i, k, dim, xa, ya;
function makeCalcdata(ax, dim) {
// call makeCalcdata with fake input
var ccol = ax.makeCalcdata({
v: dim.values,
vcalendar: trace.calendar
}, 'v');
for (var j = 0; j < ccol.length; j++) {
ccol[j] = ccol[j] === BADNUM ? NaN : ccol[j];
}
cdata.push(ccol);
ldata.push(ax.type === 'log' ? Lib.simpleMap(ccol, ax.c2l) : ccol);
}
for (i = 0; i < dimensions.length; i++) {
dim = dimensions[i];
if (dim.visible) {
xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
// if corresponding x & y axes don't have matching types, skip dim
if (xa && ya && xa.type !== ya.type) {
Lib.log('Skipping splom dimension ' + i + ' with conflicting axis types');
continue;
}
if (xa) {
makeCalcdata(xa, dim);
if (ya && ya.type === 'category') {
ya._categories = xa._categories.slice();
}
} else {
// should not make it here, if both xa and ya undefined
makeCalcdata(ya, dim);
}
visibleDims.push(i);
}
}
calcColorscale(gd, trace);
Lib.extendFlat(opts, convertMarkerStyle(gd, trace));
var visibleLength = cdata.length;
var hasTooManyPoints = visibleLength * commonLength > TOO_MANY_POINTS;
// Reuse SVG scatter axis expansion routine.
// For graphs with very large number of points and array marker.size,
// use average marker size instead to speed things up.
var ppad;
if (hasTooManyPoints) {
ppad = opts.sizeAvg || Math.max(opts.size, 3);
} else {
ppad = calcMarkerSize(trace, commonLength);
}
for (k = 0; k < visibleDims.length; k++) {
i = visibleDims[k];
dim = dimensions[i];
xa = AxisIDs.getFromId(gd, trace._diag[i][0]) || {};
ya = AxisIDs.getFromId(gd, trace._diag[i][1]) || {};
calcAxisExpansion(gd, trace, xa, ya, cdata[k], cdata[k], ppad);
}
var scene = sceneUpdate(gd, trace);
if (!scene.matrix) scene.matrix = true;
scene.matrixOptions = opts;
scene.selectedOptions = convertMarkerSelection(gd, trace, trace.selected);
scene.unselectedOptions = convertMarkerSelection(gd, trace, trace.unselected);
return [{
x: false,
y: false,
t: {},
trace: trace
}];
};
/***/ }),
/***/ 69544:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var handleArrayContainerDefaults = __webpack_require__(51272);
var attributes = __webpack_require__(44524);
var subTypes = __webpack_require__(43028);
var handleMarkerDefaults = __webpack_require__(74428);
var mergeLength = __webpack_require__(26284);
var isOpenSymbol = (__webpack_require__(80088).isOpenSymbol);
module.exports = function supplyDefaults(traceIn, traceOut, defaultColor, layout) {
function coerce(attr, dflt) {
return Lib.coerce(traceIn, traceOut, attributes, attr, dflt);
}
var dimensions = handleArrayContainerDefaults(traceIn, traceOut, {
name: 'dimensions',
handleItemDefaults: dimensionDefaults
});
var showDiag = coerce('diagonal.visible');
var showUpper = coerce('showupperhalf');
var showLower = coerce('showlowerhalf');
var dimLength = mergeLength(traceOut, dimensions, 'values');
if (!dimLength || !showDiag && !showUpper && !showLower) {
traceOut.visible = false;
return;
}
coerce('text');
coerce('hovertext');
coerce('hovertemplate');
coerce('xhoverformat');
coerce('yhoverformat');
handleMarkerDefaults(traceIn, traceOut, defaultColor, layout, coerce, {
noAngleRef: true,
noStandOff: true
});
var isOpen = isOpenSymbol(traceOut.marker.symbol);
var isBubble = subTypes.isBubble(traceOut);
coerce('marker.line.width', isOpen || isBubble ? 1 : 0);
handleAxisDefaults(traceIn, traceOut, layout, coerce);
Lib.coerceSelectionMarkerOpacity(traceOut, coerce);
};
function dimensionDefaults(dimIn, dimOut) {
function coerce(attr, dflt) {
return Lib.coerce(dimIn, dimOut, attributes.dimensions, attr, dflt);
}
coerce('label');
var values = coerce('values');
if (!(values && values.length)) dimOut.visible = false;else coerce('visible');
coerce('axis.type');
coerce('axis.matches');
}
function handleAxisDefaults(traceIn, traceOut, layout, coerce) {
var dimensions = traceOut.dimensions;
var dimLength = dimensions.length;
var showUpper = traceOut.showupperhalf;
var showLower = traceOut.showlowerhalf;
var showDiag = traceOut.diagonal.visible;
var i, j;
var xAxesDflt = new Array(dimLength);
var yAxesDflt = new Array(dimLength);
for (i = 0; i < dimLength; i++) {
var suffix = i ? i + 1 : '';
xAxesDflt[i] = 'x' + suffix;
yAxesDflt[i] = 'y' + suffix;
}
var xaxes = coerce('xaxes', xAxesDflt);
var yaxes = coerce('yaxes', yAxesDflt);
// build list of [x,y] axis corresponding to each dimensions[i],
// very useful for passing options to regl-splom
var diag = traceOut._diag = new Array(dimLength);
// lookup for 'drawn' x|y axes, to avoid costly indexOf downstream
traceOut._xaxes = {};
traceOut._yaxes = {};
// list of 'drawn' x|y axes, use to generate list of subplots
var xList = [];
var yList = [];
function fillAxisStashes(axId, counterAxId, dim, list) {
if (!axId) return;
var axLetter = axId.charAt(0);
var stash = layout._splomAxes[axLetter];
traceOut['_' + axLetter + 'axes'][axId] = 1;
list.push(axId);
if (!(axId in stash)) {
var s = stash[axId] = {};
if (dim) {
s.label = dim.label || '';
if (dim.visible && dim.axis) {
if (dim.axis.type) s.type = dim.axis.type;
if (dim.axis.matches) s.matches = counterAxId;
}
}
}
}
// cases where showDiag and showLower or showUpper are false
// no special treatment as the 'drawn' x-axes and y-axes no longer match
// the dimensions items and xaxes|yaxes 1-to-1
var mustShiftX = !showDiag && !showLower;
var mustShiftY = !showDiag && !showUpper;
traceOut._axesDim = {};
for (i = 0; i < dimLength; i++) {
var dim = dimensions[i];
var i0 = i === 0;
var iN = i === dimLength - 1;
var xaId = i0 && mustShiftX || iN && mustShiftY ? undefined : xaxes[i];
var yaId = i0 && mustShiftY || iN && mustShiftX ? undefined : yaxes[i];
fillAxisStashes(xaId, yaId, dim, xList);
fillAxisStashes(yaId, xaId, dim, yList);
diag[i] = [xaId, yaId];
traceOut._axesDim[xaId] = i;
traceOut._axesDim[yaId] = i;
}
// fill in splom subplot keys
for (i = 0; i < xList.length; i++) {
for (j = 0; j < yList.length; j++) {
var id = xList[i] + yList[j];
if (i > j && showUpper) {
layout._splomSubplots[id] = 1;
} else if (i < j && showLower) {
layout._splomSubplots[id] = 1;
} else if (i === j && (showDiag || !showLower || !showUpper)) {
// need to include diagonal subplots when
// hiding one half and the diagonal
layout._splomSubplots[id] = 1;
}
}
}
// when lower half is omitted, or when just the diagonal is gone,
// override grid default to make sure axes remain on
// the left/bottom of the plot area
if (!showLower || !showDiag && showUpper && showLower) {
layout._splomGridDflt.xside = 'bottom';
layout._splomGridDflt.yside = 'left';
}
}
/***/ }),
/***/ 83156:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var calcColorscale = __webpack_require__(90136);
var convertMarkerStyle = (__webpack_require__(6616).markerStyle);
module.exports = function editStyle(gd, cd0) {
var trace = cd0.trace;
var scene = gd._fullLayout._splomScenes[trace.uid];
if (scene) {
calcColorscale(gd, trace);
Lib.extendFlat(scene.matrixOptions, convertMarkerStyle(gd, trace));
// TODO [un]selected styles?
var opts = Lib.extendFlat({}, scene.matrixOptions, scene.viewOpts);
// TODO this is too long for arrayOk attributes!
scene.matrix.update(opts, null);
}
};
/***/ }),
/***/ 50328:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
exports.getDimIndex = function getDimIndex(trace, ax) {
var axId = ax._id;
var axLetter = axId.charAt(0);
var ind = {
x: 0,
y: 1
}[axLetter];
var visibleDims = trace._visibleDims;
for (var k = 0; k < visibleDims.length; k++) {
var i = visibleDims[k];
if (trace._diag[i][ind] === axId) return k;
}
return false;
};
/***/ }),
/***/ 72248:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var helpers = __webpack_require__(50328);
var calcHover = (__webpack_require__(41272).calcHover);
var getFromId = (__webpack_require__(54460).getFromId);
var extendFlat = (__webpack_require__(92880).extendFlat);
function hoverPoints(pointData, xval, yval, hovermode, opts) {
if (!opts) opts = {};
var hovermodeHasX = (hovermode || '').charAt(0) === 'x';
var hovermodeHasY = (hovermode || '').charAt(0) === 'y';
var points = _hoverPoints(pointData, xval, yval);
if ((hovermodeHasX || hovermodeHasY) && opts.hoversubplots === 'axis' && points[0]) {
var subplotsWith = (hovermodeHasX ? pointData.xa : pointData.ya)._subplotsWith;
var gd = opts.gd;
var _pointData = extendFlat({}, pointData);
for (var i = 0; i < subplotsWith.length; i++) {
var spId = subplotsWith[i];
if (hovermodeHasY) {
_pointData.xa = getFromId(gd, spId, 'x');
} else {
// hovermodeHasX
_pointData.ya = getFromId(gd, spId, 'y');
}
var axisHoversubplots = hovermodeHasX || hovermodeHasY;
var newPoints = _hoverPoints(_pointData, xval, yval, axisHoversubplots);
points = points.concat(newPoints);
}
}
return points;
}
function _hoverPoints(pointData, xval, yval, axisHoversubplots) {
var cd = pointData.cd;
var trace = cd[0].trace;
var scene = pointData.scene;
var cdata = scene.matrixOptions.cdata;
var xa = pointData.xa;
var ya = pointData.ya;
var xpx = xa.c2p(xval);
var ypx = ya.c2p(yval);
var maxDistance = pointData.distance;
var xi = helpers.getDimIndex(trace, xa);
var yi = helpers.getDimIndex(trace, ya);
if (xi === false || yi === false) return [pointData];
var x = cdata[xi];
var y = cdata[yi];
var id, dxy;
var minDist = maxDistance;
for (var i = 0; i < x.length; i++) {
if (axisHoversubplots && i !== pointData.index) continue;
var ptx = x[i];
var pty = y[i];
var dx = xa.c2p(ptx) - xpx;
var dy = ya.c2p(pty) - ypx;
var dist = Math.sqrt(dx * dx + dy * dy);
if (axisHoversubplots || dist < minDist) {
minDist = dxy = dist;
id = i;
}
}
pointData.index = id;
pointData.distance = minDist;
pointData.dxy = dxy;
if (id === undefined) return [pointData];
return [calcHover(pointData, x, y, trace)];
}
module.exports = {
hoverPoints: hoverPoints
};
/***/ }),
/***/ 97924:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var index = __webpack_require__(28888);
index.basePlotModule = __webpack_require__(99332), module.exports = index;
/***/ }),
/***/ 54840:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var createMatrix = __webpack_require__(78176);
var Lib = __webpack_require__(3400);
var AxisIDs = __webpack_require__(79811);
var selectMode = (__webpack_require__(72760).selectMode);
module.exports = function plot(gd, _, splomCalcData) {
if (!splomCalcData.length) return;
for (var i = 0; i < splomCalcData.length; i++) {
plotOne(gd, splomCalcData[i][0]);
}
};
function plotOne(gd, cd0) {
var fullLayout = gd._fullLayout;
var gs = fullLayout._size;
var trace = cd0.trace;
var stash = cd0.t;
var scene = fullLayout._splomScenes[trace.uid];
var matrixOpts = scene.matrixOptions;
var cdata = matrixOpts.cdata;
var regl = fullLayout._glcanvas.data()[0].regl;
var dragmode = fullLayout.dragmode;
var xa, ya;
var i, j, k;
if (cdata.length === 0) return;
// augment options with proper upper/lower halves
// regl-splom's default grid starts from bottom-left
matrixOpts.lower = trace.showupperhalf;
matrixOpts.upper = trace.showlowerhalf;
matrixOpts.diagonal = trace.diagonal.visible;
var visibleDims = trace._visibleDims;
var visibleLength = cdata.length;
var viewOpts = scene.viewOpts = {};
viewOpts.ranges = new Array(visibleLength);
viewOpts.domains = new Array(visibleLength);
for (k = 0; k < visibleDims.length; k++) {
i = visibleDims[k];
var rng = viewOpts.ranges[k] = new Array(4);
var dmn = viewOpts.domains[k] = new Array(4);
xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
if (xa) {
rng[0] = xa._rl[0];
rng[2] = xa._rl[1];
dmn[0] = xa.domain[0];
dmn[2] = xa.domain[1];
}
ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
if (ya) {
rng[1] = ya._rl[0];
rng[3] = ya._rl[1];
dmn[1] = ya.domain[0];
dmn[3] = ya.domain[1];
}
}
var plotGlPixelRatio = gd._context.plotGlPixelRatio;
var l = gs.l * plotGlPixelRatio;
var b = gs.b * plotGlPixelRatio;
var w = gs.w * plotGlPixelRatio;
var h = gs.h * plotGlPixelRatio;
viewOpts.viewport = [l, b, w + l, h + b];
if (scene.matrix === true) {
scene.matrix = createMatrix(regl);
}
var clickSelectEnabled = fullLayout.clickmode.indexOf('select') > -1;
var isSelectMode = selectMode(dragmode) || !!trace.selectedpoints || clickSelectEnabled;
var needsBaseUpdate = true;
if (isSelectMode) {
var commonLength = trace._length;
// regenerate scene batch, if traces number changed during selection
if (trace.selectedpoints) {
scene.selectBatch = trace.selectedpoints;
var selPts = trace.selectedpoints;
var selDict = {};
for (i = 0; i < selPts.length; i++) {
selDict[selPts[i]] = true;
}
var unselPts = [];
for (i = 0; i < commonLength; i++) {
if (!selDict[i]) unselPts.push(i);
}
scene.unselectBatch = unselPts;
}
// precalculate px coords since we are not going to pan during select
var xpx = stash.xpx = new Array(visibleLength);
var ypx = stash.ypx = new Array(visibleLength);
for (k = 0; k < visibleDims.length; k++) {
i = visibleDims[k];
xa = AxisIDs.getFromId(gd, trace._diag[i][0]);
if (xa) {
xpx[k] = new Array(commonLength);
for (j = 0; j < commonLength; j++) {
xpx[k][j] = xa.c2p(cdata[k][j]);
}
}
ya = AxisIDs.getFromId(gd, trace._diag[i][1]);
if (ya) {
ypx[k] = new Array(commonLength);
for (j = 0; j < commonLength; j++) {
ypx[k][j] = ya.c2p(cdata[k][j]);
}
}
}
if (scene.selectBatch.length || scene.unselectBatch.length) {
var unselOpts = Lib.extendFlat({}, matrixOpts, scene.unselectedOptions, viewOpts);
var selOpts = Lib.extendFlat({}, matrixOpts, scene.selectedOptions, viewOpts);
scene.matrix.update(unselOpts, selOpts);
needsBaseUpdate = false;
}
} else {
stash.xpx = stash.ypx = null;
}
if (needsBaseUpdate) {
var opts = Lib.extendFlat({}, matrixOpts, viewOpts);
scene.matrix.update(opts, null);
}
}
/***/ }),
/***/ 72308:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
module.exports = function sceneUpdate(gd, trace) {
var fullLayout = gd._fullLayout;
var uid = trace.uid;
// must place ref to 'scene' in fullLayout, so that:
// - it can be relinked properly on updates
// - it can be destroyed properly when needed
var splomScenes = fullLayout._splomScenes;
if (!splomScenes) splomScenes = fullLayout._splomScenes = {};
var reset = {
dirty: true,
selectBatch: [],
unselectBatch: []
};
var first = {
matrix: false,
selectBatch: [],
unselectBatch: []
};
var scene = splomScenes[trace.uid];
if (!scene) {
scene = splomScenes[uid] = Lib.extendFlat({}, reset, first);
scene.draw = function draw() {
if (scene.matrix && scene.matrix.draw) {
if (scene.selectBatch.length || scene.unselectBatch.length) {
scene.matrix.draw(scene.unselectBatch, scene.selectBatch);
} else {
scene.matrix.draw();
}
}
scene.dirty = false;
};
// remove scene resources
scene.destroy = function destroy() {
if (scene.matrix && scene.matrix.destroy) {
scene.matrix.destroy();
}
scene.matrixOptions = null;
scene.selectBatch = null;
scene.unselectBatch = null;
scene = null;
};
}
// In case if we have scene from the last calc - reset data
if (!scene.dirty) {
Lib.extendFlat(scene, reset);
}
return scene;
};
/***/ }),
/***/ 84880:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var pushUnique = Lib.pushUnique;
var subTypes = __webpack_require__(43028);
var helpers = __webpack_require__(50328);
module.exports = function select(searchInfo, selectionTester) {
var cd = searchInfo.cd;
var trace = cd[0].trace;
var stash = cd[0].t;
var scene = searchInfo.scene;
var cdata = scene.matrixOptions.cdata;
var xa = searchInfo.xaxis;
var ya = searchInfo.yaxis;
var selection = [];
if (!scene) return selection;
var hasOnlyLines = !subTypes.hasMarkers(trace) && !subTypes.hasText(trace);
if (trace.visible !== true || hasOnlyLines) return selection;
var xi = helpers.getDimIndex(trace, xa);
var yi = helpers.getDimIndex(trace, ya);
if (xi === false || yi === false) return selection;
var xpx = stash.xpx[xi];
var ypx = stash.ypx[yi];
var x = cdata[xi];
var y = cdata[yi];
var els = (searchInfo.scene.selectBatch || []).slice();
var unels = [];
// degenerate polygon does not enable selection
// filter out points by visible scatter ones
if (selectionTester !== false && !selectionTester.degenerate) {
for (var i = 0; i < x.length; i++) {
if (selectionTester.contains([xpx[i], ypx[i]], null, i, searchInfo)) {
selection.push({
pointNumber: i,
x: x[i],
y: y[i]
});
pushUnique(els, i);
} else if (els.indexOf(i) !== -1) {
pushUnique(els, i);
} else {
unels.push(i);
}
}
}
var matrixOpts = scene.matrixOptions;
if (!els.length && !unels.length) {
scene.matrix.update(matrixOpts, null);
} else if (!scene.selectBatch.length && !scene.unselectBatch.length) {
scene.matrix.update(scene.unselectedOptions, Lib.extendFlat({}, matrixOpts, scene.selectedOptions, scene.viewOpts));
}
scene.selectBatch = els;
scene.unselectBatch = unels;
return selection;
};
/***/ }),
/***/ 84224:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var Axes = __webpack_require__(54460);
var Lib = __webpack_require__(3400);
var PlotSchema = __webpack_require__(73060);
var pointsAccessorFunction = (__webpack_require__(60468)/* .pointsAccessorFunction */ .W);
var BADNUM = (__webpack_require__(39032).BADNUM);
exports.moduleType = 'transform';
exports.name = 'aggregate';
var attrs = exports.attributes = {
enabled: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
groups: {
// TODO: groupby should support string or array grouping this way too
// currently groupby only allows a grouping array
valType: 'string',
strict: true,
noBlank: true,
arrayOk: true,
dflt: 'x',
editType: 'calc'
},
aggregations: {
_isLinkedToArray: 'aggregation',
target: {
valType: 'string',
editType: 'calc'
},
func: {
valType: 'enumerated',
values: ['count', 'sum', 'avg', 'median', 'mode', 'rms', 'stddev', 'min', 'max', 'first', 'last', 'change', 'range'],
dflt: 'first',
editType: 'calc'
},
funcmode: {
valType: 'enumerated',
values: ['sample', 'population'],
dflt: 'sample',
editType: 'calc'
},
enabled: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
editType: 'calc'
},
editType: 'calc'
};
var aggAttrs = attrs.aggregations;
/**
* Supply transform attributes defaults
*
* @param {object} transformIn
* object linked to trace.transforms[i] with 'func' set to exports.name
* @param {object} traceOut
* the _fullData trace this transform applies to
* @param {object} layout
* the plot's (not-so-full) layout
* @param {object} traceIn
* the input data trace this transform applies to
*
* @return {object} transformOut
* copy of transformIn that contains attribute defaults
*/
exports.supplyDefaults = function (transformIn, traceOut) {
var transformOut = {};
var i;
function coerce(attr, dflt) {
return Lib.coerce(transformIn, transformOut, attrs, attr, dflt);
}
var enabled = coerce('enabled');
if (!enabled) return transformOut;
/*
* Normally _arrayAttrs is calculated during doCalc, but that comes later.
* Anyway this can change due to *count* aggregations (see below) so it's not
* necessarily the same set.
*
* For performance we turn it into an object of truthy values
* we'll use 1 for arrays we haven't aggregated yet, 0 for finished arrays,
* as distinct from undefined which means this array isn't present in the input
* missing arrays can still be aggregate outputs for *count* aggregations.
*/
var arrayAttrArray = PlotSchema.findArrayAttributes(traceOut);
var arrayAttrs = {};
for (i = 0; i < arrayAttrArray.length; i++) arrayAttrs[arrayAttrArray[i]] = 1;
var groups = coerce('groups');
if (!Array.isArray(groups)) {
if (!arrayAttrs[groups]) {
transformOut.enabled = false;
return transformOut;
}
arrayAttrs[groups] = 0;
}
var aggregationsIn = transformIn.aggregations || [];
var aggregationsOut = transformOut.aggregations = new Array(aggregationsIn.length);
var aggregationOut;
function coercei(attr, dflt) {
return Lib.coerce(aggregationsIn[i], aggregationOut, aggAttrs, attr, dflt);
}
for (i = 0; i < aggregationsIn.length; i++) {
aggregationOut = {
_index: i
};
var target = coercei('target');
var func = coercei('func');
var enabledi = coercei('enabled');
// add this aggregation to the output only if it's the first instance
// of a valid target attribute - or an unused target attribute with "count"
if (enabledi && target && (arrayAttrs[target] || func === 'count' && arrayAttrs[target] === undefined)) {
if (func === 'stddev') coercei('funcmode');
arrayAttrs[target] = 0;
aggregationsOut[i] = aggregationOut;
} else aggregationsOut[i] = {
enabled: false,
_index: i
};
}
// any array attributes we haven't yet covered, fill them with the default aggregation
for (i = 0; i < arrayAttrArray.length; i++) {
if (arrayAttrs[arrayAttrArray[i]]) {
aggregationsOut.push({
target: arrayAttrArray[i],
func: aggAttrs.func.dflt,
enabled: true,
_index: -1
});
}
}
return transformOut;
};
exports.calcTransform = function (gd, trace, opts) {
if (!opts.enabled) return;
var groups = opts.groups;
var groupArray = Lib.getTargetArray(trace, {
target: groups
});
if (!groupArray) return;
var i, vi, groupIndex, newGrouping;
var groupIndices = {};
var indexToPoints = {};
var groupings = [];
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
var len = groupArray.length;
if (trace._length) len = Math.min(len, trace._length);
for (i = 0; i < len; i++) {
vi = groupArray[i];
groupIndex = groupIndices[vi];
if (groupIndex === undefined) {
groupIndices[vi] = groupings.length;
newGrouping = [i];
groupings.push(newGrouping);
indexToPoints[groupIndices[vi]] = originalPointsAccessor(i);
} else {
groupings[groupIndex].push(i);
indexToPoints[groupIndices[vi]] = (indexToPoints[groupIndices[vi]] || []).concat(originalPointsAccessor(i));
}
}
opts._indexToPoints = indexToPoints;
var aggregations = opts.aggregations;
for (i = 0; i < aggregations.length; i++) {
aggregateOneArray(gd, trace, groupings, aggregations[i]);
}
if (typeof groups === 'string') {
aggregateOneArray(gd, trace, groupings, {
target: groups,
func: 'first',
enabled: true
});
}
trace._length = groupings.length;
};
function aggregateOneArray(gd, trace, groupings, aggregation) {
if (!aggregation.enabled) return;
var attr = aggregation.target;
var targetNP = Lib.nestedProperty(trace, attr);
var arrayIn = targetNP.get();
var conversions = Axes.getDataConversions(gd, trace, attr, arrayIn);
var func = getAggregateFunction(aggregation, conversions);
var arrayOut = new Array(groupings.length);
for (var i = 0; i < groupings.length; i++) {
arrayOut[i] = func(arrayIn, groupings[i]);
}
targetNP.set(arrayOut);
if (aggregation.func === 'count') {
// count does not depend on an input array, so it's likely not part of _arrayAttrs yet
// but after this transform it most definitely *is* an array attribute.
Lib.pushUnique(trace._arrayAttrs, attr);
}
}
function getAggregateFunction(opts, conversions) {
var func = opts.func;
var d2c = conversions.d2c;
var c2d = conversions.c2d;
switch (func) {
// count, first, and last don't depend on anything about the data
// point back to pure functions for performance
case 'count':
return count;
case 'first':
return first;
case 'last':
return last;
case 'sum':
// This will produce output in all cases even though it's nonsensical
// for date or category data.
return function (array, indices) {
var total = 0;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) total += vi;
}
return c2d(total);
};
case 'avg':
// Generally meaningless for category data but it still does something.
return function (array, indices) {
var total = 0;
var cnt = 0;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) {
total += vi;
cnt++;
}
}
return cnt ? c2d(total / cnt) : BADNUM;
};
case 'min':
return function (array, indices) {
var out = Infinity;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) out = Math.min(out, vi);
}
return out === Infinity ? BADNUM : c2d(out);
};
case 'max':
return function (array, indices) {
var out = -Infinity;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) out = Math.max(out, vi);
}
return out === -Infinity ? BADNUM : c2d(out);
};
case 'range':
return function (array, indices) {
var min = Infinity;
var max = -Infinity;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) {
min = Math.min(min, vi);
max = Math.max(max, vi);
}
}
return max === -Infinity || min === Infinity ? BADNUM : c2d(max - min);
};
case 'change':
return function (array, indices) {
var first = d2c(array[indices[0]]);
var last = d2c(array[indices[indices.length - 1]]);
return first === BADNUM || last === BADNUM ? BADNUM : c2d(last - first);
};
case 'median':
return function (array, indices) {
var sortCalc = [];
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) sortCalc.push(vi);
}
if (!sortCalc.length) return BADNUM;
sortCalc.sort(Lib.sorterAsc);
var mid = (sortCalc.length - 1) / 2;
return c2d((sortCalc[Math.floor(mid)] + sortCalc[Math.ceil(mid)]) / 2);
};
case 'mode':
return function (array, indices) {
var counts = {};
var maxCnt = 0;
var out = BADNUM;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) {
var counti = counts[vi] = (counts[vi] || 0) + 1;
if (counti > maxCnt) {
maxCnt = counti;
out = vi;
}
}
}
return maxCnt ? c2d(out) : BADNUM;
};
case 'rms':
return function (array, indices) {
var total = 0;
var cnt = 0;
for (var i = 0; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) {
total += vi * vi;
cnt++;
}
}
return cnt ? c2d(Math.sqrt(total / cnt)) : BADNUM;
};
case 'stddev':
return function (array, indices) {
// balance numerical stability with performance:
// so that we call d2c once per element but don't need to
// store them, reference all to the first element
var total = 0;
var total2 = 0;
var cnt = 1;
var v0 = BADNUM;
var i;
for (i = 0; i < indices.length && v0 === BADNUM; i++) {
v0 = d2c(array[indices[i]]);
}
if (v0 === BADNUM) return BADNUM;
for (; i < indices.length; i++) {
var vi = d2c(array[indices[i]]);
if (vi !== BADNUM) {
var dv = vi - v0;
total += dv;
total2 += dv * dv;
cnt++;
}
}
// This is population std dev, if we want sample std dev
// we would need (...) / (cnt - 1)
// Also note there's no c2d here - that means for dates the result
// is a number of milliseconds, and for categories it's a number
// of category differences, which is not generically meaningful but
// as in other cases we don't forbid it.
var norm = opts.funcmode === 'sample' ? cnt - 1 : cnt;
// this is debatable: should a count of 1 return sample stddev of
// 0 or undefined?
if (!norm) return 0;
return Math.sqrt((total2 - total * total / cnt) / norm);
};
}
}
function count(array, indices) {
return indices.length;
}
function first(array, indices) {
return array[indices[0]];
}
function last(array, indices) {
return array[indices[indices.length - 1]];
}
/***/ }),
/***/ 76744:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Registry = __webpack_require__(24040);
var Axes = __webpack_require__(54460);
var pointsAccessorFunction = (__webpack_require__(60468)/* .pointsAccessorFunction */ .W);
var filterOps = __webpack_require__(69104);
var COMPARISON_OPS = filterOps.COMPARISON_OPS;
var INTERVAL_OPS = filterOps.INTERVAL_OPS;
var SET_OPS = filterOps.SET_OPS;
exports.moduleType = 'transform';
exports.name = 'filter';
exports.attributes = {
enabled: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
target: {
valType: 'string',
strict: true,
noBlank: true,
arrayOk: true,
dflt: 'x',
editType: 'calc'
},
operation: {
valType: 'enumerated',
values: [].concat(COMPARISON_OPS).concat(INTERVAL_OPS).concat(SET_OPS),
dflt: '=',
editType: 'calc'
},
value: {
valType: 'any',
dflt: 0,
editType: 'calc'
},
preservegaps: {
valType: 'boolean',
dflt: false,
editType: 'calc'
},
editType: 'calc'
};
exports.supplyDefaults = function (transformIn) {
var transformOut = {};
function coerce(attr, dflt) {
return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt);
}
var enabled = coerce('enabled');
if (enabled) {
var target = coerce('target');
if (Lib.isArrayOrTypedArray(target) && target.length === 0) {
transformOut.enabled = false;
return transformOut;
}
coerce('preservegaps');
coerce('operation');
coerce('value');
var handleCalendarDefaults = Registry.getComponentMethod('calendars', 'handleDefaults');
handleCalendarDefaults(transformIn, transformOut, 'valuecalendar', null);
handleCalendarDefaults(transformIn, transformOut, 'targetcalendar', null);
}
return transformOut;
};
exports.calcTransform = function (gd, trace, opts) {
if (!opts.enabled) return;
var targetArray = Lib.getTargetArray(trace, opts);
if (!targetArray) return;
var target = opts.target;
var len = targetArray.length;
if (trace._length) len = Math.min(len, trace._length);
var targetCalendar = opts.targetcalendar;
var arrayAttrs = trace._arrayAttrs;
var preservegaps = opts.preservegaps;
// even if you provide targetcalendar, if target is a string and there
// is a calendar attribute matching target it will get used instead.
if (typeof target === 'string') {
var attrTargetCalendar = Lib.nestedProperty(trace, target + 'calendar').get();
if (attrTargetCalendar) targetCalendar = attrTargetCalendar;
}
var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray);
var filterFunc = getFilterFunc(opts, d2c, targetCalendar);
var originalArrays = {};
var indexToPoints = {};
var index = 0;
function forAllAttrs(fn, index) {
for (var j = 0; j < arrayAttrs.length; j++) {
var np = Lib.nestedProperty(trace, arrayAttrs[j]);
fn(np, index);
}
}
var initFn;
var fillFn;
if (preservegaps) {
initFn = function (np) {
originalArrays[np.astr] = Lib.extendDeep([], np.get());
np.set(new Array(len));
};
fillFn = function (np, index) {
var val = originalArrays[np.astr][index];
np.get()[index] = val;
};
} else {
initFn = function (np) {
originalArrays[np.astr] = Lib.extendDeep([], np.get());
np.set([]);
};
fillFn = function (np, index) {
var val = originalArrays[np.astr][index];
np.get().push(val);
};
}
// copy all original array attribute values, and clear arrays in trace
forAllAttrs(initFn);
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
// loop through filter array, fill trace arrays if passed
for (var i = 0; i < len; i++) {
var passed = filterFunc(targetArray[i]);
if (passed) {
forAllAttrs(fillFn, i);
indexToPoints[index++] = originalPointsAccessor(i);
} else if (preservegaps) index++;
}
opts._indexToPoints = indexToPoints;
trace._length = index;
};
function getFilterFunc(opts, d2c, targetCalendar) {
var operation = opts.operation;
var value = opts.value;
var hasArrayValue = Lib.isArrayOrTypedArray(value);
function isOperationIn(array) {
return array.indexOf(operation) !== -1;
}
var d2cValue = function (v) {
return d2c(v, 0, opts.valuecalendar);
};
var d2cTarget = function (v) {
return d2c(v, 0, targetCalendar);
};
var coercedValue;
if (isOperationIn(COMPARISON_OPS)) {
coercedValue = hasArrayValue ? d2cValue(value[0]) : d2cValue(value);
} else if (isOperationIn(INTERVAL_OPS)) {
coercedValue = hasArrayValue ? [d2cValue(value[0]), d2cValue(value[1])] : [d2cValue(value), d2cValue(value)];
} else if (isOperationIn(SET_OPS)) {
coercedValue = hasArrayValue ? value.map(d2cValue) : [d2cValue(value)];
}
switch (operation) {
case '=':
return function (v) {
return d2cTarget(v) === coercedValue;
};
case '!=':
return function (v) {
return d2cTarget(v) !== coercedValue;
};
case '<':
return function (v) {
return d2cTarget(v) < coercedValue;
};
case '<=':
return function (v) {
return d2cTarget(v) <= coercedValue;
};
case '>':
return function (v) {
return d2cTarget(v) > coercedValue;
};
case '>=':
return function (v) {
return d2cTarget(v) >= coercedValue;
};
case '[]':
return function (v) {
var cv = d2cTarget(v);
return cv >= coercedValue[0] && cv <= coercedValue[1];
};
case '()':
return function (v) {
var cv = d2cTarget(v);
return cv > coercedValue[0] && cv < coercedValue[1];
};
case '[)':
return function (v) {
var cv = d2cTarget(v);
return cv >= coercedValue[0] && cv < coercedValue[1];
};
case '(]':
return function (v) {
var cv = d2cTarget(v);
return cv > coercedValue[0] && cv <= coercedValue[1];
};
case '][':
return function (v) {
var cv = d2cTarget(v);
return cv <= coercedValue[0] || cv >= coercedValue[1];
};
case ')(':
return function (v) {
var cv = d2cTarget(v);
return cv < coercedValue[0] || cv > coercedValue[1];
};
case '](':
return function (v) {
var cv = d2cTarget(v);
return cv <= coercedValue[0] || cv > coercedValue[1];
};
case ')[':
return function (v) {
var cv = d2cTarget(v);
return cv < coercedValue[0] || cv >= coercedValue[1];
};
case '{}':
return function (v) {
return coercedValue.indexOf(d2cTarget(v)) !== -1;
};
case '}{':
return function (v) {
return coercedValue.indexOf(d2cTarget(v)) === -1;
};
}
}
/***/ }),
/***/ 32028:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var PlotSchema = __webpack_require__(73060);
var Plots = __webpack_require__(7316);
var pointsAccessorFunction = (__webpack_require__(60468)/* .pointsAccessorFunction */ .W);
exports.moduleType = 'transform';
exports.name = 'groupby';
exports.attributes = {
enabled: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
groups: {
valType: 'data_array',
dflt: [],
editType: 'calc'
},
nameformat: {
valType: 'string',
editType: 'calc'
},
styles: {
_isLinkedToArray: 'style',
target: {
valType: 'string',
editType: 'calc'
},
value: {
valType: 'any',
dflt: {},
editType: 'calc',
_compareAsJSON: true
},
editType: 'calc'
},
editType: 'calc'
};
/**
* Supply transform attributes defaults
*
* @param {object} transformIn
* object linked to trace.transforms[i] with 'type' set to exports.name
* @param {object} traceOut
* the _fullData trace this transform applies to
* @param {object} layout
* the plot's (not-so-full) layout
* @param {object} traceIn
* the input data trace this transform applies to
*
* @return {object} transformOut
* copy of transformIn that contains attribute defaults
*/
exports.supplyDefaults = function (transformIn, traceOut, layout) {
var i;
var transformOut = {};
function coerce(attr, dflt) {
return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt);
}
var enabled = coerce('enabled');
if (!enabled) return transformOut;
coerce('groups');
coerce('nameformat', layout._dataLength > 1 ? '%{group} (%{trace})' : '%{group}');
var styleIn = transformIn.styles;
var styleOut = transformOut.styles = [];
if (styleIn) {
for (i = 0; i < styleIn.length; i++) {
var thisStyle = styleOut[i] = {};
Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'target');
var value = Lib.coerce(styleIn[i], styleOut[i], exports.attributes.styles, 'value');
// so that you can edit value in place and have Plotly.react notice it, or
// rebuild it every time and have Plotly.react NOT think it changed:
// use _compareAsJSON to say we should diff the _JSON_value
if (Lib.isPlainObject(value)) thisStyle.value = Lib.extendDeep({}, value);else if (value) delete thisStyle.value;
}
}
return transformOut;
};
/**
* Apply transform !!!
*
* @param {array} data
* array of transformed traces (is [fullTrace] upon first transform)
*
* @param {object} state
* state object which includes:
* - transform {object} full transform attributes
* - fullTrace {object} full trace object which is being transformed
* - fullData {array} full pre-transform(s) data array
* - layout {object} the plot's (not-so-full) layout
*
* @return {object} newData
* array of transformed traces
*/
exports.transform = function (data, state) {
var newTraces, i, j;
var newData = [];
for (i = 0; i < data.length; i++) {
newTraces = transformOne(data[i], state);
for (j = 0; j < newTraces.length; j++) {
newData.push(newTraces[j]);
}
}
return newData;
};
function transformOne(trace, state) {
var i, j, k, attr, srcArray, groupName, newTrace, transforms, arrayLookup;
var groupNameObj;
var opts = state.transform;
var transformIndex = state.transformIndex;
var groups = trace.transforms[transformIndex].groups;
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
if (!Lib.isArrayOrTypedArray(groups) || groups.length === 0) {
return [trace];
}
var groupNames = Lib.filterUnique(groups);
var newData = new Array(groupNames.length);
var len = groups.length;
var arrayAttrs = PlotSchema.findArrayAttributes(trace);
var styles = opts.styles || [];
var styleLookup = {};
for (i = 0; i < styles.length; i++) {
styleLookup[styles[i].target] = styles[i].value;
}
if (opts.styles) {
groupNameObj = Lib.keyedContainer(opts, 'styles', 'target', 'value.name');
}
// An index to map group name --> expanded trace index
var indexLookup = {};
var indexCnts = {};
for (i = 0; i < groupNames.length; i++) {
groupName = groupNames[i];
indexLookup[groupName] = i;
indexCnts[groupName] = 0;
// Start with a deep extend that just copies array references.
newTrace = newData[i] = Lib.extendDeepNoArrays({}, trace);
newTrace._group = groupName;
newTrace.transforms[transformIndex]._indexToPoints = {};
var suppliedName = null;
if (groupNameObj) {
suppliedName = groupNameObj.get(groupName);
}
if (suppliedName || suppliedName === '') {
newTrace.name = suppliedName;
} else {
newTrace.name = Lib.templateString(opts.nameformat, {
trace: trace.name,
group: groupName
});
}
// In order for groups to apply correctly to other transform data (e.g.
// a filter transform), we have to break the connection and clone the
// transforms so that each group writes grouped values into a different
// destination. This function does not break the array reference
// connection between the split transforms it creates. That's handled in
// initialize, which creates a new empty array for each arrayAttr.
transforms = newTrace.transforms;
newTrace.transforms = [];
for (j = 0; j < transforms.length; j++) {
newTrace.transforms[j] = Lib.extendDeepNoArrays({}, transforms[j]);
}
// Initialize empty arrays for the arrayAttrs, to be split in the next step
for (j = 0; j < arrayAttrs.length; j++) {
Lib.nestedProperty(newTrace, arrayAttrs[j]).set([]);
}
}
// For each array attribute including those nested inside this and other
// transforms (small note that we technically only need to do this for
// transforms that have not yet been applied):
for (k = 0; k < arrayAttrs.length; k++) {
attr = arrayAttrs[k];
// Cache all the arrays to which we'll push:
for (j = 0, arrayLookup = []; j < groupNames.length; j++) {
arrayLookup[j] = Lib.nestedProperty(newData[j], attr).get();
}
// Get the input data:
srcArray = Lib.nestedProperty(trace, attr).get();
// Send each data point to the appropriate expanded trace:
for (j = 0; j < len; j++) {
// Map group data --> trace index --> array and push data onto it
arrayLookup[indexLookup[groups[j]]].push(srcArray[j]);
}
}
for (j = 0; j < len; j++) {
newTrace = newData[indexLookup[groups[j]]];
var indexToPoints = newTrace.transforms[transformIndex]._indexToPoints;
indexToPoints[indexCnts[groups[j]]] = originalPointsAccessor(j);
indexCnts[groups[j]]++;
}
for (i = 0; i < groupNames.length; i++) {
groupName = groupNames[i];
newTrace = newData[i];
Plots.clearExpandedTraceDefaultColors(newTrace);
// there's no need to coerce styleLookup[groupName] here
// as another round of supplyDefaults is done on the transformed traces
newTrace = Lib.extendDeepNoArrays(newTrace, styleLookup[groupName] || {});
}
return newData;
}
/***/ }),
/***/ 60468:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
exports.W = function (transforms, opts) {
var tr;
var prevIndexToPoints;
for (var i = 0; i < transforms.length; i++) {
tr = transforms[i];
if (tr === opts) break;
if (!tr._indexToPoints || tr.enabled === false) continue;
prevIndexToPoints = tr._indexToPoints;
}
var originalPointsAccessor = prevIndexToPoints ? function (i) {
return prevIndexToPoints[i];
} : function (i) {
return [i];
};
return originalPointsAccessor;
};
/***/ }),
/***/ 76272:
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
"use strict";
var Lib = __webpack_require__(3400);
var Axes = __webpack_require__(54460);
var pointsAccessorFunction = (__webpack_require__(60468)/* .pointsAccessorFunction */ .W);
var BADNUM = (__webpack_require__(39032).BADNUM);
exports.moduleType = 'transform';
exports.name = 'sort';
exports.attributes = {
enabled: {
valType: 'boolean',
dflt: true,
editType: 'calc'
},
target: {
valType: 'string',
strict: true,
noBlank: true,
arrayOk: true,
dflt: 'x',
editType: 'calc'
},
order: {
valType: 'enumerated',
values: ['ascending', 'descending'],
dflt: 'ascending',
editType: 'calc'
},
editType: 'calc'
};
exports.supplyDefaults = function (transformIn) {
var transformOut = {};
function coerce(attr, dflt) {
return Lib.coerce(transformIn, transformOut, exports.attributes, attr, dflt);
}
var enabled = coerce('enabled');
if (enabled) {
coerce('target');
coerce('order');
}
return transformOut;
};
exports.calcTransform = function (gd, trace, opts) {
if (!opts.enabled) return;
var targetArray = Lib.getTargetArray(trace, opts);
if (!targetArray) return;
var target = opts.target;
var len = targetArray.length;
if (trace._length) len = Math.min(len, trace._length);
var arrayAttrs = trace._arrayAttrs;
var d2c = Axes.getDataToCoordFunc(gd, trace, target, targetArray);
var indices = getIndices(opts, targetArray, d2c, len);
var originalPointsAccessor = pointsAccessorFunction(trace.transforms, opts);
var indexToPoints = {};
var i, j;
for (i = 0; i < arrayAttrs.length; i++) {
var np = Lib.nestedProperty(trace, arrayAttrs[i]);
var arrayOld = np.get();
var arrayNew = new Array(len);
for (j = 0; j < len; j++) {
arrayNew[j] = arrayOld[indices[j]];
}
np.set(arrayNew);
}
for (j = 0; j < len; j++) {
indexToPoints[j] = originalPointsAccessor(indices[j]);
}
opts._indexToPoints = indexToPoints;
trace._length = len;
};
function getIndices(opts, targetArray, d2c, len) {
var sortedArray = new Array(len);
var indices = new Array(len);
var i;
for (i = 0; i < len; i++) {
sortedArray[i] = {
v: targetArray[i],
i: i
};
}
sortedArray.sort(getSortFunc(opts, d2c));
for (i = 0; i < len; i++) {
indices[i] = sortedArray[i].i;
}
return indices;
}
function getSortFunc(opts, d2c) {
switch (opts.order) {
case 'ascending':
return function (a, b) {
var ac = d2c(a.v);
var bc = d2c(b.v);
if (ac === BADNUM) {
return 1;
}
if (bc === BADNUM) {
return -1;
}
return ac - bc;
};
case 'descending':
return function (a, b) {
var ac = d2c(a.v);
var bc = d2c(b.v);
if (ac === BADNUM) {
return 1;
}
if (bc === BADNUM) {
return -1;
}
return bc - ac;
};
}
}
/***/ }),
/***/ 25788:
/***/ (function(__unused_webpack_module, exports) {
"use strict";
// package version injected by `npm run preprocess`
exports.version = '2.31.0';
/***/ }),
/***/ 67792:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
/* provided dependency */ var process = __webpack_require__(4168);
/******/(function(){// webpackBootstrap
/******/var __webpack_modules__={/***/1964:/***/function(module,__unused_webpack_exports,__nested_webpack_require_129__){module.exports={alpha_shape:__nested_webpack_require_129__(3502),convex_hull:__nested_webpack_require_129__(7352),delaunay_triangulate:__nested_webpack_require_129__(7642),gl_cone3d:__nested_webpack_require_129__(6405),gl_error3d:__nested_webpack_require_129__(9165),gl_heatmap2d:__nested_webpack_require_129__(2510),gl_line3d:__nested_webpack_require_129__(5714),gl_mesh3d:__nested_webpack_require_129__(7201),gl_plot2d:__nested_webpack_require_129__(1850),gl_plot3d:__nested_webpack_require_129__(4100),gl_pointcloud2d:__nested_webpack_require_129__(4696),gl_scatter3d:__nested_webpack_require_129__(8418),gl_select_box:__nested_webpack_require_129__(3161),gl_spikes2d:__nested_webpack_require_129__(4098),gl_streamtube3d:__nested_webpack_require_129__(7815),gl_surface3d:__nested_webpack_require_129__(9499),ndarray:__nested_webpack_require_129__(9618),ndarray_linear_interpolate:__nested_webpack_require_129__(4317)};/***/},/***/4793:/***/function(__unused_webpack_module,exports,__nested_webpack_require_936__){"use strict";var __webpack_unused_export__;/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh
* @license MIT
*/ /* eslint-disable no-proto */function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;iK_MAX_LENGTH){throw new RangeError('The value "'+length+'" is invalid for option "size"');}// Return an augmented `Uint8Array` instance
var buf=new Uint8Array(length);Object.setPrototypeOf(buf,Buffer.prototype);return buf;}/**
* The Buffer constructor returns instances of `Uint8Array` that have their
* prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
* `Uint8Array`, so the returned instances will have all the node `Buffer` methods
* and the `Uint8Array` methods. Square bracket notation works as expected -- it
* returns a single octet.
*
* The `Uint8Array` prototype remains unmodified.
*/function Buffer(arg,encodingOrOffset,length){// Common case.
if(typeof arg==='number'){if(typeof encodingOrOffset==='string'){throw new TypeError('The "string" argument must be of type string. Received type number');}return allocUnsafe(arg);}return from(arg,encodingOrOffset,length);}Buffer.poolSize=8192;// not used by this implementation
function from(value,encodingOrOffset,length){if(typeof value==='string'){return fromString(value,encodingOrOffset);}if(ArrayBuffer.isView(value)){return fromArrayView(value);}if(value==null){throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, '+'or Array-like Object. Received type '+_typeof(value));}if(isInstance(value,ArrayBuffer)||value&&isInstance(value.buffer,ArrayBuffer)){return fromArrayBuffer(value,encodingOrOffset,length);}if(typeof SharedArrayBuffer!=='undefined'&&(isInstance(value,SharedArrayBuffer)||value&&isInstance(value.buffer,SharedArrayBuffer))){return fromArrayBuffer(value,encodingOrOffset,length);}if(typeof value==='number'){throw new TypeError('The "value" argument must not be of type number. Received type number');}var valueOf=value.valueOf&&value.valueOf();if(valueOf!=null&&valueOf!==value){return Buffer.from(valueOf,encodingOrOffset,length);}var b=fromObject(value);if(b)return b;if(typeof Symbol!=='undefined'&&Symbol.toPrimitive!=null&&typeof value[Symbol.toPrimitive]==='function'){return Buffer.from(value[Symbol.toPrimitive]('string'),encodingOrOffset,length);}throw new TypeError('The first argument must be one of type string, Buffer, ArrayBuffer, Array, '+'or Array-like Object. Received type '+_typeof(value));}/**
* Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
* if value is a number.
* Buffer.from(str[, encoding])
* Buffer.from(array)
* Buffer.from(buffer)
* Buffer.from(arrayBuffer[, byteOffset[, length]])
**/Buffer.from=function(value,encodingOrOffset,length){return from(value,encodingOrOffset,length);};// Note: Change prototype *after* Buffer.from is defined to workaround Chrome bug:
// https://github.com/feross/buffer/pull/148
Object.setPrototypeOf(Buffer.prototype,Uint8Array.prototype);Object.setPrototypeOf(Buffer,Uint8Array);function assertSize(size){if(typeof size!=='number'){throw new TypeError('"size" argument must be of type number');}else if(size<0){throw new RangeError('The value "'+size+'" is invalid for option "size"');}}function alloc(size,fill,encoding){assertSize(size);if(size<=0){return createBuffer(size);}if(fill!==undefined){// Only pay attention to encoding if it's a string. This
// prevents accidentally sending in a number that would
// be interpreted as a start offset.
return typeof encoding==='string'?createBuffer(size).fill(fill,encoding):createBuffer(size).fill(fill);}return createBuffer(size);}/**
* Creates a new filled Buffer instance.
* alloc(size[, fill[, encoding]])
**/Buffer.alloc=function(size,fill,encoding){return alloc(size,fill,encoding);};function allocUnsafe(size){assertSize(size);return createBuffer(size<0?0:checked(size)|0);}/**
* Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
* */Buffer.allocUnsafe=function(size){return allocUnsafe(size);};/**
* Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
*/Buffer.allocUnsafeSlow=function(size){return allocUnsafe(size);};function fromString(string,encoding){if(typeof encoding!=='string'||encoding===''){encoding='utf8';}if(!Buffer.isEncoding(encoding)){throw new TypeError('Unknown encoding: '+encoding);}var length=byteLength(string,encoding)|0;var buf=createBuffer(length);var actual=buf.write(string,encoding);if(actual!==length){// Writing a hex string, for example, that contains invalid characters will
// cause everything after the first invalid character to be ignored. (e.g.
// 'abxxcd' will be treated as 'ab')
buf=buf.slice(0,actual);}return buf;}function fromArrayLike(array){var length=array.length<0?0:checked(array.length)|0;var buf=createBuffer(length);for(var i=0;i=K_MAX_LENGTH){throw new RangeError('Attempt to allocate Buffer larger than maximum '+'size: 0x'+K_MAX_LENGTH.toString(16)+' bytes');}return length|0;}function SlowBuffer(length){if(+length!=length){// eslint-disable-line eqeqeq
length=0;}return Buffer.alloc(+length);}Buffer.isBuffer=function isBuffer(b){return b!=null&&b._isBuffer===true&&b!==Buffer.prototype;// so Buffer.isBuffer(Buffer.prototype) will be false
};Buffer.compare=function compare(a,b){if(isInstance(a,Uint8Array))a=Buffer.from(a,a.offset,a.byteLength);if(isInstance(b,Uint8Array))b=Buffer.from(b,b.offset,b.byteLength);if(!Buffer.isBuffer(a)||!Buffer.isBuffer(b)){throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');}if(a===b)return 0;var x=a.length;var y=b.length;for(var i=0,len=Math.min(x,y);ibuffer.length){if(!Buffer.isBuffer(buf))buf=Buffer.from(buf);buf.copy(buffer,pos);}else{Uint8Array.prototype.set.call(buffer,buf,pos);}}else if(!Buffer.isBuffer(buf)){throw new TypeError('"list" argument must be an Array of Buffers');}else{buf.copy(buffer,pos);}pos+=buf.length;}return buffer;};function byteLength(string,encoding){if(Buffer.isBuffer(string)){return string.length;}if(ArrayBuffer.isView(string)||isInstance(string,ArrayBuffer)){return string.byteLength;}if(typeof string!=='string'){throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. '+'Received type '+_typeof(string));}var len=string.length;var mustMatch=arguments.length>2&&arguments[2]===true;if(!mustMatch&&len===0)return 0;// Use a for loop to avoid recursion
var loweredCase=false;for(;;){switch(encoding){case'ascii':case'latin1':case'binary':return len;case'utf8':case'utf-8':return utf8ToBytes(string).length;case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return len*2;case'hex':return len>>>1;case'base64':return base64ToBytes(string).length;default:if(loweredCase){return mustMatch?-1:utf8ToBytes(string).length;// assume utf8
}encoding=(''+encoding).toLowerCase();loweredCase=true;}}}Buffer.byteLength=byteLength;function slowToString(encoding,start,end){var loweredCase=false;// No need to verify that "this.length <= MAX_UINT32" since it's a read-only
// property of a typed array.
// This behaves neither like String nor Uint8Array in that we set start/end
// to their upper/lower bounds if the value passed is out of range.
// undefined is handled specially as per ECMA-262 6th Edition,
// Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
if(start===undefined||start<0){start=0;}// Return early if start > this.length. Done here to prevent potential uint32
// coercion fail below.
if(start>this.length){return'';}if(end===undefined||end>this.length){end=this.length;}if(end<=0){return'';}// Force coercion to uint32. This will also coerce falsey/NaN values to 0.
end>>>=0;start>>>=0;if(end<=start){return'';}if(!encoding)encoding='utf8';while(true){switch(encoding){case'hex':return hexSlice(this,start,end);case'utf8':case'utf-8':return utf8Slice(this,start,end);case'ascii':return asciiSlice(this,start,end);case'latin1':case'binary':return latin1Slice(this,start,end);case'base64':return base64Slice(this,start,end);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return utf16leSlice(this,start,end);default:if(loweredCase)throw new TypeError('Unknown encoding: '+encoding);encoding=(encoding+'').toLowerCase();loweredCase=true;}}}// This property is used by `Buffer.isBuffer` (and the `is-buffer` npm package)
// to detect a Buffer instance. It's not possible to use `instanceof Buffer`
// reliably in a browserify context because there could be multiple different
// copies of the 'buffer' package in use. This method works even for Buffer
// instances that were created from another copy of the `buffer` package.
// See: https://github.com/feross/buffer/issues/154
Buffer.prototype._isBuffer=true;function swap(b,n,m){var i=b[n];b[n]=b[m];b[m]=i;}Buffer.prototype.swap16=function swap16(){var len=this.length;if(len%2!==0){throw new RangeError('Buffer size must be a multiple of 16-bits');}for(var i=0;imax)str+=' ... ';return'';};if(customInspectSymbol){Buffer.prototype[customInspectSymbol]=Buffer.prototype.inspect;}Buffer.prototype.compare=function compare(target,start,end,thisStart,thisEnd){if(isInstance(target,Uint8Array)){target=Buffer.from(target,target.offset,target.byteLength);}if(!Buffer.isBuffer(target)){throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. '+'Received type '+_typeof(target));}if(start===undefined){start=0;}if(end===undefined){end=target?target.length:0;}if(thisStart===undefined){thisStart=0;}if(thisEnd===undefined){thisEnd=this.length;}if(start<0||end>target.length||thisStart<0||thisEnd>this.length){throw new RangeError('out of range index');}if(thisStart>=thisEnd&&start>=end){return 0;}if(thisStart>=thisEnd){return-1;}if(start>=end){return 1;}start>>>=0;end>>>=0;thisStart>>>=0;thisEnd>>>=0;if(this===target)return 0;var x=thisEnd-thisStart;var y=end-start;var len=Math.min(x,y);var thisCopy=this.slice(thisStart,thisEnd);var targetCopy=target.slice(start,end);for(var i=0;i= `byteOffset`,
// OR the last index of `val` in `buffer` at offset <= `byteOffset`.
//
// Arguments:
// - buffer - a Buffer to search
// - val - a string, Buffer, or number
// - byteOffset - an index into `buffer`; will be clamped to an int32
// - encoding - an optional encoding, relevant is val is a string
// - dir - true for indexOf, false for lastIndexOf
function bidirectionalIndexOf(buffer,val,byteOffset,encoding,dir){// Empty buffer means no match
if(buffer.length===0)return-1;// Normalize byteOffset
if(typeof byteOffset==='string'){encoding=byteOffset;byteOffset=0;}else if(byteOffset>0x7fffffff){byteOffset=0x7fffffff;}else if(byteOffset<-0x80000000){byteOffset=-0x80000000;}byteOffset=+byteOffset;// Coerce to Number.
if(numberIsNaN(byteOffset)){// byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
byteOffset=dir?0:buffer.length-1;}// Normalize byteOffset: negative offsets start from the end of the buffer
if(byteOffset<0)byteOffset=buffer.length+byteOffset;if(byteOffset>=buffer.length){if(dir)return-1;else byteOffset=buffer.length-1;}else if(byteOffset<0){if(dir)byteOffset=0;else return-1;}// Normalize val
if(typeof val==='string'){val=Buffer.from(val,encoding);}// Finally, search either indexOf (if dir is true) or lastIndexOf
if(Buffer.isBuffer(val)){// Special case: looking for empty string/buffer always fails
if(val.length===0){return-1;}return arrayIndexOf(buffer,val,byteOffset,encoding,dir);}else if(typeof val==='number'){val=val&0xFF;// Search for a byte value [0-255]
if(typeof Uint8Array.prototype.indexOf==='function'){if(dir){return Uint8Array.prototype.indexOf.call(buffer,val,byteOffset);}else{return Uint8Array.prototype.lastIndexOf.call(buffer,val,byteOffset);}}return arrayIndexOf(buffer,[val],byteOffset,encoding,dir);}throw new TypeError('val must be string, number or Buffer');}function arrayIndexOf(arr,val,byteOffset,encoding,dir){var indexSize=1;var arrLength=arr.length;var valLength=val.length;if(encoding!==undefined){encoding=String(encoding).toLowerCase();if(encoding==='ucs2'||encoding==='ucs-2'||encoding==='utf16le'||encoding==='utf-16le'){if(arr.length<2||val.length<2){return-1;}indexSize=2;arrLength/=2;valLength/=2;byteOffset/=2;}}function read(buf,i){if(indexSize===1){return buf[i];}else{return buf.readUInt16BE(i*indexSize);}}var i;if(dir){var foundIndex=-1;for(i=byteOffset;iarrLength)byteOffset=arrLength-valLength;for(i=byteOffset;i>=0;i--){var found=true;for(var j=0;jremaining){length=remaining;}}var strLen=string.length;if(length>strLen/2){length=strLen/2;}var i;for(i=0;i>>0;if(isFinite(length)){length=length>>>0;if(encoding===undefined)encoding='utf8';}else{encoding=length;length=undefined;}}else{throw new Error('Buffer.write(string, encoding, offset[, length]) is no longer supported');}var remaining=this.length-offset;if(length===undefined||length>remaining)length=remaining;if(string.length>0&&(length<0||offset<0)||offset>this.length){throw new RangeError('Attempt to write outside buffer bounds');}if(!encoding)encoding='utf8';var loweredCase=false;for(;;){switch(encoding){case'hex':return hexWrite(this,string,offset,length);case'utf8':case'utf-8':return utf8Write(this,string,offset,length);case'ascii':case'latin1':case'binary':return asciiWrite(this,string,offset,length);case'base64':// Warning: maxLength not taken into account in base64Write
return base64Write(this,string,offset,length);case'ucs2':case'ucs-2':case'utf16le':case'utf-16le':return ucs2Write(this,string,offset,length);default:if(loweredCase)throw new TypeError('Unknown encoding: '+encoding);encoding=(''+encoding).toLowerCase();loweredCase=true;}}};Buffer.prototype.toJSON=function toJSON(){return{type:'Buffer',data:Array.prototype.slice.call(this._arr||this,0)};};function base64Slice(buf,start,end){if(start===0&&end===buf.length){return base64.fromByteArray(buf);}else{return base64.fromByteArray(buf.slice(start,end));}}function utf8Slice(buf,start,end){end=Math.min(buf.length,end);var res=[];var i=start;while(i0xEF?4:firstByte>0xDF?3:firstByte>0xBF?2:1;if(i+bytesPerSequence<=end){var secondByte=void 0,thirdByte=void 0,fourthByte=void 0,tempCodePoint=void 0;switch(bytesPerSequence){case 1:if(firstByte<0x80){codePoint=firstByte;}break;case 2:secondByte=buf[i+1];if((secondByte&0xC0)===0x80){tempCodePoint=(firstByte&0x1F)<<0x6|secondByte&0x3F;if(tempCodePoint>0x7F){codePoint=tempCodePoint;}}break;case 3:secondByte=buf[i+1];thirdByte=buf[i+2];if((secondByte&0xC0)===0x80&&(thirdByte&0xC0)===0x80){tempCodePoint=(firstByte&0xF)<<0xC|(secondByte&0x3F)<<0x6|thirdByte&0x3F;if(tempCodePoint>0x7FF&&(tempCodePoint<0xD800||tempCodePoint>0xDFFF)){codePoint=tempCodePoint;}}break;case 4:secondByte=buf[i+1];thirdByte=buf[i+2];fourthByte=buf[i+3];if((secondByte&0xC0)===0x80&&(thirdByte&0xC0)===0x80&&(fourthByte&0xC0)===0x80){tempCodePoint=(firstByte&0xF)<<0x12|(secondByte&0x3F)<<0xC|(thirdByte&0x3F)<<0x6|fourthByte&0x3F;if(tempCodePoint>0xFFFF&&tempCodePoint<0x110000){codePoint=tempCodePoint;}}}}if(codePoint===null){// we did not generate a valid codePoint so insert a
// replacement char (U+FFFD) and advance only 1 byte
codePoint=0xFFFD;bytesPerSequence=1;}else if(codePoint>0xFFFF){// encode to utf16 (surrogate pair dance)
codePoint-=0x10000;res.push(codePoint>>>10&0x3FF|0xD800);codePoint=0xDC00|codePoint&0x3FF;}res.push(codePoint);i+=bytesPerSequence;}return decodeCodePointsArray(res);}// Based on http://stackoverflow.com/a/22747272/680742, the browser with
// the lowest limit is Chrome, with 0x10000 args.
// We go 1 magnitude less, for safety
var MAX_ARGUMENTS_LENGTH=0x1000;function decodeCodePointsArray(codePoints){var len=codePoints.length;if(len<=MAX_ARGUMENTS_LENGTH){return String.fromCharCode.apply(String,codePoints);// avoid extra slice()
}// Decode in chunks to avoid "call stack size exceeded".
var res='';var i=0;while(ilen)end=len;var out='';for(var i=start;ilen){start=len;}if(end<0){end+=len;if(end<0)end=0;}else if(end>len){end=len;}if(endlength)throw new RangeError('Trying to access beyond buffer length');}Buffer.prototype.readUintLE=Buffer.prototype.readUIntLE=function readUIntLE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){checkOffset(offset,byteLength,this.length);}var val=this[offset+--byteLength];var mul=1;while(byteLength>0&&(mul*=0x100)){val+=this[offset+--byteLength]*mul;}return val;};Buffer.prototype.readUint8=Buffer.prototype.readUInt8=function readUInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);return this[offset];};Buffer.prototype.readUint16LE=Buffer.prototype.readUInt16LE=function readUInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]|this[offset+1]<<8;};Buffer.prototype.readUint16BE=Buffer.prototype.readUInt16BE=function readUInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);return this[offset]<<8|this[offset+1];};Buffer.prototype.readUint32LE=Buffer.prototype.readUInt32LE=function readUInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return(this[offset]|this[offset+1]<<8|this[offset+2]<<16)+this[offset+3]*0x1000000;};Buffer.prototype.readUint32BE=Buffer.prototype.readUInt32BE=function readUInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]*0x1000000+(this[offset+1]<<16|this[offset+2]<<8|this[offset+3]);};Buffer.prototype.readBigUInt64LE=defineBigIntMethod(function readBigUInt64LE(offset){offset=offset>>>0;validateNumber(offset,'offset');var first=this[offset];var last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}var lo=first+this[++offset]*Math.pow(2,8)+this[++offset]*Math.pow(2,16)+this[++offset]*Math.pow(2,24);var hi=this[++offset]+this[++offset]*Math.pow(2,8)+this[++offset]*Math.pow(2,16)+last*Math.pow(2,24);return BigInt(lo)+(BigInt(hi)<>>0;validateNumber(offset,'offset');var first=this[offset];var last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}var hi=first*Math.pow(2,24)+this[++offset]*Math.pow(2,16)+this[++offset]*Math.pow(2,8)+this[++offset];var lo=this[++offset]*Math.pow(2,24)+this[++offset]*Math.pow(2,16)+this[++offset]*Math.pow(2,8)+last;return(BigInt(hi)<>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var val=this[offset];var mul=1;var i=0;while(++i=mul)val-=Math.pow(2,8*byteLength);return val;};Buffer.prototype.readIntBE=function readIntBE(offset,byteLength,noAssert){offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert)checkOffset(offset,byteLength,this.length);var i=byteLength;var mul=1;var val=this[offset+--i];while(i>0&&(mul*=0x100)){val+=this[offset+--i]*mul;}mul*=0x80;if(val>=mul)val-=Math.pow(2,8*byteLength);return val;};Buffer.prototype.readInt8=function readInt8(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,1,this.length);if(!(this[offset]&0x80))return this[offset];return(0xff-this[offset]+1)*-1;};Buffer.prototype.readInt16LE=function readInt16LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset]|this[offset+1]<<8;return val&0x8000?val|0xFFFF0000:val;};Buffer.prototype.readInt16BE=function readInt16BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,2,this.length);var val=this[offset+1]|this[offset]<<8;return val&0x8000?val|0xFFFF0000:val;};Buffer.prototype.readInt32LE=function readInt32LE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]|this[offset+1]<<8|this[offset+2]<<16|this[offset+3]<<24;};Buffer.prototype.readInt32BE=function readInt32BE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return this[offset]<<24|this[offset+1]<<16|this[offset+2]<<8|this[offset+3];};Buffer.prototype.readBigInt64LE=defineBigIntMethod(function readBigInt64LE(offset){offset=offset>>>0;validateNumber(offset,'offset');var first=this[offset];var last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}var val=this[offset+4]+this[offset+5]*Math.pow(2,8)+this[offset+6]*Math.pow(2,16)+(last<<24);// Overflow
return(BigInt(val)<>>0;validateNumber(offset,'offset');var first=this[offset];var last=this[offset+7];if(first===undefined||last===undefined){boundsError(offset,this.length-8);}var val=(first<<24)+// Overflow
this[++offset]*Math.pow(2,16)+this[++offset]*Math.pow(2,8)+this[++offset];return(BigInt(val)<>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,true,23,4);};Buffer.prototype.readFloatBE=function readFloatBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,4,this.length);return ieee754.read(this,offset,false,23,4);};Buffer.prototype.readDoubleLE=function readDoubleLE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,true,52,8);};Buffer.prototype.readDoubleBE=function readDoubleBE(offset,noAssert){offset=offset>>>0;if(!noAssert)checkOffset(offset,8,this.length);return ieee754.read(this,offset,false,52,8);};function checkInt(buf,value,offset,ext,max,min){if(!Buffer.isBuffer(buf))throw new TypeError('"buffer" argument must be a Buffer instance');if(value>max||valuebuf.length)throw new RangeError('Index out of range');}Buffer.prototype.writeUintLE=Buffer.prototype.writeUIntLE=function writeUIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0);}var mul=1;var i=0;this[offset]=value&0xFF;while(++i>>0;byteLength=byteLength>>>0;if(!noAssert){var maxBytes=Math.pow(2,8*byteLength)-1;checkInt(this,value,offset,byteLength,maxBytes,0);}var i=byteLength-1;var mul=1;this[offset+i]=value&0xFF;while(--i>=0&&(mul*=0x100)){this[offset+i]=value/mul&0xFF;}return offset+byteLength;};Buffer.prototype.writeUint8=Buffer.prototype.writeUInt8=function writeUInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,0xff,0);this[offset]=value&0xff;return offset+1;};Buffer.prototype.writeUint16LE=Buffer.prototype.writeUInt16LE=function writeUInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0xffff,0);this[offset]=value&0xff;this[offset+1]=value>>>8;return offset+2;};Buffer.prototype.writeUint16BE=Buffer.prototype.writeUInt16BE=function writeUInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0xffff,0);this[offset]=value>>>8;this[offset+1]=value&0xff;return offset+2;};Buffer.prototype.writeUint32LE=Buffer.prototype.writeUInt32LE=function writeUInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0xffffffff,0);this[offset+3]=value>>>24;this[offset+2]=value>>>16;this[offset+1]=value>>>8;this[offset]=value&0xff;return offset+4;};Buffer.prototype.writeUint32BE=Buffer.prototype.writeUInt32BE=function writeUInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0xffffffff,0);this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&0xff;return offset+4;};function wrtBigUInt64LE(buf,value,offset,min,max){checkIntBI(value,min,max,buf,offset,7);var lo=Number(value&BigInt(0xffffffff));buf[offset++]=lo;lo=lo>>8;buf[offset++]=lo;lo=lo>>8;buf[offset++]=lo;lo=lo>>8;buf[offset++]=lo;var hi=Number(value>>BigInt(32)&BigInt(0xffffffff));buf[offset++]=hi;hi=hi>>8;buf[offset++]=hi;hi=hi>>8;buf[offset++]=hi;hi=hi>>8;buf[offset++]=hi;return offset;}function wrtBigUInt64BE(buf,value,offset,min,max){checkIntBI(value,min,max,buf,offset,7);var lo=Number(value&BigInt(0xffffffff));buf[offset+7]=lo;lo=lo>>8;buf[offset+6]=lo;lo=lo>>8;buf[offset+5]=lo;lo=lo>>8;buf[offset+4]=lo;var hi=Number(value>>BigInt(32)&BigInt(0xffffffff));buf[offset+3]=hi;hi=hi>>8;buf[offset+2]=hi;hi=hi>>8;buf[offset+1]=hi;hi=hi>>8;buf[offset]=hi;return offset+8;}Buffer.prototype.writeBigUInt64LE=defineBigIntMethod(function writeBigUInt64LE(value){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return wrtBigUInt64LE(this,value,offset,BigInt(0),BigInt('0xffffffffffffffff'));});Buffer.prototype.writeBigUInt64BE=defineBigIntMethod(function writeBigUInt64BE(value){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return wrtBigUInt64BE(this,value,offset,BigInt(0),BigInt('0xffffffffffffffff'));});Buffer.prototype.writeIntLE=function writeIntLE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit);}var i=0;var mul=1;var sub=0;this[offset]=value&0xFF;while(++i>0)-sub&0xFF;}return offset+byteLength;};Buffer.prototype.writeIntBE=function writeIntBE(value,offset,byteLength,noAssert){value=+value;offset=offset>>>0;if(!noAssert){var limit=Math.pow(2,8*byteLength-1);checkInt(this,value,offset,byteLength,limit-1,-limit);}var i=byteLength-1;var mul=1;var sub=0;this[offset+i]=value&0xFF;while(--i>=0&&(mul*=0x100)){if(value<0&&sub===0&&this[offset+i+1]!==0){sub=1;}this[offset+i]=(value/mul>>0)-sub&0xFF;}return offset+byteLength;};Buffer.prototype.writeInt8=function writeInt8(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,1,0x7f,-0x80);if(value<0)value=0xff+value+1;this[offset]=value&0xff;return offset+1;};Buffer.prototype.writeInt16LE=function writeInt16LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0x7fff,-0x8000);this[offset]=value&0xff;this[offset+1]=value>>>8;return offset+2;};Buffer.prototype.writeInt16BE=function writeInt16BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,2,0x7fff,-0x8000);this[offset]=value>>>8;this[offset+1]=value&0xff;return offset+2;};Buffer.prototype.writeInt32LE=function writeInt32LE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0x7fffffff,-0x80000000);this[offset]=value&0xff;this[offset+1]=value>>>8;this[offset+2]=value>>>16;this[offset+3]=value>>>24;return offset+4;};Buffer.prototype.writeInt32BE=function writeInt32BE(value,offset,noAssert){value=+value;offset=offset>>>0;if(!noAssert)checkInt(this,value,offset,4,0x7fffffff,-0x80000000);if(value<0)value=0xffffffff+value+1;this[offset]=value>>>24;this[offset+1]=value>>>16;this[offset+2]=value>>>8;this[offset+3]=value&0xff;return offset+4;};Buffer.prototype.writeBigInt64LE=defineBigIntMethod(function writeBigInt64LE(value){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return wrtBigUInt64LE(this,value,offset,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'));});Buffer.prototype.writeBigInt64BE=defineBigIntMethod(function writeBigInt64BE(value){var offset=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;return wrtBigUInt64BE(this,value,offset,-BigInt('0x8000000000000000'),BigInt('0x7fffffffffffffff'));});function checkIEEE754(buf,value,offset,ext,max,min){if(offset+ext>buf.length)throw new RangeError('Index out of range');if(offset<0)throw new RangeError('Index out of range');}function writeFloat(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,4,3.4028234663852886e+38,-3.4028234663852886e+38);}ieee754.write(buf,value,offset,littleEndian,23,4);return offset+4;}Buffer.prototype.writeFloatLE=function writeFloatLE(value,offset,noAssert){return writeFloat(this,value,offset,true,noAssert);};Buffer.prototype.writeFloatBE=function writeFloatBE(value,offset,noAssert){return writeFloat(this,value,offset,false,noAssert);};function writeDouble(buf,value,offset,littleEndian,noAssert){value=+value;offset=offset>>>0;if(!noAssert){checkIEEE754(buf,value,offset,8,1.7976931348623157E+308,-1.7976931348623157E+308);}ieee754.write(buf,value,offset,littleEndian,52,8);return offset+8;}Buffer.prototype.writeDoubleLE=function writeDoubleLE(value,offset,noAssert){return writeDouble(this,value,offset,true,noAssert);};Buffer.prototype.writeDoubleBE=function writeDoubleBE(value,offset,noAssert){return writeDouble(this,value,offset,false,noAssert);};// copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
Buffer.prototype.copy=function copy(target,targetStart,start,end){if(!Buffer.isBuffer(target))throw new TypeError('argument should be a Buffer');if(!start)start=0;if(!end&&end!==0)end=this.length;if(targetStart>=target.length)targetStart=target.length;if(!targetStart)targetStart=0;if(end>0&&end=this.length)throw new RangeError('Index out of range');if(end<0)throw new RangeError('sourceEnd out of bounds');// Are we oob?
if(end>this.length)end=this.length;if(target.length-targetStart>>0;end=end===undefined?this.length:end>>>0;if(!val)val=0;var i;if(typeof val==='number'){for(i=start;iMath.pow(2,32)){received=addNumericalSeparator(String(input));}else if(typeof input==='bigint'){received=String(input);if(input>Math.pow(BigInt(2),BigInt(32))||input<-Math.pow(BigInt(2),BigInt(32))){received=addNumericalSeparator(received);}received+='n';}msg+=" It must be ".concat(range,". Received ").concat(received);return msg;},RangeError);function addNumericalSeparator(val){var res='';var i=val.length;var start=val[0]==='-'?1:0;for(;i>=start+4;i-=3){res="_".concat(val.slice(i-3,i)).concat(res);}return"".concat(val.slice(0,i)).concat(res);}// CHECK FUNCTIONS
// ===============
function checkBounds(buf,offset,byteLength){validateNumber(offset,'offset');if(buf[offset]===undefined||buf[offset+byteLength]===undefined){boundsError(offset,buf.length-(byteLength+1));}}function checkIntBI(value,min,max,buf,offset,byteLength){if(value>max||value3){if(min===0||min===BigInt(0)){range=">= 0".concat(n," and < 2").concat(n," ** ").concat((byteLength+1)*8).concat(n);}else{range=">= -(2".concat(n," ** ").concat((byteLength+1)*8-1).concat(n,") and < 2 ** ")+"".concat((byteLength+1)*8-1).concat(n);}}else{range=">= ".concat(min).concat(n," and <= ").concat(max).concat(n);}throw new errors.ERR_OUT_OF_RANGE('value',range,value);}checkBounds(buf,offset,byteLength);}function validateNumber(value,name){if(typeof value!=='number'){throw new errors.ERR_INVALID_ARG_TYPE(name,'number',value);}}function boundsError(value,length,type){if(Math.floor(value)!==value){validateNumber(value,type);throw new errors.ERR_OUT_OF_RANGE(type||'offset','an integer',value);}if(length<0){throw new errors.ERR_BUFFER_OUT_OF_BOUNDS();}throw new errors.ERR_OUT_OF_RANGE(type||'offset',">= ".concat(type?1:0," and <= ").concat(length),value);}// HELPER FUNCTIONS
// ================
var INVALID_BASE64_RE=/[^+/0-9A-Za-z-_]/g;function base64clean(str){// Node takes equal signs as end of the Base64 encoding
str=str.split('=')[0];// Node strips out invalid characters like \n and \t from the string, base64-js does not
str=str.trim().replace(INVALID_BASE64_RE,'');// Node converts strings with length < 2 to ''
if(str.length<2)return'';// Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
while(str.length%4!==0){str=str+'=';}return str;}function utf8ToBytes(string,units){units=units||Infinity;var codePoint;var length=string.length;var leadSurrogate=null;var bytes=[];for(var i=0;i0xD7FF&&codePoint<0xE000){// last char was a lead
if(!leadSurrogate){// no lead yet
if(codePoint>0xDBFF){// unexpected trail
if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);continue;}else if(i+1===length){// unpaired lead
if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);continue;}// valid lead
leadSurrogate=codePoint;continue;}// 2 leads in a row
if(codePoint<0xDC00){if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);leadSurrogate=codePoint;continue;}// valid surrogate pair
codePoint=(leadSurrogate-0xD800<<10|codePoint-0xDC00)+0x10000;}else if(leadSurrogate){// valid bmp char, but last char was a lead
if((units-=3)>-1)bytes.push(0xEF,0xBF,0xBD);}leadSurrogate=null;// encode utf8
if(codePoint<0x80){if((units-=1)<0)break;bytes.push(codePoint);}else if(codePoint<0x800){if((units-=2)<0)break;bytes.push(codePoint>>0x6|0xC0,codePoint&0x3F|0x80);}else if(codePoint<0x10000){if((units-=3)<0)break;bytes.push(codePoint>>0xC|0xE0,codePoint>>0x6&0x3F|0x80,codePoint&0x3F|0x80);}else if(codePoint<0x110000){if((units-=4)<0)break;bytes.push(codePoint>>0x12|0xF0,codePoint>>0xC&0x3F|0x80,codePoint>>0x6&0x3F|0x80,codePoint&0x3F|0x80);}else{throw new Error('Invalid code point');}}return bytes;}function asciiToBytes(str){var byteArray=[];for(var i=0;i>8;lo=c%256;byteArray.push(lo);byteArray.push(hi);}return byteArray;}function base64ToBytes(str){return base64.toByteArray(base64clean(str));}function blitBuffer(src,dst,offset,length){var i;for(i=0;i=dst.length||i>=src.length)break;dst[i+offset]=src[i];}return i;}// ArrayBuffer or Uint8Array objects from other contexts (i.e. iframes) do not pass
// the `instanceof` check but they should be treated as of that type.
// See: https://github.com/feross/buffer/issues/166
function isInstance(obj,type){return obj instanceof type||obj!=null&&obj.constructor!=null&&obj.constructor.name!=null&&obj.constructor.name===type.name;}function numberIsNaN(obj){// For IE11 support
return obj!==obj;// eslint-disable-line no-self-compare
}// Create lookup table for `toString('hex')`
// See: https://github.com/feross/buffer/issues/219
var hexSliceLookupTable=function(){var alphabet='0123456789abcdef';var table=new Array(256);for(var i=0;i<16;++i){var i16=i*16;for(var j=0;j<16;++j){table[i16+j]=alphabet[i]+alphabet[j];}}return table;}();// Return not function with Error if BigInt not supported
function defineBigIntMethod(fn){return typeof BigInt==='undefined'?BufferBigIntNotDefined:fn;}function BufferBigIntNotDefined(){throw new Error('BigInt not supported');}/***/},/***/9216:/***/function(module){"use strict";module.exports=isMobile;module.exports.isMobile=isMobile;module.exports["default"]=isMobile;var mobileRE=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i;var notMobileRE=/CrOS/;var tabletRE=/android|ipad|playbook|silk/i;function isMobile(opts){if(!opts)opts={};var ua=opts.ua;if(!ua&&typeof navigator!=='undefined')ua=navigator.userAgent;if(ua&&ua.headers&&typeof ua.headers['user-agent']==='string'){ua=ua.headers['user-agent'];}if(typeof ua!=='string')return false;var result=mobileRE.test(ua)&&!notMobileRE.test(ua)||!!opts.tablet&&tabletRE.test(ua);if(!result&&opts.tablet&&opts.featureDetect&&navigator&&navigator.maxTouchPoints>1&&ua.indexOf('Macintosh')!==-1&&ua.indexOf('Safari')!==-1){result=true;}return result;}/***/},/***/6296:/***/function(module,__unused_webpack_exports,__nested_webpack_require_53135__){"use strict";module.exports=createViewController;var createTurntable=__nested_webpack_require_53135__(7261);var createOrbit=__nested_webpack_require_53135__(9977);var createMatrix=__nested_webpack_require_53135__(4192);function ViewController(controllers,mode){this._controllerNames=Object.keys(controllers);this._controllerList=this._controllerNames.map(function(n){return controllers[n];});this._mode=mode;this._active=controllers[mode];if(!this._active){this._mode='turntable';this._active=controllers.turntable;}this.modes=this._controllerNames;this.computedMatrix=this._active.computedMatrix;this.computedEye=this._active.computedEye;this.computedUp=this._active.computedUp;this.computedCenter=this._active.computedCenter;this.computedRadius=this._active.computedRadius;}var proto=ViewController.prototype;proto.flush=function(a0){var cc=this._controllerList;for(var i=0;i0){throw new Error('Invalid string. Length must be a multiple of 4');}// Trim off extra bytes after placeholder bytes are found
// See: https://github.com/beatgammit/base64-js/issues/42
var validLen=b64.indexOf('=');if(validLen===-1)validLen=len;var placeHoldersLen=validLen===len?0:4-validLen%4;return[validLen,placeHoldersLen];}// base64 is 4/3 + up to two characters of the original data
function byteLength(b64){var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];return(validLen+placeHoldersLen)*3/4-placeHoldersLen;}function _byteLength(b64,validLen,placeHoldersLen){return(validLen+placeHoldersLen)*3/4-placeHoldersLen;}function toByteArray(b64){var tmp;var lens=getLens(b64);var validLen=lens[0];var placeHoldersLen=lens[1];var arr=new Arr(_byteLength(b64,validLen,placeHoldersLen));var curByte=0;// if there are placeholders, only get up to the last complete 4 chars
var len=placeHoldersLen>0?validLen-4:validLen;var i;for(i=0;i>16&0xFF;arr[curByte++]=tmp>>8&0xFF;arr[curByte++]=tmp&0xFF;}if(placeHoldersLen===2){tmp=revLookup[b64.charCodeAt(i)]<<2|revLookup[b64.charCodeAt(i+1)]>>4;arr[curByte++]=tmp&0xFF;}if(placeHoldersLen===1){tmp=revLookup[b64.charCodeAt(i)]<<10|revLookup[b64.charCodeAt(i+1)]<<4|revLookup[b64.charCodeAt(i+2)]>>2;arr[curByte++]=tmp>>8&0xFF;arr[curByte++]=tmp&0xFF;}return arr;}function tripletToBase64(num){return lookup[num>>18&0x3F]+lookup[num>>12&0x3F]+lookup[num>>6&0x3F]+lookup[num&0x3F];}function encodeChunk(uint8,start,end){var tmp;var output=[];for(var i=start;ilen2?len2:i+maxChunkLength));}// pad the end with zeros, but make sure to not forget the extra bytes
if(extraBytes===1){tmp=uint8[len-1];parts.push(lookup[tmp>>2]+lookup[tmp<<4&0x3F]+'==');}else if(extraBytes===2){tmp=(uint8[len-2]<<8)+uint8[len-1];parts.push(lookup[tmp>>10]+lookup[tmp>>4&0x3F]+lookup[tmp<<2&0x3F]+'=');}return parts.join('');}/***/},/***/3865:/***/function(module,__unused_webpack_exports,__nested_webpack_require_63262__){"use strict";var rationalize=__nested_webpack_require_63262__(869);module.exports=add;function add(a,b){return rationalize(a[0].mul(b[1]).add(b[0].mul(a[1])),a[1].mul(b[1]));}/***/},/***/1318:/***/function(module){"use strict";module.exports=cmp;function cmp(a,b){return a[0].mul(b[1]).cmp(b[0].mul(a[1]));}/***/},/***/8697:/***/function(module,__unused_webpack_exports,__nested_webpack_require_63640__){"use strict";var rationalize=__nested_webpack_require_63640__(869);module.exports=div;function div(a,b){return rationalize(a[0].mul(b[1]),a[1].mul(b[0]));}/***/},/***/7842:/***/function(module,__unused_webpack_exports,__nested_webpack_require_63866__){"use strict";var isRat=__nested_webpack_require_63866__(6330);var isBN=__nested_webpack_require_63866__(1533);var num2bn=__nested_webpack_require_63866__(2651);var str2bn=__nested_webpack_require_63866__(4387);var rationalize=__nested_webpack_require_63866__(869);var div=__nested_webpack_require_63866__(8697);module.exports=makeRational;function makeRational(numer,denom){if(isRat(numer)){if(denom){return div(numer,makeRational(denom));}return[numer[0].clone(),numer[1].clone()];}var shift=0;var a,b;if(isBN(numer)){a=numer.clone();}else if(typeof numer==='string'){a=str2bn(numer);}else if(numer===0){return[num2bn(0),num2bn(1)];}else if(numer===Math.floor(numer)){a=num2bn(numer);}else{while(numer!==Math.floor(numer)){numer=numer*Math.pow(2,256);shift-=256;}a=num2bn(numer);}if(isRat(denom)){a.mul(denom[1]);b=denom[0].clone();}else if(isBN(denom)){b=denom.clone();}else if(typeof denom==='string'){b=str2bn(denom);}else if(!denom){b=num2bn(1);}else if(denom===Math.floor(denom)){b=num2bn(denom);}else{while(denom!==Math.floor(denom)){denom=denom*Math.pow(2,256);shift+=256;}b=num2bn(denom);}if(shift>0){a=a.ushln(shift);}else if(shift<0){b=b.ushln(-shift);}return rationalize(a,b);}/***/},/***/6330:/***/function(module,__unused_webpack_exports,__nested_webpack_require_65061__){"use strict";var isBN=__nested_webpack_require_65061__(1533);module.exports=isRat;function isRat(x){return Array.isArray(x)&&x.length===2&&isBN(x[0])&&isBN(x[1]);}/***/},/***/5716:/***/function(module,__unused_webpack_exports,__nested_webpack_require_65295__){"use strict";var BN=__nested_webpack_require_65295__(6859);module.exports=sign;function sign(x){return x.cmp(new BN(0));}/***/},/***/1369:/***/function(module,__unused_webpack_exports,__nested_webpack_require_65487__){"use strict";var sign=__nested_webpack_require_65487__(5716);module.exports=bn2num;//TODO: Make this better
function bn2num(b){var l=b.length;var words=b.words;var out=0;if(l===1){out=words[0];}else if(l===2){out=words[0]+words[1]*0x4000000;}else{for(var i=0;i20){return 52;}return h+32;}/***/},/***/1533:/***/function(module,__unused_webpack_exports,__nested_webpack_require_66252__){"use strict";var BN=__nested_webpack_require_66252__(6859);module.exports=isBN;//Test if x is a bignumber
//FIXME: obviously this is the wrong way to do it
function isBN(x){return x&&typeof x==='object'&&Boolean(x.words);}/***/},/***/2651:/***/function(module,__unused_webpack_exports,__nested_webpack_require_66545__){"use strict";var BN=__nested_webpack_require_66545__(6859);var db=__nested_webpack_require_66545__(2361);module.exports=num2bn;function num2bn(x){var e=db.exponent(x);if(e<52){return new BN(x);}else{return new BN(x*Math.pow(2,52-e)).ushln(e-52);}}/***/},/***/869:/***/function(module,__unused_webpack_exports,__nested_webpack_require_66849__){"use strict";var num2bn=__nested_webpack_require_66849__(2651);var sign=__nested_webpack_require_66849__(5716);module.exports=rationalize;function rationalize(numer,denom){var snumer=sign(numer);var sdenom=sign(denom);if(snumer===0){return[num2bn(0),num2bn(1)];}if(sdenom===0){return[num2bn(0),num2bn(0)];}if(sdenom<0){numer=numer.neg();denom=denom.neg();}var d=numer.gcd(denom);if(d.cmpn(1)){return[numer.div(d),denom.div(d)];}return[numer,denom];}/***/},/***/4387:/***/function(module,__unused_webpack_exports,__nested_webpack_require_67356__){"use strict";var BN=__nested_webpack_require_67356__(6859);module.exports=str2BN;function str2BN(x){return new BN(x);}/***/},/***/6504:/***/function(module,__unused_webpack_exports,__nested_webpack_require_67545__){"use strict";var rationalize=__nested_webpack_require_67545__(869);module.exports=mul;function mul(a,b){return rationalize(a[0].mul(b[0]),a[1].mul(b[1]));}/***/},/***/7721:/***/function(module,__unused_webpack_exports,__nested_webpack_require_67771__){"use strict";var bnsign=__nested_webpack_require_67771__(5716);module.exports=sign;function sign(x){return bnsign(x[0])*bnsign(x[1]);}/***/},/***/5572:/***/function(module,__unused_webpack_exports,__nested_webpack_require_67976__){"use strict";var rationalize=__nested_webpack_require_67976__(869);module.exports=sub;function sub(a,b){return rationalize(a[0].mul(b[1]).sub(a[1].mul(b[0])),a[1].mul(b[1]));}/***/},/***/946:/***/function(module,__unused_webpack_exports,__nested_webpack_require_68221__){"use strict";var bn2num=__nested_webpack_require_68221__(1369);var ctz=__nested_webpack_require_68221__(4025);module.exports=roundRat;// Round a rational to the closest float
function roundRat(f){var a=f[0];var b=f[1];if(a.cmpn(0)===0){return 0;}var h=a.abs().divmod(b.abs());var iv=h.div;var x=bn2num(iv);var ir=h.mod;var sgn=a.negative!==b.negative?-1:1;if(ir.cmpn(0)===0){return sgn*x;}if(x){var s=ctz(x)+4;var y=bn2num(ir.ushln(s).divRound(b));return sgn*(x+y*Math.pow(2,-s));}else{var ybits=b.bitLength()-ir.bitLength()+53;var y=bn2num(ir.ushln(ybits).divRound(b));if(ybits<1023){return sgn*y*Math.pow(2,-ybits);}y*=Math.pow(2,-1023);return sgn*y*Math.pow(2,1023-ybits);}}/***/},/***/2478:/***/function(module){"use strict";// (a, y, c, l, h) = (array, y[, cmp, lo, hi])
function ge(a,y,c,l,h){var i=h+1;while(l<=h){var m=l+h>>>1,x=a[m];var p=c!==undefined?c(x,y):x-y;if(p>=0){i=m;h=m-1;}else{l=m+1;}}return i;};function gt(a,y,c,l,h){var i=h+1;while(l<=h){var m=l+h>>>1,x=a[m];var p=c!==undefined?c(x,y):x-y;if(p>0){i=m;h=m-1;}else{l=m+1;}}return i;};function lt(a,y,c,l,h){var i=l-1;while(l<=h){var m=l+h>>>1,x=a[m];var p=c!==undefined?c(x,y):x-y;if(p<0){i=m;l=m+1;}else{h=m-1;}}return i;};function le(a,y,c,l,h){var i=l-1;while(l<=h){var m=l+h>>>1,x=a[m];var p=c!==undefined?c(x,y):x-y;if(p<=0){i=m;l=m+1;}else{h=m-1;}}return i;};function eq(a,y,c,l,h){while(l<=h){var m=l+h>>>1,x=a[m];var p=c!==undefined?c(x,y):x-y;if(p===0){return m;}if(p<=0){l=m+1;}else{h=m-1;}}return-1;};function norm(a,y,c,l,h,f){if(typeof c==='function'){return f(a,y,c,l===undefined?0:l|0,h===undefined?a.length-1:h|0);}return f(a,y,undefined,c===undefined?0:c|0,l===undefined?a.length-1:l|0);}module.exports={ge:function(a,y,c,l,h){return norm(a,y,c,l,h,ge);},gt:function(a,y,c,l,h){return norm(a,y,c,l,h,gt);},lt:function(a,y,c,l,h){return norm(a,y,c,l,h,lt);},le:function(a,y,c,l,h){return norm(a,y,c,l,h,le);},eq:function(a,y,c,l,h){return norm(a,y,c,l,h,eq);}};/***/},/***/8828:/***/function(__unused_webpack_module,exports){"use strict";/**
* Bit twiddling hacks for JavaScript.
*
* Author: Mikola Lysenko
*
* Ported from Stanford bit twiddling hack library:
* http://graphics.stanford.edu/~seander/bithacks.html
*/"use restrict";//Number of bits in an integer
var INT_BITS=32;//Constants
exports.INT_BITS=INT_BITS;exports.INT_MAX=0x7fffffff;exports.INT_MIN=-1<0)-(v<0);};//Computes absolute value of integer
exports.abs=function(v){var mask=v>>INT_BITS-1;return(v^mask)-mask;};//Computes minimum of integers x and y
exports.min=function(x,y){return y^(x^y)&-(x0xFFFF)<<4;v>>>=r;shift=(v>0xFF)<<3;v>>>=shift;r|=shift;shift=(v>0xF)<<2;v>>>=shift;r|=shift;shift=(v>0x3)<<1;v>>>=shift;r|=shift;return r|v>>1;};//Computes log base 10 of v
exports.log10=function(v){return v>=1000000000?9:v>=100000000?8:v>=10000000?7:v>=1000000?6:v>=100000?5:v>=10000?4:v>=1000?3:v>=100?2:v>=10?1:0;};//Counts number of bits
exports.popCount=function(v){v=v-(v>>>1&0x55555555);v=(v&0x33333333)+(v>>>2&0x33333333);return(v+(v>>>4)&0xF0F0F0F)*0x1010101>>>24;};//Counts number of trailing zeros
function countTrailingZeros(v){var c=32;v&=-v;if(v)c--;if(v&0x0000FFFF)c-=16;if(v&0x00FF00FF)c-=8;if(v&0x0F0F0F0F)c-=4;if(v&0x33333333)c-=2;if(v&0x55555555)c-=1;return c;}exports.countTrailingZeros=countTrailingZeros;//Rounds to next power of 2
exports.nextPow2=function(v){v+=v===0;--v;v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v+1;};//Rounds down to previous power of 2
exports.prevPow2=function(v){v|=v>>>1;v|=v>>>2;v|=v>>>4;v|=v>>>8;v|=v>>>16;return v-(v>>>1);};//Computes parity of word
exports.parity=function(v){v^=v>>>16;v^=v>>>8;v^=v>>>4;v&=0xf;return 0x6996>>>v&1;};var REVERSE_TABLE=new Array(256);(function(tab){for(var i=0;i<256;++i){var v=i,r=i,s=7;for(v>>>=1;v;v>>>=1){r<<=1;r|=v&1;--s;}tab[i]=r<>>8&0xff]<<16|REVERSE_TABLE[v>>>16&0xff]<<8|REVERSE_TABLE[v>>>24&0xff];};//Interleave bits of 2 coordinates with 16 bits. Useful for fast quadtree codes
exports.interleave2=function(x,y){x&=0xFFFF;x=(x|x<<8)&0x00FF00FF;x=(x|x<<4)&0x0F0F0F0F;x=(x|x<<2)&0x33333333;x=(x|x<<1)&0x55555555;y&=0xFFFF;y=(y|y<<8)&0x00FF00FF;y=(y|y<<4)&0x0F0F0F0F;y=(y|y<<2)&0x33333333;y=(y|y<<1)&0x55555555;return x|y<<1;};//Extracts the nth interleaved component
exports.deinterleave2=function(v,n){v=v>>>n&0x55555555;v=(v|v>>>1)&0x33333333;v=(v|v>>>2)&0x0F0F0F0F;v=(v|v>>>4)&0x00FF00FF;v=(v|v>>>16)&0x000FFFF;return v<<16>>16;};//Interleave bits of 3 coordinates, each with 10 bits. Useful for fast octree codes
exports.interleave3=function(x,y,z){x&=0x3FF;x=(x|x<<16)&4278190335;x=(x|x<<8)&251719695;x=(x|x<<4)&3272356035;x=(x|x<<2)&1227133513;y&=0x3FF;y=(y|y<<16)&4278190335;y=(y|y<<8)&251719695;y=(y|y<<4)&3272356035;y=(y|y<<2)&1227133513;x|=y<<1;z&=0x3FF;z=(z|z<<16)&4278190335;z=(z|z<<8)&251719695;z=(z|z<<4)&3272356035;z=(z|z<<2)&1227133513;return x|z<<2;};//Extracts nth interleaved component of a 3-tuple
exports.deinterleave3=function(v,n){v=v>>>n&1227133513;v=(v|v>>>2)&3272356035;v=(v|v>>>4)&251719695;v=(v|v>>>8)&4278190335;v=(v|v>>>16)&0x3FF;return v<<22>>22;};//Computes next combination in colexicographic order (this is mistakenly called nextPermutation on the bit twiddling hacks page)
exports.nextCombination=function(v){var t=v|v-1;return t+1|(~t&-~t)-1>>>countTrailingZeros(v)+1;};/***/},/***/6859:/***/function(module,__unused_webpack_exports,__nested_webpack_require_74030__){/* module decorator */module=__nested_webpack_require_74030__.nmd(module);(function(module,exports){'use strict';// Utils
function assert(val,msg){if(!val)throw new Error(msg||'Assertion failed');}// Could use `inherits` module, but don't want to move from single file
// architecture yet.
function inherits(ctor,superCtor){ctor.super_=superCtor;var TempCtor=function(){};TempCtor.prototype=superCtor.prototype;ctor.prototype=new TempCtor();ctor.prototype.constructor=ctor;}// BN
function BN(number,base,endian){if(BN.isBN(number)){return number;}this.negative=0;this.words=null;this.length=0;// Reduction context
this.red=null;if(number!==null){if(base==='le'||base==='be'){endian=base;base=10;}this._init(number||0,base||10,endian||'be');}}if(typeof module==='object'){module.exports=BN;}else{exports.BN=BN;}BN.BN=BN;BN.wordSize=26;var Buffer;try{if(typeof window!=='undefined'&&typeof window.Buffer!=='undefined'){Buffer=window.Buffer;}else{Buffer=__nested_webpack_require_74030__(7790).Buffer;}}catch(e){}BN.isBN=function isBN(num){if(num instanceof BN){return true;}return num!==null&&typeof num==='object'&&num.constructor.wordSize===BN.wordSize&&Array.isArray(num.words);};BN.max=function max(left,right){if(left.cmp(right)>0)return left;return right;};BN.min=function min(left,right){if(left.cmp(right)<0)return left;return right;};BN.prototype._init=function init(number,base,endian){if(typeof number==='number'){return this._initNumber(number,base,endian);}if(typeof number==='object'){return this._initArray(number,base,endian);}if(base==='hex'){base=16;}assert(base===(base|0)&&base>=2&&base<=36);number=number.toString().replace(/\s+/g,'');var start=0;if(number[0]==='-'){start++;this.negative=1;}if(start=0;i-=3){w=number[i]|number[i-1]<<8|number[i-2]<<16;this.words[j]|=w<>>26-off&0x3ffffff;off+=24;if(off>=26){off-=26;j++;}}}else if(endian==='le'){for(i=0,j=0;i>>26-off&0x3ffffff;off+=24;if(off>=26){off-=26;j++;}}}return this.strip();};function parseHex4Bits(string,index){var c=string.charCodeAt(index);// 'A' - 'F'
if(c>=65&&c<=70){return c-55;// 'a' - 'f'
}else if(c>=97&&c<=102){return c-87;// '0' - '9'
}else{return c-48&0xf;}}function parseHexByte(string,lowerBound,index){var r=parseHex4Bits(string,index);if(index-1>=lowerBound){r|=parseHex4Bits(string,index-1)<<4;}return r;}BN.prototype._parseHex=function _parseHex(number,start,endian){// Create possibly bigger array to ensure that it fits the number
this.length=Math.ceil((number.length-start)/6);this.words=new Array(this.length);for(var i=0;i=start;i-=2){w=parseHexByte(number,start,i)<=18){off-=18;j+=1;this.words[j]|=w>>>26;}else{off+=8;}}}else{var parseLength=number.length-start;for(i=parseLength%2===0?start+1:start;i=18){off-=18;j+=1;this.words[j]|=w>>>26;}else{off+=8;}}}this.strip();};function parseBase(str,start,end,mul){var r=0;var len=Math.min(str.length,end);for(var i=start;i=49){r+=c-49+0xa;// 'A'
}else if(c>=17){r+=c-17+0xa;// '0' - '9'
}else{r+=c;}}return r;}BN.prototype._parseBase=function _parseBase(number,base,start){// Initialize as zero
this.words=[0];this.length=1;// Find length of limb in base
for(var limbLen=0,limbPow=1;limbPow<=0x3ffffff;limbPow*=base){limbLen++;}limbLen--;limbPow=limbPow/base|0;var total=number.length-start;var mod=total%limbLen;var end=Math.min(total,total-mod)+start;var word=0;for(var i=start;i1&&this.words[this.length-1]===0){this.length--;}return this._normSign();};BN.prototype._normSign=function _normSign(){// -0 = 0
if(this.length===1&&this.words[0]===0){this.negative=0;}return this;};BN.prototype.inspect=function inspect(){return(this.red?'';};/*
var zeros = [];
var groupSizes = [];
var groupBases = [];
var s = '';
var i = -1;
while (++i < BN.wordSize) {
zeros[i] = s;
s += '0';
}
groupSizes[0] = 0;
groupSizes[1] = 0;
groupBases[0] = 0;
groupBases[1] = 0;
var base = 2 - 1;
while (++base < 36 + 1) {
var groupSize = 0;
var groupBase = 1;
while (groupBase < (1 << BN.wordSize) / base) {
groupBase *= base;
groupSize += 1;
}
groupSizes[base] = groupSize;
groupBases[base] = groupBase;
}
*/var zeros=['','0','00','000','0000','00000','000000','0000000','00000000','000000000','0000000000','00000000000','000000000000','0000000000000','00000000000000','000000000000000','0000000000000000','00000000000000000','000000000000000000','0000000000000000000','00000000000000000000','000000000000000000000','0000000000000000000000','00000000000000000000000','000000000000000000000000','0000000000000000000000000'];var groupSizes=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5];var groupBases=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,10000000,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64000000,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,24300000,28629151,33554432,39135393,45435424,52521875,60466176];BN.prototype.toString=function toString(base,padding){base=base||10;padding=padding|0||1;var out;if(base===16||base==='hex'){out='';var off=0;var carry=0;for(var i=0;i>>24-off&0xffffff;if(carry!==0||i!==this.length-1){out=zeros[6-word.length]+word+out;}else{out=word+out;}off+=2;if(off>=26){off-=26;i--;}}if(carry!==0){out=carry.toString(16)+out;}while(out.length%padding!==0){out='0'+out;}if(this.negative!==0){out='-'+out;}return out;}if(base===(base|0)&&base>=2&&base<=36){// var groupSize = Math.floor(BN.wordSize * Math.LN2 / Math.log(base));
var groupSize=groupSizes[base];// var groupBase = Math.pow(base, groupSize);
var groupBase=groupBases[base];out='';var c=this.clone();c.negative=0;while(!c.isZero()){var r=c.modn(groupBase).toString(base);c=c.idivn(groupBase);if(!c.isZero()){out=zeros[groupSize-r.length]+r+out;}else{out=r+out;}}if(this.isZero()){out='0'+out;}while(out.length%padding!==0){out='0'+out;}if(this.negative!==0){out='-'+out;}return out;}assert(false,'Base should be between 2 and 36');};BN.prototype.toNumber=function toNumber(){var ret=this.words[0];if(this.length===2){ret+=this.words[1]*0x4000000;}else if(this.length===3&&this.words[2]===0x01){// NOTE: at this stage it is known that the top bit is set
ret+=0x10000000000000+this.words[1]*0x4000000;}else if(this.length>2){assert(false,'Number can only safely store up to 53 bits');}return this.negative!==0?-ret:ret;};BN.prototype.toJSON=function toJSON(){return this.toString(16);};BN.prototype.toBuffer=function toBuffer(endian,length){assert(typeof Buffer!=='undefined');return this.toArrayLike(Buffer,endian,length);};BN.prototype.toArray=function toArray(endian,length){return this.toArrayLike(Array,endian,length);};BN.prototype.toArrayLike=function toArrayLike(ArrayType,endian,length){var byteLength=this.byteLength();var reqLength=length||Math.max(1,byteLength);assert(byteLength<=reqLength,'byte array longer than desired length');assert(reqLength>0,'Requested array length <= 0');this.strip();var littleEndian=endian==='le';var res=new ArrayType(reqLength);var b,i;var q=this.clone();if(!littleEndian){// Assume big-endian
for(i=0;i=0x1000){r+=13;t>>>=13;}if(t>=0x40){r+=7;t>>>=7;}if(t>=0x8){r+=4;t>>>=4;}if(t>=0x02){r+=2;t>>>=2;}return r+t;};}BN.prototype._zeroBits=function _zeroBits(w){// Short-cut
if(w===0)return 26;var t=w;var r=0;if((t&0x1fff)===0){r+=13;t>>>=13;}if((t&0x7f)===0){r+=7;t>>>=7;}if((t&0xf)===0){r+=4;t>>>=4;}if((t&0x3)===0){r+=2;t>>>=2;}if((t&0x1)===0){r++;}return r;};// Return number of used bits in a BN
BN.prototype.bitLength=function bitLength(){var w=this.words[this.length-1];var hi=this._countBits(w);return(this.length-1)*26+hi;};function toBitArray(num){var w=new Array(num.bitLength());for(var bit=0;bit>>wbit;}return w;}// Number of trailing zero bits
BN.prototype.zeroBits=function zeroBits(){if(this.isZero())return 0;var r=0;for(var i=0;inum.length)return this.clone().ior(num);return num.clone().ior(this);};BN.prototype.uor=function uor(num){if(this.length>num.length)return this.clone().iuor(num);return num.clone().iuor(this);};// And `num` with `this` in-place
BN.prototype.iuand=function iuand(num){// b = min-length(num, this)
var b;if(this.length>num.length){b=num;}else{b=this;}for(var i=0;inum.length)return this.clone().iand(num);return num.clone().iand(this);};BN.prototype.uand=function uand(num){if(this.length>num.length)return this.clone().iuand(num);return num.clone().iuand(this);};// Xor `num` with `this` in-place
BN.prototype.iuxor=function iuxor(num){// a.length > b.length
var a;var b;if(this.length>num.length){a=this;b=num;}else{a=num;b=this;}for(var i=0;inum.length)return this.clone().ixor(num);return num.clone().ixor(this);};BN.prototype.uxor=function uxor(num){if(this.length>num.length)return this.clone().iuxor(num);return num.clone().iuxor(this);};// Not ``this`` with ``width`` bitwidth
BN.prototype.inotn=function inotn(width){assert(typeof width==='number'&&width>=0);var bytesNeeded=Math.ceil(width/26)|0;var bitsLeft=width%26;// Extend the buffer with leading zeroes
this._expand(bytesNeeded);if(bitsLeft>0){bytesNeeded--;}// Handle complete words
for(var i=0;i0){this.words[i]=~this.words[i]&0x3ffffff>>26-bitsLeft;}// And remove leading zeroes
return this.strip();};BN.prototype.notn=function notn(width){return this.clone().inotn(width);};// Set `bit` of `this`
BN.prototype.setn=function setn(bit,val){assert(typeof bit==='number'&&bit>=0);var off=bit/26|0;var wbit=bit%26;this._expand(off+1);if(val){this.words[off]=this.words[off]|1< b.length
var a,b;if(this.length>num.length){a=this;b=num;}else{a=num;b=this;}var carry=0;for(var i=0;i>>26;}for(;carry!==0&&i>>26;}this.length=a.length;if(carry!==0){this.words[this.length]=carry;this.length++;// Copy the rest of the words
}else if(a!==this){for(;inum.length)return this.clone().iadd(num);return num.clone().iadd(this);};// Subtract `num` from `this` in-place
BN.prototype.isub=function isub(num){// this - (-num) = this + num
if(num.negative!==0){num.negative=0;var r=this.iadd(num);num.negative=1;return r._normSign();// -this - num = -(this + num)
}else if(this.negative!==0){this.negative=0;this.iadd(num);this.negative=1;return this._normSign();}// At this point both numbers are positive
var cmp=this.cmp(num);// Optimization - zeroify
if(cmp===0){this.negative=0;this.length=1;this.words[0]=0;return this;}// a > b
var a,b;if(cmp>0){a=this;b=num;}else{a=num;b=this;}var carry=0;for(var i=0;i>26;this.words[i]=r&0x3ffffff;}for(;carry!==0&&i>26;this.words[i]=r&0x3ffffff;}// Copy rest of the words
if(carry===0&&i= 0x3ffffff
var ncarry=carry>>>26;var rword=carry&0x3ffffff;var maxJ=Math.min(k,num.length-1);for(var j=Math.max(0,k-self.length+1);j<=maxJ;j++){var i=k-j|0;a=self.words[i]|0;b=num.words[j]|0;r=a*b+rword;ncarry+=r/0x4000000|0;rword=r&0x3ffffff;}out.words[k]=rword|0;carry=ncarry|0;}if(carry!==0){out.words[k]=carry|0;}else{out.length--;}return out.strip();}// TODO(indutny): it may be reasonable to omit it for users who don't need
// to work with 256-bit numbers, otherwise it gives 20% improvement for 256-bit
// multiplication (like elliptic secp256k1).
var comb10MulTo=function comb10MulTo(self,num,out){var a=self.words;var b=num.words;var o=out.words;var c=0;var lo;var mid;var hi;var a0=a[0]|0;var al0=a0&0x1fff;var ah0=a0>>>13;var a1=a[1]|0;var al1=a1&0x1fff;var ah1=a1>>>13;var a2=a[2]|0;var al2=a2&0x1fff;var ah2=a2>>>13;var a3=a[3]|0;var al3=a3&0x1fff;var ah3=a3>>>13;var a4=a[4]|0;var al4=a4&0x1fff;var ah4=a4>>>13;var a5=a[5]|0;var al5=a5&0x1fff;var ah5=a5>>>13;var a6=a[6]|0;var al6=a6&0x1fff;var ah6=a6>>>13;var a7=a[7]|0;var al7=a7&0x1fff;var ah7=a7>>>13;var a8=a[8]|0;var al8=a8&0x1fff;var ah8=a8>>>13;var a9=a[9]|0;var al9=a9&0x1fff;var ah9=a9>>>13;var b0=b[0]|0;var bl0=b0&0x1fff;var bh0=b0>>>13;var b1=b[1]|0;var bl1=b1&0x1fff;var bh1=b1>>>13;var b2=b[2]|0;var bl2=b2&0x1fff;var bh2=b2>>>13;var b3=b[3]|0;var bl3=b3&0x1fff;var bh3=b3>>>13;var b4=b[4]|0;var bl4=b4&0x1fff;var bh4=b4>>>13;var b5=b[5]|0;var bl5=b5&0x1fff;var bh5=b5>>>13;var b6=b[6]|0;var bl6=b6&0x1fff;var bh6=b6>>>13;var b7=b[7]|0;var bl7=b7&0x1fff;var bh7=b7>>>13;var b8=b[8]|0;var bl8=b8&0x1fff;var bh8=b8>>>13;var b9=b[9]|0;var bl9=b9&0x1fff;var bh9=b9>>>13;out.negative=self.negative^num.negative;out.length=19;/* k = 0 */lo=Math.imul(al0,bl0);mid=Math.imul(al0,bh0);mid=mid+Math.imul(ah0,bl0)|0;hi=Math.imul(ah0,bh0);var w0=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w0>>>26)|0;w0&=0x3ffffff;/* k = 1 */lo=Math.imul(al1,bl0);mid=Math.imul(al1,bh0);mid=mid+Math.imul(ah1,bl0)|0;hi=Math.imul(ah1,bh0);lo=lo+Math.imul(al0,bl1)|0;mid=mid+Math.imul(al0,bh1)|0;mid=mid+Math.imul(ah0,bl1)|0;hi=hi+Math.imul(ah0,bh1)|0;var w1=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w1>>>26)|0;w1&=0x3ffffff;/* k = 2 */lo=Math.imul(al2,bl0);mid=Math.imul(al2,bh0);mid=mid+Math.imul(ah2,bl0)|0;hi=Math.imul(ah2,bh0);lo=lo+Math.imul(al1,bl1)|0;mid=mid+Math.imul(al1,bh1)|0;mid=mid+Math.imul(ah1,bl1)|0;hi=hi+Math.imul(ah1,bh1)|0;lo=lo+Math.imul(al0,bl2)|0;mid=mid+Math.imul(al0,bh2)|0;mid=mid+Math.imul(ah0,bl2)|0;hi=hi+Math.imul(ah0,bh2)|0;var w2=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w2>>>26)|0;w2&=0x3ffffff;/* k = 3 */lo=Math.imul(al3,bl0);mid=Math.imul(al3,bh0);mid=mid+Math.imul(ah3,bl0)|0;hi=Math.imul(ah3,bh0);lo=lo+Math.imul(al2,bl1)|0;mid=mid+Math.imul(al2,bh1)|0;mid=mid+Math.imul(ah2,bl1)|0;hi=hi+Math.imul(ah2,bh1)|0;lo=lo+Math.imul(al1,bl2)|0;mid=mid+Math.imul(al1,bh2)|0;mid=mid+Math.imul(ah1,bl2)|0;hi=hi+Math.imul(ah1,bh2)|0;lo=lo+Math.imul(al0,bl3)|0;mid=mid+Math.imul(al0,bh3)|0;mid=mid+Math.imul(ah0,bl3)|0;hi=hi+Math.imul(ah0,bh3)|0;var w3=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w3>>>26)|0;w3&=0x3ffffff;/* k = 4 */lo=Math.imul(al4,bl0);mid=Math.imul(al4,bh0);mid=mid+Math.imul(ah4,bl0)|0;hi=Math.imul(ah4,bh0);lo=lo+Math.imul(al3,bl1)|0;mid=mid+Math.imul(al3,bh1)|0;mid=mid+Math.imul(ah3,bl1)|0;hi=hi+Math.imul(ah3,bh1)|0;lo=lo+Math.imul(al2,bl2)|0;mid=mid+Math.imul(al2,bh2)|0;mid=mid+Math.imul(ah2,bl2)|0;hi=hi+Math.imul(ah2,bh2)|0;lo=lo+Math.imul(al1,bl3)|0;mid=mid+Math.imul(al1,bh3)|0;mid=mid+Math.imul(ah1,bl3)|0;hi=hi+Math.imul(ah1,bh3)|0;lo=lo+Math.imul(al0,bl4)|0;mid=mid+Math.imul(al0,bh4)|0;mid=mid+Math.imul(ah0,bl4)|0;hi=hi+Math.imul(ah0,bh4)|0;var w4=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w4>>>26)|0;w4&=0x3ffffff;/* k = 5 */lo=Math.imul(al5,bl0);mid=Math.imul(al5,bh0);mid=mid+Math.imul(ah5,bl0)|0;hi=Math.imul(ah5,bh0);lo=lo+Math.imul(al4,bl1)|0;mid=mid+Math.imul(al4,bh1)|0;mid=mid+Math.imul(ah4,bl1)|0;hi=hi+Math.imul(ah4,bh1)|0;lo=lo+Math.imul(al3,bl2)|0;mid=mid+Math.imul(al3,bh2)|0;mid=mid+Math.imul(ah3,bl2)|0;hi=hi+Math.imul(ah3,bh2)|0;lo=lo+Math.imul(al2,bl3)|0;mid=mid+Math.imul(al2,bh3)|0;mid=mid+Math.imul(ah2,bl3)|0;hi=hi+Math.imul(ah2,bh3)|0;lo=lo+Math.imul(al1,bl4)|0;mid=mid+Math.imul(al1,bh4)|0;mid=mid+Math.imul(ah1,bl4)|0;hi=hi+Math.imul(ah1,bh4)|0;lo=lo+Math.imul(al0,bl5)|0;mid=mid+Math.imul(al0,bh5)|0;mid=mid+Math.imul(ah0,bl5)|0;hi=hi+Math.imul(ah0,bh5)|0;var w5=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w5>>>26)|0;w5&=0x3ffffff;/* k = 6 */lo=Math.imul(al6,bl0);mid=Math.imul(al6,bh0);mid=mid+Math.imul(ah6,bl0)|0;hi=Math.imul(ah6,bh0);lo=lo+Math.imul(al5,bl1)|0;mid=mid+Math.imul(al5,bh1)|0;mid=mid+Math.imul(ah5,bl1)|0;hi=hi+Math.imul(ah5,bh1)|0;lo=lo+Math.imul(al4,bl2)|0;mid=mid+Math.imul(al4,bh2)|0;mid=mid+Math.imul(ah4,bl2)|0;hi=hi+Math.imul(ah4,bh2)|0;lo=lo+Math.imul(al3,bl3)|0;mid=mid+Math.imul(al3,bh3)|0;mid=mid+Math.imul(ah3,bl3)|0;hi=hi+Math.imul(ah3,bh3)|0;lo=lo+Math.imul(al2,bl4)|0;mid=mid+Math.imul(al2,bh4)|0;mid=mid+Math.imul(ah2,bl4)|0;hi=hi+Math.imul(ah2,bh4)|0;lo=lo+Math.imul(al1,bl5)|0;mid=mid+Math.imul(al1,bh5)|0;mid=mid+Math.imul(ah1,bl5)|0;hi=hi+Math.imul(ah1,bh5)|0;lo=lo+Math.imul(al0,bl6)|0;mid=mid+Math.imul(al0,bh6)|0;mid=mid+Math.imul(ah0,bl6)|0;hi=hi+Math.imul(ah0,bh6)|0;var w6=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w6>>>26)|0;w6&=0x3ffffff;/* k = 7 */lo=Math.imul(al7,bl0);mid=Math.imul(al7,bh0);mid=mid+Math.imul(ah7,bl0)|0;hi=Math.imul(ah7,bh0);lo=lo+Math.imul(al6,bl1)|0;mid=mid+Math.imul(al6,bh1)|0;mid=mid+Math.imul(ah6,bl1)|0;hi=hi+Math.imul(ah6,bh1)|0;lo=lo+Math.imul(al5,bl2)|0;mid=mid+Math.imul(al5,bh2)|0;mid=mid+Math.imul(ah5,bl2)|0;hi=hi+Math.imul(ah5,bh2)|0;lo=lo+Math.imul(al4,bl3)|0;mid=mid+Math.imul(al4,bh3)|0;mid=mid+Math.imul(ah4,bl3)|0;hi=hi+Math.imul(ah4,bh3)|0;lo=lo+Math.imul(al3,bl4)|0;mid=mid+Math.imul(al3,bh4)|0;mid=mid+Math.imul(ah3,bl4)|0;hi=hi+Math.imul(ah3,bh4)|0;lo=lo+Math.imul(al2,bl5)|0;mid=mid+Math.imul(al2,bh5)|0;mid=mid+Math.imul(ah2,bl5)|0;hi=hi+Math.imul(ah2,bh5)|0;lo=lo+Math.imul(al1,bl6)|0;mid=mid+Math.imul(al1,bh6)|0;mid=mid+Math.imul(ah1,bl6)|0;hi=hi+Math.imul(ah1,bh6)|0;lo=lo+Math.imul(al0,bl7)|0;mid=mid+Math.imul(al0,bh7)|0;mid=mid+Math.imul(ah0,bl7)|0;hi=hi+Math.imul(ah0,bh7)|0;var w7=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w7>>>26)|0;w7&=0x3ffffff;/* k = 8 */lo=Math.imul(al8,bl0);mid=Math.imul(al8,bh0);mid=mid+Math.imul(ah8,bl0)|0;hi=Math.imul(ah8,bh0);lo=lo+Math.imul(al7,bl1)|0;mid=mid+Math.imul(al7,bh1)|0;mid=mid+Math.imul(ah7,bl1)|0;hi=hi+Math.imul(ah7,bh1)|0;lo=lo+Math.imul(al6,bl2)|0;mid=mid+Math.imul(al6,bh2)|0;mid=mid+Math.imul(ah6,bl2)|0;hi=hi+Math.imul(ah6,bh2)|0;lo=lo+Math.imul(al5,bl3)|0;mid=mid+Math.imul(al5,bh3)|0;mid=mid+Math.imul(ah5,bl3)|0;hi=hi+Math.imul(ah5,bh3)|0;lo=lo+Math.imul(al4,bl4)|0;mid=mid+Math.imul(al4,bh4)|0;mid=mid+Math.imul(ah4,bl4)|0;hi=hi+Math.imul(ah4,bh4)|0;lo=lo+Math.imul(al3,bl5)|0;mid=mid+Math.imul(al3,bh5)|0;mid=mid+Math.imul(ah3,bl5)|0;hi=hi+Math.imul(ah3,bh5)|0;lo=lo+Math.imul(al2,bl6)|0;mid=mid+Math.imul(al2,bh6)|0;mid=mid+Math.imul(ah2,bl6)|0;hi=hi+Math.imul(ah2,bh6)|0;lo=lo+Math.imul(al1,bl7)|0;mid=mid+Math.imul(al1,bh7)|0;mid=mid+Math.imul(ah1,bl7)|0;hi=hi+Math.imul(ah1,bh7)|0;lo=lo+Math.imul(al0,bl8)|0;mid=mid+Math.imul(al0,bh8)|0;mid=mid+Math.imul(ah0,bl8)|0;hi=hi+Math.imul(ah0,bh8)|0;var w8=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w8>>>26)|0;w8&=0x3ffffff;/* k = 9 */lo=Math.imul(al9,bl0);mid=Math.imul(al9,bh0);mid=mid+Math.imul(ah9,bl0)|0;hi=Math.imul(ah9,bh0);lo=lo+Math.imul(al8,bl1)|0;mid=mid+Math.imul(al8,bh1)|0;mid=mid+Math.imul(ah8,bl1)|0;hi=hi+Math.imul(ah8,bh1)|0;lo=lo+Math.imul(al7,bl2)|0;mid=mid+Math.imul(al7,bh2)|0;mid=mid+Math.imul(ah7,bl2)|0;hi=hi+Math.imul(ah7,bh2)|0;lo=lo+Math.imul(al6,bl3)|0;mid=mid+Math.imul(al6,bh3)|0;mid=mid+Math.imul(ah6,bl3)|0;hi=hi+Math.imul(ah6,bh3)|0;lo=lo+Math.imul(al5,bl4)|0;mid=mid+Math.imul(al5,bh4)|0;mid=mid+Math.imul(ah5,bl4)|0;hi=hi+Math.imul(ah5,bh4)|0;lo=lo+Math.imul(al4,bl5)|0;mid=mid+Math.imul(al4,bh5)|0;mid=mid+Math.imul(ah4,bl5)|0;hi=hi+Math.imul(ah4,bh5)|0;lo=lo+Math.imul(al3,bl6)|0;mid=mid+Math.imul(al3,bh6)|0;mid=mid+Math.imul(ah3,bl6)|0;hi=hi+Math.imul(ah3,bh6)|0;lo=lo+Math.imul(al2,bl7)|0;mid=mid+Math.imul(al2,bh7)|0;mid=mid+Math.imul(ah2,bl7)|0;hi=hi+Math.imul(ah2,bh7)|0;lo=lo+Math.imul(al1,bl8)|0;mid=mid+Math.imul(al1,bh8)|0;mid=mid+Math.imul(ah1,bl8)|0;hi=hi+Math.imul(ah1,bh8)|0;lo=lo+Math.imul(al0,bl9)|0;mid=mid+Math.imul(al0,bh9)|0;mid=mid+Math.imul(ah0,bl9)|0;hi=hi+Math.imul(ah0,bh9)|0;var w9=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w9>>>26)|0;w9&=0x3ffffff;/* k = 10 */lo=Math.imul(al9,bl1);mid=Math.imul(al9,bh1);mid=mid+Math.imul(ah9,bl1)|0;hi=Math.imul(ah9,bh1);lo=lo+Math.imul(al8,bl2)|0;mid=mid+Math.imul(al8,bh2)|0;mid=mid+Math.imul(ah8,bl2)|0;hi=hi+Math.imul(ah8,bh2)|0;lo=lo+Math.imul(al7,bl3)|0;mid=mid+Math.imul(al7,bh3)|0;mid=mid+Math.imul(ah7,bl3)|0;hi=hi+Math.imul(ah7,bh3)|0;lo=lo+Math.imul(al6,bl4)|0;mid=mid+Math.imul(al6,bh4)|0;mid=mid+Math.imul(ah6,bl4)|0;hi=hi+Math.imul(ah6,bh4)|0;lo=lo+Math.imul(al5,bl5)|0;mid=mid+Math.imul(al5,bh5)|0;mid=mid+Math.imul(ah5,bl5)|0;hi=hi+Math.imul(ah5,bh5)|0;lo=lo+Math.imul(al4,bl6)|0;mid=mid+Math.imul(al4,bh6)|0;mid=mid+Math.imul(ah4,bl6)|0;hi=hi+Math.imul(ah4,bh6)|0;lo=lo+Math.imul(al3,bl7)|0;mid=mid+Math.imul(al3,bh7)|0;mid=mid+Math.imul(ah3,bl7)|0;hi=hi+Math.imul(ah3,bh7)|0;lo=lo+Math.imul(al2,bl8)|0;mid=mid+Math.imul(al2,bh8)|0;mid=mid+Math.imul(ah2,bl8)|0;hi=hi+Math.imul(ah2,bh8)|0;lo=lo+Math.imul(al1,bl9)|0;mid=mid+Math.imul(al1,bh9)|0;mid=mid+Math.imul(ah1,bl9)|0;hi=hi+Math.imul(ah1,bh9)|0;var w10=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w10>>>26)|0;w10&=0x3ffffff;/* k = 11 */lo=Math.imul(al9,bl2);mid=Math.imul(al9,bh2);mid=mid+Math.imul(ah9,bl2)|0;hi=Math.imul(ah9,bh2);lo=lo+Math.imul(al8,bl3)|0;mid=mid+Math.imul(al8,bh3)|0;mid=mid+Math.imul(ah8,bl3)|0;hi=hi+Math.imul(ah8,bh3)|0;lo=lo+Math.imul(al7,bl4)|0;mid=mid+Math.imul(al7,bh4)|0;mid=mid+Math.imul(ah7,bl4)|0;hi=hi+Math.imul(ah7,bh4)|0;lo=lo+Math.imul(al6,bl5)|0;mid=mid+Math.imul(al6,bh5)|0;mid=mid+Math.imul(ah6,bl5)|0;hi=hi+Math.imul(ah6,bh5)|0;lo=lo+Math.imul(al5,bl6)|0;mid=mid+Math.imul(al5,bh6)|0;mid=mid+Math.imul(ah5,bl6)|0;hi=hi+Math.imul(ah5,bh6)|0;lo=lo+Math.imul(al4,bl7)|0;mid=mid+Math.imul(al4,bh7)|0;mid=mid+Math.imul(ah4,bl7)|0;hi=hi+Math.imul(ah4,bh7)|0;lo=lo+Math.imul(al3,bl8)|0;mid=mid+Math.imul(al3,bh8)|0;mid=mid+Math.imul(ah3,bl8)|0;hi=hi+Math.imul(ah3,bh8)|0;lo=lo+Math.imul(al2,bl9)|0;mid=mid+Math.imul(al2,bh9)|0;mid=mid+Math.imul(ah2,bl9)|0;hi=hi+Math.imul(ah2,bh9)|0;var w11=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w11>>>26)|0;w11&=0x3ffffff;/* k = 12 */lo=Math.imul(al9,bl3);mid=Math.imul(al9,bh3);mid=mid+Math.imul(ah9,bl3)|0;hi=Math.imul(ah9,bh3);lo=lo+Math.imul(al8,bl4)|0;mid=mid+Math.imul(al8,bh4)|0;mid=mid+Math.imul(ah8,bl4)|0;hi=hi+Math.imul(ah8,bh4)|0;lo=lo+Math.imul(al7,bl5)|0;mid=mid+Math.imul(al7,bh5)|0;mid=mid+Math.imul(ah7,bl5)|0;hi=hi+Math.imul(ah7,bh5)|0;lo=lo+Math.imul(al6,bl6)|0;mid=mid+Math.imul(al6,bh6)|0;mid=mid+Math.imul(ah6,bl6)|0;hi=hi+Math.imul(ah6,bh6)|0;lo=lo+Math.imul(al5,bl7)|0;mid=mid+Math.imul(al5,bh7)|0;mid=mid+Math.imul(ah5,bl7)|0;hi=hi+Math.imul(ah5,bh7)|0;lo=lo+Math.imul(al4,bl8)|0;mid=mid+Math.imul(al4,bh8)|0;mid=mid+Math.imul(ah4,bl8)|0;hi=hi+Math.imul(ah4,bh8)|0;lo=lo+Math.imul(al3,bl9)|0;mid=mid+Math.imul(al3,bh9)|0;mid=mid+Math.imul(ah3,bl9)|0;hi=hi+Math.imul(ah3,bh9)|0;var w12=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w12>>>26)|0;w12&=0x3ffffff;/* k = 13 */lo=Math.imul(al9,bl4);mid=Math.imul(al9,bh4);mid=mid+Math.imul(ah9,bl4)|0;hi=Math.imul(ah9,bh4);lo=lo+Math.imul(al8,bl5)|0;mid=mid+Math.imul(al8,bh5)|0;mid=mid+Math.imul(ah8,bl5)|0;hi=hi+Math.imul(ah8,bh5)|0;lo=lo+Math.imul(al7,bl6)|0;mid=mid+Math.imul(al7,bh6)|0;mid=mid+Math.imul(ah7,bl6)|0;hi=hi+Math.imul(ah7,bh6)|0;lo=lo+Math.imul(al6,bl7)|0;mid=mid+Math.imul(al6,bh7)|0;mid=mid+Math.imul(ah6,bl7)|0;hi=hi+Math.imul(ah6,bh7)|0;lo=lo+Math.imul(al5,bl8)|0;mid=mid+Math.imul(al5,bh8)|0;mid=mid+Math.imul(ah5,bl8)|0;hi=hi+Math.imul(ah5,bh8)|0;lo=lo+Math.imul(al4,bl9)|0;mid=mid+Math.imul(al4,bh9)|0;mid=mid+Math.imul(ah4,bl9)|0;hi=hi+Math.imul(ah4,bh9)|0;var w13=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w13>>>26)|0;w13&=0x3ffffff;/* k = 14 */lo=Math.imul(al9,bl5);mid=Math.imul(al9,bh5);mid=mid+Math.imul(ah9,bl5)|0;hi=Math.imul(ah9,bh5);lo=lo+Math.imul(al8,bl6)|0;mid=mid+Math.imul(al8,bh6)|0;mid=mid+Math.imul(ah8,bl6)|0;hi=hi+Math.imul(ah8,bh6)|0;lo=lo+Math.imul(al7,bl7)|0;mid=mid+Math.imul(al7,bh7)|0;mid=mid+Math.imul(ah7,bl7)|0;hi=hi+Math.imul(ah7,bh7)|0;lo=lo+Math.imul(al6,bl8)|0;mid=mid+Math.imul(al6,bh8)|0;mid=mid+Math.imul(ah6,bl8)|0;hi=hi+Math.imul(ah6,bh8)|0;lo=lo+Math.imul(al5,bl9)|0;mid=mid+Math.imul(al5,bh9)|0;mid=mid+Math.imul(ah5,bl9)|0;hi=hi+Math.imul(ah5,bh9)|0;var w14=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w14>>>26)|0;w14&=0x3ffffff;/* k = 15 */lo=Math.imul(al9,bl6);mid=Math.imul(al9,bh6);mid=mid+Math.imul(ah9,bl6)|0;hi=Math.imul(ah9,bh6);lo=lo+Math.imul(al8,bl7)|0;mid=mid+Math.imul(al8,bh7)|0;mid=mid+Math.imul(ah8,bl7)|0;hi=hi+Math.imul(ah8,bh7)|0;lo=lo+Math.imul(al7,bl8)|0;mid=mid+Math.imul(al7,bh8)|0;mid=mid+Math.imul(ah7,bl8)|0;hi=hi+Math.imul(ah7,bh8)|0;lo=lo+Math.imul(al6,bl9)|0;mid=mid+Math.imul(al6,bh9)|0;mid=mid+Math.imul(ah6,bl9)|0;hi=hi+Math.imul(ah6,bh9)|0;var w15=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w15>>>26)|0;w15&=0x3ffffff;/* k = 16 */lo=Math.imul(al9,bl7);mid=Math.imul(al9,bh7);mid=mid+Math.imul(ah9,bl7)|0;hi=Math.imul(ah9,bh7);lo=lo+Math.imul(al8,bl8)|0;mid=mid+Math.imul(al8,bh8)|0;mid=mid+Math.imul(ah8,bl8)|0;hi=hi+Math.imul(ah8,bh8)|0;lo=lo+Math.imul(al7,bl9)|0;mid=mid+Math.imul(al7,bh9)|0;mid=mid+Math.imul(ah7,bl9)|0;hi=hi+Math.imul(ah7,bh9)|0;var w16=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w16>>>26)|0;w16&=0x3ffffff;/* k = 17 */lo=Math.imul(al9,bl8);mid=Math.imul(al9,bh8);mid=mid+Math.imul(ah9,bl8)|0;hi=Math.imul(ah9,bh8);lo=lo+Math.imul(al8,bl9)|0;mid=mid+Math.imul(al8,bh9)|0;mid=mid+Math.imul(ah8,bl9)|0;hi=hi+Math.imul(ah8,bh9)|0;var w17=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w17>>>26)|0;w17&=0x3ffffff;/* k = 18 */lo=Math.imul(al9,bl9);mid=Math.imul(al9,bh9);mid=mid+Math.imul(ah9,bl9)|0;hi=Math.imul(ah9,bh9);var w18=(c+lo|0)+((mid&0x1fff)<<13)|0;c=(hi+(mid>>>13)|0)+(w18>>>26)|0;w18&=0x3ffffff;o[0]=w0;o[1]=w1;o[2]=w2;o[3]=w3;o[4]=w4;o[5]=w5;o[6]=w6;o[7]=w7;o[8]=w8;o[9]=w9;o[10]=w10;o[11]=w11;o[12]=w12;o[13]=w13;o[14]=w14;o[15]=w15;o[16]=w16;o[17]=w17;o[18]=w18;if(c!==0){o[19]=c;out.length++;}return out;};// Polyfill comb
if(!Math.imul){comb10MulTo=smallMulTo;}function bigMulTo(self,num,out){out.negative=num.negative^self.negative;out.length=self.length+num.length;var carry=0;var hncarry=0;for(var k=0;k= 0x3ffffff
var ncarry=hncarry;hncarry=0;var rword=carry&0x3ffffff;var maxJ=Math.min(k,num.length-1);for(var j=Math.max(0,k-self.length+1);j<=maxJ;j++){var i=k-j;var a=self.words[i]|0;var b=num.words[j]|0;var r=a*b;var lo=r&0x3ffffff;ncarry=ncarry+(r/0x4000000|0)|0;lo=lo+rword|0;rword=lo&0x3ffffff;ncarry=ncarry+(lo>>>26)|0;hncarry+=ncarry>>>26;ncarry&=0x3ffffff;}out.words[k]=rword;carry=ncarry;ncarry=hncarry;}if(carry!==0){out.words[k]=carry;}else{out.length--;}return out.strip();}function jumboMulTo(self,num,out){var fftm=new FFTM();return fftm.mulp(self,num,out);}BN.prototype.mulTo=function mulTo(num,out){var res;var len=this.length+num.length;if(this.length===10&&num.length===10){res=comb10MulTo(this,num,out);}else if(len<63){res=smallMulTo(this,num,out);}else if(len<1024){res=bigMulTo(this,num,out);}else{res=jumboMulTo(this,num,out);}return res;};// Cooley-Tukey algorithm for FFT
// slightly revisited to rely on looping instead of recursion
function FFTM(x,y){this.x=x;this.y=y;}FFTM.prototype.makeRBT=function makeRBT(N){var t=new Array(N);var l=BN.prototype._countBits(N)-1;for(var i=0;i>=1;}return rb;};// Performs "tweedling" phase, therefore 'emulating'
// behaviour of the recursive algorithm
FFTM.prototype.permute=function permute(rbt,rws,iws,rtws,itws,N){for(var i=0;i>>1){i++;}return 1<>>13;rws[2*i+1]=carry&0x1fff;carry=carry>>>13;}// Pad with zeroes
for(i=2*len;i>=26;carry+=w/0x4000000|0;// NOTE: lo is 27bit maximum
carry+=lo>>>26;this.words[i]=lo&0x3ffffff;}if(carry!==0){this.words[i]=carry;this.length++;}return this;};BN.prototype.muln=function muln(num){return this.clone().imuln(num);};// `this` * `this`
BN.prototype.sqr=function sqr(){return this.mul(this);};// `this` * `this` in-place
BN.prototype.isqr=function isqr(){return this.imul(this.clone());};// Math.pow(`this`, `num`)
BN.prototype.pow=function pow(num){var w=toBitArray(num);if(w.length===0)return new BN(1);// Skip leading zeroes
var res=this;for(var i=0;i=0);var r=bits%26;var s=(bits-r)/26;var carryMask=0x3ffffff>>>26-r<<26-r;var i;if(r!==0){var carry=0;for(i=0;i>>26-r;}if(carry){this.words[i]=carry;this.length++;}}if(s!==0){for(i=this.length-1;i>=0;i--){this.words[i+s]=this.words[i];}for(i=0;i=0);var h;if(hint){h=(hint-hint%26)/26;}else{h=0;}var r=bits%26;var s=Math.min((bits-r)/26,this.length);var mask=0x3ffffff^0x3ffffff>>>r<s){this.length-=s;for(i=0;i=0&&(carry!==0||i>=h);i--){var word=this.words[i]|0;this.words[i]=carry<<26-r|word>>>r;carry=word&mask;}// Push carried bits as a mask
if(maskedWords&&carry!==0){maskedWords.words[maskedWords.length++]=carry;}if(this.length===0){this.words[0]=0;this.length=1;}return this.strip();};BN.prototype.ishrn=function ishrn(bits,hint,extended){// TODO(indutny): implement me
assert(this.negative===0);return this.iushrn(bits,hint,extended);};// Shift-left
BN.prototype.shln=function shln(bits){return this.clone().ishln(bits);};BN.prototype.ushln=function ushln(bits){return this.clone().iushln(bits);};// Shift-right
BN.prototype.shrn=function shrn(bits){return this.clone().ishrn(bits);};BN.prototype.ushrn=function ushrn(bits){return this.clone().iushrn(bits);};// Test if n bit is set
BN.prototype.testn=function testn(bit){assert(typeof bit==='number'&&bit>=0);var r=bit%26;var s=(bit-r)/26;var q=1<=0);var r=bits%26;var s=(bits-r)/26;assert(this.negative===0,'imaskn works only with positive numbers');if(this.length<=s){return this;}if(r!==0){s++;}this.length=Math.min(s,this.length);if(r!==0){var mask=0x3ffffff^0x3ffffff>>>r<=0x4000000;i++){this.words[i]-=0x4000000;if(i===this.length-1){this.words[i+1]=1;}else{this.words[i+1]++;}}this.length=Math.max(this.length,i+1);return this;};// Subtract plain number `num` from `this`
BN.prototype.isubn=function isubn(num){assert(typeof num==='number');assert(num<0x4000000);if(num<0)return this.iaddn(-num);if(this.negative!==0){this.negative=0;this.iaddn(num);this.negative=1;return this;}this.words[0]-=num;if(this.length===1&&this.words[0]<0){this.words[0]=-this.words[0];this.negative=1;}else{// Carry
for(var i=0;i>26)-(right/0x4000000|0);this.words[i+shift]=w&0x3ffffff;}for(;i>26;this.words[i+shift]=w&0x3ffffff;}if(carry===0)return this.strip();// Subtraction overflow
assert(carry===-1);carry=0;for(i=0;i>26;this.words[i]=w&0x3ffffff;}this.negative=1;return this.strip();};BN.prototype._wordDiv=function _wordDiv(num,mode){var shift=this.length-num.length;var a=this.clone();var b=num;// Normalize
var bhi=b.words[b.length-1]|0;var bhiBits=this._countBits(bhi);shift=26-bhiBits;if(shift!==0){b=b.ushln(shift);a.iushln(shift);bhi=b.words[b.length-1]|0;}// Initialize quotient
var m=a.length-b.length;var q;if(mode!=='mod'){q=new BN(null);q.length=m+1;q.words=new Array(q.length);for(var i=0;i=0;j--){var qj=(a.words[b.length+j]|0)*0x4000000+(a.words[b.length+j-1]|0);// NOTE: (qj / bhi) is (0x3ffffff * 0x4000000 + 0x3ffffff) / 0x2000000 max
// (0x7ffffff)
qj=Math.min(qj/bhi|0,0x3ffffff);a._ishlnsubmul(b,qj,j);while(a.negative!==0){qj--;a.negative=0;a._ishlnsubmul(b,1,j);if(!a.isZero()){a.negative^=1;}}if(q){q.words[j]=qj;}}if(q){q.strip();}a.strip();// Denormalize
if(mode!=='div'&&shift!==0){a.iushrn(shift);}return{div:q||null,mod:a};};// NOTE: 1) `mode` can be set to `mod` to request mod only,
// to `div` to request div only, or be absent to
// request both div & mod
// 2) `positive` is true if unsigned mod is requested
BN.prototype.divmod=function divmod(num,mode,positive){assert(!num.isZero());if(this.isZero()){return{div:new BN(0),mod:new BN(0)};}var div,mod,res;if(this.negative!==0&&num.negative===0){res=this.neg().divmod(num,mode);if(mode!=='mod'){div=res.div.neg();}if(mode!=='div'){mod=res.mod.neg();if(positive&&mod.negative!==0){mod.iadd(num);}}return{div:div,mod:mod};}if(this.negative===0&&num.negative!==0){res=this.divmod(num.neg(),mode);if(mode!=='mod'){div=res.div.neg();}return{div:div,mod:res.mod};}if((this.negative&num.negative)!==0){res=this.neg().divmod(num.neg(),mode);if(mode!=='div'){mod=res.mod.neg();if(positive&&mod.negative!==0){mod.isub(num);}}return{div:res.div,mod:mod};}// Both numbers are positive at this point
// Strip both numbers to approximate shift value
if(num.length>this.length||this.cmp(num)<0){return{div:new BN(0),mod:this};}// Very short reduction
if(num.length===1){if(mode==='div'){return{div:this.divn(num.words[0]),mod:null};}if(mode==='mod'){return{div:null,mod:new BN(this.modn(num.words[0]))};}return{div:this.divn(num.words[0]),mod:new BN(this.modn(num.words[0]))};}return this._wordDiv(num,mode);};// Find `this` / `num`
BN.prototype.div=function div(num){return this.divmod(num,'div',false).div;};// Find `this` % `num`
BN.prototype.mod=function mod(num){return this.divmod(num,'mod',false).mod;};BN.prototype.umod=function umod(num){return this.divmod(num,'mod',true).mod;};// Find Round(`this` / `num`)
BN.prototype.divRound=function divRound(num){var dm=this.divmod(num);// Fast case - exact division
if(dm.mod.isZero())return dm.div;var mod=dm.div.negative!==0?dm.mod.isub(num):dm.mod;var half=num.ushrn(1);var r2=num.andln(1);var cmp=mod.cmp(half);// Round down
if(cmp<0||r2===1&&cmp===0)return dm.div;// Round up
return dm.div.negative!==0?dm.div.isubn(1):dm.div.iaddn(1);};BN.prototype.modn=function modn(num){assert(num<=0x3ffffff);var p=(1<<26)%num;var acc=0;for(var i=this.length-1;i>=0;i--){acc=(p*acc+(this.words[i]|0))%num;}return acc;};// In-place division by number
BN.prototype.idivn=function idivn(num){assert(num<=0x3ffffff);var carry=0;for(var i=this.length-1;i>=0;i--){var w=(this.words[i]|0)+carry*0x4000000;this.words[i]=w/num|0;carry=w%num;}return this.strip();};BN.prototype.divn=function divn(num){return this.clone().idivn(num);};BN.prototype.egcd=function egcd(p){assert(p.negative===0);assert(!p.isZero());var x=this;var y=p.clone();if(x.negative!==0){x=x.umod(p);}else{x=x.clone();}// A * x + B * y = x
var A=new BN(1);var B=new BN(0);// C * x + D * y = y
var C=new BN(0);var D=new BN(1);var g=0;while(x.isEven()&&y.isEven()){x.iushrn(1);y.iushrn(1);++g;}var yp=y.clone();var xp=x.clone();while(!x.isZero()){for(var i=0,im=1;(x.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0){x.iushrn(i);while(i-->0){if(A.isOdd()||B.isOdd()){A.iadd(yp);B.isub(xp);}A.iushrn(1);B.iushrn(1);}}for(var j=0,jm=1;(y.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0){y.iushrn(j);while(j-->0){if(C.isOdd()||D.isOdd()){C.iadd(yp);D.isub(xp);}C.iushrn(1);D.iushrn(1);}}if(x.cmp(y)>=0){x.isub(y);A.isub(C);B.isub(D);}else{y.isub(x);C.isub(A);D.isub(B);}}return{a:C,b:D,gcd:y.iushln(g)};};// This is reduced incarnation of the binary EEA
// above, designated to invert members of the
// _prime_ fields F(p) at a maximal speed
BN.prototype._invmp=function _invmp(p){assert(p.negative===0);assert(!p.isZero());var a=this;var b=p.clone();if(a.negative!==0){a=a.umod(p);}else{a=a.clone();}var x1=new BN(1);var x2=new BN(0);var delta=b.clone();while(a.cmpn(1)>0&&b.cmpn(1)>0){for(var i=0,im=1;(a.words[0]&im)===0&&i<26;++i,im<<=1);if(i>0){a.iushrn(i);while(i-->0){if(x1.isOdd()){x1.iadd(delta);}x1.iushrn(1);}}for(var j=0,jm=1;(b.words[0]&jm)===0&&j<26;++j,jm<<=1);if(j>0){b.iushrn(j);while(j-->0){if(x2.isOdd()){x2.iadd(delta);}x2.iushrn(1);}}if(a.cmp(b)>=0){a.isub(b);x1.isub(x2);}else{b.isub(a);x2.isub(x1);}}var res;if(a.cmpn(1)===0){res=x1;}else{res=x2;}if(res.cmpn(0)<0){res.iadd(p);}return res;};BN.prototype.gcd=function gcd(num){if(this.isZero())return num.abs();if(num.isZero())return this.abs();var a=this.clone();var b=num.clone();a.negative=0;b.negative=0;// Remove common factor of two
for(var shift=0;a.isEven()&&b.isEven();shift++){a.iushrn(1);b.iushrn(1);}do{while(a.isEven()){a.iushrn(1);}while(b.isEven()){b.iushrn(1);}var r=a.cmp(b);if(r<0){// Swap `a` and `b` to make `a` always bigger than `b`
var t=a;a=b;b=t;}else if(r===0||b.cmpn(1)===0){break;}a.isub(b);}while(true);return b.iushln(shift);};// Invert number in the field F(num)
BN.prototype.invm=function invm(num){return this.egcd(num).a.umod(num);};BN.prototype.isEven=function isEven(){return(this.words[0]&1)===0;};BN.prototype.isOdd=function isOdd(){return(this.words[0]&1)===1;};// And first word and num
BN.prototype.andln=function andln(num){return this.words[0]#};// Increment at the bit position in-line
BN.prototype.bincn=function bincn(bit){assert(typeof bit==='number');var r=bit%26;var s=(bit-r)/26;var q=1<>>26;w&=0x3ffffff;this.words[i]=w;}if(carry!==0){this.words[i]=carry;this.length++;}return this;};BN.prototype.isZero=function isZero(){return this.length===1&&this.words[0]===0;};BN.prototype.cmpn=function cmpn(num){var negative=num<0;if(this.negative!==0&&!negative)return-1;if(this.negative===0&&negative)return 1;this.strip();var res;if(this.length>1){res=1;}else{if(negative){num=-num;}assert(num<=0x3ffffff,'Number is too big');var w=this.words[0]|0;res=w===num?0:w `num`
// 0 - if `this` == `num`
// -1 - if `this` < `num`
BN.prototype.cmp=function cmp(num){if(this.negative!==0&&num.negative===0)return-1;if(this.negative===0&&num.negative!==0)return 1;var res=this.ucmp(num);if(this.negative!==0)return-res|0;return res;};// Unsigned comparison
BN.prototype.ucmp=function ucmp(num){// At this point both numbers have the same sign
if(this.length>num.length)return 1;if(this.length=0;i--){var a=this.words[i]|0;var b=num.words[i]|0;if(a===b)continue;if(ab){res=1;}break;}return res;};BN.prototype.gtn=function gtn(num){return this.cmpn(num)===1;};BN.prototype.gt=function gt(num){return this.cmp(num)===1;};BN.prototype.gten=function gten(num){return this.cmpn(num)>=0;};BN.prototype.gte=function gte(num){return this.cmp(num)>=0;};BN.prototype.ltn=function ltn(num){return this.cmpn(num)===-1;};BN.prototype.lt=function lt(num){return this.cmp(num)===-1;};BN.prototype.lten=function lten(num){return this.cmpn(num)<=0;};BN.prototype.lte=function lte(num){return this.cmp(num)<=0;};BN.prototype.eqn=function eqn(num){return this.cmpn(num)===0;};BN.prototype.eq=function eq(num){return this.cmp(num)===0;};//
// A reduce context, could be using montgomery or something better, depending
// on the `m` itself.
//
BN.red=function red(num){return new Red(num);};BN.prototype.toRed=function toRed(ctx){assert(!this.red,'Already a number in reduction context');assert(this.negative===0,'red works only with positives');return ctx.convertTo(this)._forceRed(ctx);};BN.prototype.fromRed=function fromRed(){assert(this.red,'fromRed works only with numbers in reduction context');return this.red.convertFrom(this);};BN.prototype._forceRed=function _forceRed(ctx){this.red=ctx;return this;};BN.prototype.forceRed=function forceRed(ctx){assert(!this.red,'Already a number in reduction context');return this._forceRed(ctx);};BN.prototype.redAdd=function redAdd(num){assert(this.red,'redAdd works only with red numbers');return this.red.add(this,num);};BN.prototype.redIAdd=function redIAdd(num){assert(this.red,'redIAdd works only with red numbers');return this.red.iadd(this,num);};BN.prototype.redSub=function redSub(num){assert(this.red,'redSub works only with red numbers');return this.red.sub(this,num);};BN.prototype.redISub=function redISub(num){assert(this.red,'redISub works only with red numbers');return this.red.isub(this,num);};BN.prototype.redShl=function redShl(num){assert(this.red,'redShl works only with red numbers');return this.red.shl(this,num);};BN.prototype.redMul=function redMul(num){assert(this.red,'redMul works only with red numbers');this.red._verify2(this,num);return this.red.mul(this,num);};BN.prototype.redIMul=function redIMul(num){assert(this.red,'redMul works only with red numbers');this.red._verify2(this,num);return this.red.imul(this,num);};BN.prototype.redSqr=function redSqr(){assert(this.red,'redSqr works only with red numbers');this.red._verify1(this);return this.red.sqr(this);};BN.prototype.redISqr=function redISqr(){assert(this.red,'redISqr works only with red numbers');this.red._verify1(this);return this.red.isqr(this);};// Square root over p
BN.prototype.redSqrt=function redSqrt(){assert(this.red,'redSqrt works only with red numbers');this.red._verify1(this);return this.red.sqrt(this);};BN.prototype.redInvm=function redInvm(){assert(this.red,'redInvm works only with red numbers');this.red._verify1(this);return this.red.invm(this);};// Return negative clone of `this` % `red modulo`
BN.prototype.redNeg=function redNeg(){assert(this.red,'redNeg works only with red numbers');this.red._verify1(this);return this.red.neg(this);};BN.prototype.redPow=function redPow(num){assert(this.red&&!num.red,'redPow(normalNum)');this.red._verify1(this);return this.red.pow(this,num);};// Prime numbers with efficient reduction
var primes={k256:null,p224:null,p192:null,p25519:null};// Pseudo-Mersenne prime
function MPrime(name,p){// P = 2 ^ N - K
this.name=name;this.p=new BN(p,16);this.n=this.p.bitLength();this.k=new BN(1).iushln(this.n).isub(this.p);this.tmp=this._tmp();}MPrime.prototype._tmp=function _tmp(){var tmp=new BN(null);tmp.words=new Array(Math.ceil(this.n/13));return tmp;};MPrime.prototype.ireduce=function ireduce(num){// Assumes that `num` is less than `P^2`
// num = HI * (2 ^ N - K) + HI * K + LO = HI * K + LO (mod P)
var r=num;var rlen;do{this.split(r,this.tmp);r=this.imulK(r);r=r.iadd(this.tmp);rlen=r.bitLength();}while(rlen>this.n);var cmp=rlen0){r.isub(this.p);}else{if(r.strip!==undefined){// r is BN v4 instance
r.strip();}else{// r is BN v5 instance
r._strip();}}return r;};MPrime.prototype.split=function split(input,out){input.iushrn(this.n,0,out);};MPrime.prototype.imulK=function imulK(num){return num.imul(this.k);};function K256(){MPrime.call(this,'k256','ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f');}inherits(K256,MPrime);K256.prototype.split=function split(input,output){// 256 = 9 * 26 + 22
var mask=0x3fffff;var outLen=Math.min(input.length,9);for(var i=0;i>>22;prev=next;}prev>>>=22;input.words[i-10]=prev;if(prev===0&&input.length>10){input.length-=10;}else{input.length-=9;}};K256.prototype.imulK=function imulK(num){// K = 0x1000003d1 = [ 0x40, 0x3d1 ]
num.words[num.length]=0;num.words[num.length+1]=0;num.length+=2;// bounded at: 0x40 * 0x3ffffff + 0x3d0 = 0x100000390
var lo=0;for(var i=0;i>>=26;num.words[i]=lo;carry=hi;}if(carry!==0){num.words[num.length++]=carry;}return num;};// Exported mostly for testing purposes, use plain name instead
BN._prime=function prime(name){// Cached version of prime
if(primes[name])return primes[name];var prime;if(name==='k256'){prime=new K256();}else if(name==='p224'){prime=new P224();}else if(name==='p192'){prime=new P192();}else if(name==='p25519'){prime=new P25519();}else{throw new Error('Unknown prime '+name);}primes[name]=prime;return prime;};//
// Base reduction engine
//
function Red(m){if(typeof m==='string'){var prime=BN._prime(m);this.m=prime.p;this.prime=prime;}else{assert(m.gtn(1),'modulus must be greater than 1');this.m=m;this.prime=null;}}Red.prototype._verify1=function _verify1(a){assert(a.negative===0,'red works only with positives');assert(a.red,'red works only with red numbers');};Red.prototype._verify2=function _verify2(a,b){assert((a.negative|b.negative)===0,'red works only with positives');assert(a.red&&a.red===b.red,'red works only with red numbers');};Red.prototype.imod=function imod(a){if(this.prime)return this.prime.ireduce(a)._forceRed(this);return a.umod(this.m)._forceRed(this);};Red.prototype.neg=function neg(a){if(a.isZero()){return a.clone();}return this.m.sub(a)._forceRed(this);};Red.prototype.add=function add(a,b){this._verify2(a,b);var res=a.add(b);if(res.cmp(this.m)>=0){res.isub(this.m);}return res._forceRed(this);};Red.prototype.iadd=function iadd(a,b){this._verify2(a,b);var res=a.iadd(b);if(res.cmp(this.m)>=0){res.isub(this.m);}return res;};Red.prototype.sub=function sub(a,b){this._verify2(a,b);var res=a.sub(b);if(res.cmpn(0)<0){res.iadd(this.m);}return res._forceRed(this);};Red.prototype.isub=function isub(a,b){this._verify2(a,b);var res=a.isub(b);if(res.cmpn(0)<0){res.iadd(this.m);}return res;};Red.prototype.shl=function shl(a,num){this._verify1(a);return this.imod(a.ushln(num));};Red.prototype.imul=function imul(a,b){this._verify2(a,b);return this.imod(a.imul(b));};Red.prototype.mul=function mul(a,b){this._verify2(a,b);return this.imod(a.mul(b));};Red.prototype.isqr=function isqr(a){return this.imul(a,a.clone());};Red.prototype.sqr=function sqr(a){return this.mul(a,a);};Red.prototype.sqrt=function sqrt(a){if(a.isZero())return a.clone();var mod3=this.m.andln(3);assert(mod3%2===1);// Fast case
if(mod3===3){var pow=this.m.add(new BN(1)).iushrn(2);return this.pow(a,pow);}// Tonelli-Shanks algorithm (Totally unoptimized and slow)
//
// Find Q and S, that Q * 2 ^ S = (P - 1)
var q=this.m.subn(1);var s=0;while(!q.isZero()&&q.andln(1)===0){s++;q.iushrn(1);}assert(!q.isZero());var one=new BN(1).toRed(this);var nOne=one.redNeg();// Find quadratic non-residue
// NOTE: Max is such because of generalized Riemann hypothesis.
var lpow=this.m.subn(1).iushrn(1);var z=this.m.bitLength();z=new BN(2*z*z).toRed(this);while(this.pow(z,lpow).cmp(nOne)!==0){z.redIAdd(nOne);}var c=this.pow(z,q);var r=this.pow(a,q.addn(1).iushrn(1));var t=this.pow(a,q);var m=s;while(t.cmp(one)!==0){var tmp=t;for(var i=0;tmp.cmp(one)!==0;i++){tmp=tmp.redSqr();}assert(i=0;i--){var word=num.words[i];for(var j=start-1;j>=0;j--){var bit=word>>j&1;if(res!==wnd[0]){res=this.sqr(res);}if(bit===0&¤t===0){currentLen=0;continue;}current<<=1;current|=bit;currentLen++;if(currentLen!==windowSize&&(i!==0||j!==0))continue;res=this.mul(res,wnd[current]);currentLen=0;current=0;}start=26;}return res;};Red.prototype.convertTo=function convertTo(num){var r=num.umod(this.m);return r===num?r.clone():r;};Red.prototype.convertFrom=function convertFrom(num){var res=num.clone();res.red=null;return res;};//
// Montgomery method engine
//
BN.mont=function mont(num){return new Mont(num);};function Mont(m){Red.call(this,m);this.shift=this.m.bitLength();if(this.shift%26!==0){this.shift+=26-this.shift%26;}this.r=new BN(1).iushln(this.shift);this.r2=this.imod(this.r.sqr());this.rinv=this.r._invmp(this.m);this.minv=this.rinv.mul(this.r).isubn(1).div(this.m);this.minv=this.minv.umod(this.r);this.minv=this.r.sub(this.minv);}inherits(Mont,Red);Mont.prototype.convertTo=function convertTo(num){return this.imod(num.ushln(this.shift));};Mont.prototype.convertFrom=function convertFrom(num){var r=this.imod(num.mul(this.rinv));r.red=null;return r;};Mont.prototype.imul=function imul(a,b){if(a.isZero()||b.isZero()){a.words[0]=0;a.length=1;return a;}var t=a.imul(b);var c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);var u=t.isub(c).iushrn(this.shift);var res=u;if(u.cmp(this.m)>=0){res=u.isub(this.m);}else if(u.cmpn(0)<0){res=u.iadd(this.m);}return res._forceRed(this);};Mont.prototype.mul=function mul(a,b){if(a.isZero()||b.isZero())return new BN(0)._forceRed(this);var t=a.mul(b);var c=t.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m);var u=t.isub(c).iushrn(this.shift);var res=u;if(u.cmp(this.m)>=0){res=u.isub(this.m);}else if(u.cmpn(0)<0){res=u.iadd(this.m);}return res._forceRed(this);};Mont.prototype.invm=function invm(a){// (AR)^-1 * R^2 = (A^-1 * R^-1) * R^2 = A^-1 * R
var res=this.imod(a._invmp(this.m).mul(this.r2));return res._forceRed(this);};})( false||module,this);/***/},/***/6204:/***/function(module){"use strict";module.exports=boundary;function boundary(cells){var i,j,k;var n=cells.length;var sz=0;for(i=0;i>>1;if(d<=0){return;}var retval;//Convert red boxes
var redList=pool.mallocDouble(2*d*n);var redIds=pool.mallocInt32(n);n=convertBoxes(red,d,redList,redIds);if(n>0){if(d===1&&full){//Special case: 1d complete
sweep.init(n);retval=sweep.sweepComplete(d,visit,0,n,redList,redIds,0,n,redList,redIds);}else{//Convert blue boxes
var blueList=pool.mallocDouble(2*d*m);var blueIds=pool.mallocInt32(m);m=convertBoxes(blue,d,blueList,blueIds);if(m>0){sweep.init(n+m);if(d===1){//Special case: 1d bipartite
retval=sweep.sweepBipartite(d,visit,0,n,redList,redIds,0,m,blueList,blueIds);}else{//General case: d>1
retval=boxIntersectIter(d,visit,full,n,redList,redIds,m,blueList,blueIds);}pool.free(blueList);pool.free(blueIds);}}pool.free(redList);pool.free(redIds);}return retval;}var RESULT;function appendItem(i,j){RESULT.push([i,j]);}function intersectFullArray(x){RESULT=[];boxIntersect(x,x,appendItem,true);return RESULT;}function intersectBipartiteArray(x,y){RESULT=[];boxIntersect(x,y,appendItem,false);return RESULT;}//User-friendly wrapper, handle full input and no-visitor cases
function boxIntersectWrapper(arg0,arg1,arg2){switch(arguments.length){case 1:return intersectFullArray(arg0);case 2:if(typeof arg1==='function'){return boxIntersect(arg0,arg0,arg1,true);}else{return intersectBipartiteArray(arg0,arg1);}case 3:return boxIntersect(arg0,arg1,arg2,false);default:throw new Error('box-intersect: Invalid arguments');}}/***/},/***/2455:/***/function(__unused_webpack_module,exports){"use strict";function full(){function bruteForceRedFull(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi){var es=2*d;for(var i=rs,rp=es*rs;ibe-bs){return bruteForceRedFull(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi);}else{return bruteForceBlueFull(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi);}}return bruteForceFull;}function partial(){function bruteForceRedFlip(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi){var es=2*d;for(var i=rs,rp=es*rs;ibe-bs){if(fp){return bruteForceRedFlip(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi);}else{return bruteForceRed(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi);}}else{if(fp){return bruteForceBlueFlip(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi);}else{return bruteForceBlue(d,ax,vv,rs,re,rb,ri,bs,be,bb,bi);}}}return bruteForcePartial;}function bruteForcePlanner(isFull){return isFull?full():partial();}exports.partial=bruteForcePlanner(false);exports.full=bruteForcePlanner(true);/***/},/***/7150:/***/function(module,__unused_webpack_exports,__nested_webpack_require_141648__){"use strict";module.exports=boxIntersectIter;var pool=__nested_webpack_require_141648__(1888);var bits=__nested_webpack_require_141648__(8828);var bruteForce=__nested_webpack_require_141648__(2455);var bruteForcePartial=bruteForce.partial;var bruteForceFull=bruteForce.full;var sweep=__nested_webpack_require_141648__(855);var findMedian=__nested_webpack_require_141648__(3545);var genPartition=__nested_webpack_require_141648__(8105);//Twiddle parameters
var BRUTE_FORCE_CUTOFF=128;//Cut off for brute force search
var SCAN_CUTOFF=1<<22;//Cut off for two way scan
var SCAN_COMPLETE_CUTOFF=1<<22;//Partition functions
var partitionInteriorContainsInterval=genPartition('!(lo>=p0)&&!(p1>=hi)');var partitionStartEqual=genPartition('lo===p0');var partitionStartLessThan=genPartition('lo0){top-=1;var iptr=top*IFRAME_SIZE;var axis=BOX_ISTACK[iptr];var redStart=BOX_ISTACK[iptr+1];var redEnd=BOX_ISTACK[iptr+2];var blueStart=BOX_ISTACK[iptr+3];var blueEnd=BOX_ISTACK[iptr+4];var state=BOX_ISTACK[iptr+5];var dptr=top*DFRAME_SIZE;var lo=BOX_DSTACK[dptr];var hi=BOX_DSTACK[dptr+1];//Unpack state info
var flip=state&1;var full=!!(state&16);//Unpack indices
var red=xBoxes;var redIndex=xIndex;var blue=yBoxes;var blueIndex=yIndex;if(flip){red=yBoxes;redIndex=yIndex;blue=xBoxes;blueIndex=xIndex;}if(state&2){redEnd=partitionStartLessThan(d,axis,redStart,redEnd,red,redIndex,hi);if(redStart>=redEnd){continue;}}if(state&4){redStart=partitionEndLessThanEqual(d,axis,redStart,redEnd,red,redIndex,lo);if(redStart>=redEnd){continue;}}var redCount=redEnd-redStart;var blueCount=blueEnd-blueStart;if(full){if(d*redCount*(redCount+blueCount) mid point
//
var blue0=findMedian(d,axis,blueStart,blueEnd,blue,blueIndex);var mid=blue[elemSize*blue0+axis];var blue1=partitionStartEqual(d,axis,blue0,blueEnd,blue,blueIndex,mid);//Right case
if(blue1start&&boxes[ptr+axis]>x;--j,ptr-=elemSize){//Swap
var aPtr=ptr;var bPtr=ptr+elemSize;for(var k=0;k>>1;var elemSize=2*d;var pivot=mid;var value=boxes[elemSize*mid+axis];while(lo=value1){pivot=pivot1;value=value1;}else if(value0>=value2){pivot=pivot0;value=value0;}else{pivot=pivot2;value=value2;}}else{if(value1>=value2){pivot=pivot1;value=value1;}else if(value2>=value0){pivot=pivot0;value=value0;}else{pivot=pivot2;value=value2;}}//Swap pivot to end of array
var aPtr=elemSize*(hi-1);var bPtr=elemSize*pivot;for(var i=0;i=p0)&&!(p1>=hi)':lo_lessThan_p0_and_p1_lessThan_hi};function genPartition(predicate){return P2F[predicate];}// lo===p0
function lo_equal_p0(a,b,c,d,e,f,p0){for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var lo=e[k+n];if(lo===p0)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}// lop;++p,k+=j){var lo=e[k+n];if(los;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}// lo<=p0
function lo_lessOrEqual_p0(a,b,c,d,e,f,p0){for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var hi=e[k+o];if(hi<=p0)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}// hi<=p0
function hi_lessOrEqual_p0(a,b,c,d,e,f,p0){for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var hi=e[k+o];if(hi<=p0)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}// lo<=p0&&p0<=hi
function lo_lassOrEqual_p0_and_p0_lessOrEqual_hi(a,b,c,d,e,f,p0){for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var lo=e[k+n],hi=e[k+o];if(lo<=p0&&p0<=hi)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}// lop;++p,k+=j){var lo=e[k+n],hi=e[k+o];if(los;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}// !(lo>=p0)&&!(p1>=hi)
function lo_lessThan_p0_and_p1_lessThan_hi(a,b,c,d,e,f,p0,p1){for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var lo=e[k+n],hi=e[k+o];if(!(lo>=p0)&&!(p1>=hi))if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t;}var u=f[p];f[p]=f[m],f[m++]=u;}}return m;}/***/},/***/1811:/***/function(module){"use strict";//This code is extracted from ndarray-sort
//It is inlined here as a temporary workaround
module.exports=wrapper;var INSERT_SORT_CUTOFF=32;function wrapper(data,n0){if(n0<=4*INSERT_SORT_CUTOFF){insertionSort(0,n0-1,data);}else{quickSort(0,n0-1,data);}}function insertionSort(left,right,data){var ptr=2*(left+1);for(var i=left+1;i<=right;++i){var a=data[ptr++];var b=data[ptr++];var j=i;var jptr=ptr-2;while(j-->left){var x=data[jptr-2];var y=data[jptr-1];if(xdata[j+1];}return true;}function comparePivot(i,y,b,data){i*=2;var x=data[i];if(x>1,index2=index3-sixth,index4=index3+sixth,el1=index1,el2=index2,el3=index3,el4=index4,el5=index5,less=left+1,great=right-1,tmp=0;if(compare(el1,el2,data)){tmp=el1;el1=el2;el2=tmp;}if(compare(el4,el5,data)){tmp=el4;el4=el5;el5=tmp;}if(compare(el1,el3,data)){tmp=el1;el1=el3;el3=tmp;}if(compare(el2,el3,data)){tmp=el2;el2=el3;el3=tmp;}if(compare(el1,el4,data)){tmp=el1;el1=el4;el4=tmp;}if(compare(el3,el4,data)){tmp=el3;el3=el4;el4=tmp;}if(compare(el2,el5,data)){tmp=el2;el2=el5;el5=tmp;}if(compare(el2,el3,data)){tmp=el2;el2=el3;el3=tmp;}if(compare(el4,el5,data)){tmp=el4;el4=el5;el5=tmp;}var pivot1X=data[2*el2];var pivot1Y=data[2*el2+1];var pivot2X=data[2*el4];var pivot2Y=data[2*el4+1];var ptr0=2*el1;var ptr2=2*el3;var ptr4=2*el5;var ptr5=2*index1;var ptr6=2*index3;var ptr7=2*index5;for(var i1=0;i1<2;++i1){var x=data[ptr0+i1];var y=data[ptr2+i1];var z=data[ptr4+i1];data[ptr5+i1]=x;data[ptr6+i1]=y;data[ptr7+i1]=z;}move(index2,left,data);move(index4,right,data);for(var k=less;k<=great;++k){if(comparePivot(k,pivot1X,pivot1Y,data)){if(k!==less){swap(k,less,data);}++less;}else{if(!comparePivot(k,pivot2X,pivot2Y,data)){while(true){if(!comparePivot(great,pivot2X,pivot2Y,data)){if(--greatright
var n=ptr>>>1;isort(SWEEP_EVENTS,n);var redActive=0;var blueActive=0;for(var i=0;i=BLUE_FLAG){//blue destroy event
e=e-BLUE_FLAG|0;sqPop(BLUE_SWEEP_QUEUE,BLUE_SWEEP_INDEX,blueActive--,e);}else if(e>=0){//red destroy event
sqPop(RED_SWEEP_QUEUE,RED_SWEEP_INDEX,redActive--,e);}else if(e<=-BLUE_FLAG){//blue create event
e=-e-BLUE_FLAG|0;for(var j=0;jright
var n=ptr>>>1;isort(SWEEP_EVENTS,n);var redActive=0;var blueActive=0;var commonActive=0;for(var i=0;i>1===SWEEP_EVENTS[2*i+3]>>1){color=2;i+=1;}if(e<0){//Create event
var id=-(e>>1)-1;//Intersect with common
for(var j=0;j>1)-1;if(color===0){//Red
sqPop(RED_SWEEP_QUEUE,RED_SWEEP_INDEX,redActive--,id);}else if(color===1){//Blue
sqPop(BLUE_SWEEP_QUEUE,BLUE_SWEEP_INDEX,blueActive--,id);}else if(color===2){//Both
sqPop(COMMON_SWEEP_QUEUE,COMMON_SWEEP_INDEX,commonActive--,id);}}}}//Sweep and prune/scanline algorithm:
// Scan along axis, detect intersections
// Brute force all boxes along axis
function scanBipartite(d,axis,visit,flip,redStart,redEnd,red,redIndex,blueStart,blueEnd,blue,blueIndex){var ptr=0;var elemSize=2*d;var istart=axis;var iend=axis+d;var redShift=1;var blueShift=1;if(flip){blueShift=BLUE_FLAG;}else{redShift=BLUE_FLAG;}for(var i=redStart;iright
var n=ptr>>>1;isort(SWEEP_EVENTS,n);var redActive=0;for(var i=0;i=BLUE_FLAG){isRed=!flip;idx-=BLUE_FLAG;}else{isRed=!!flip;idx-=1;}if(isRed){sqPush(RED_SWEEP_QUEUE,RED_SWEEP_INDEX,redActive++,idx);}else{var blueId=blueIndex[idx];var bluePtr=elemSize*idx;var b0=blue[bluePtr+axis+1];var b1=blue[bluePtr+axis+1+d];red_loop:for(var j=0;jright
var n=ptr>>>1;isort(SWEEP_EVENTS,n);var redActive=0;for(var i=0;i=BLUE_FLAG){RED_SWEEP_QUEUE[redActive++]=idx-BLUE_FLAG;}else{idx-=1;var blueId=blueIndex[idx];var bluePtr=elemSize*idx;var b0=blue[bluePtr+axis+1];var b1=blue[bluePtr+axis+1+d];red_loop:for(var j=0;j=0;--j){if(RED_SWEEP_QUEUE[j]===idx){for(var k=j+1;k0){var b=stack.pop();var a=stack.pop();//Find opposite pairs
var x=-1,y=-1;var star=stars[a];for(var i=1;i=0){continue;}//Flip the edge
triangulation.flip(a,b);//Test flipping neighboring edges
testFlip(points,triangulation,stack,x,a,y);testFlip(points,triangulation,stack,a,y,x);testFlip(points,triangulation,stack,y,b,x);testFlip(points,triangulation,stack,b,x,y);}}/***/},/***/5023:/***/function(module,__unused_webpack_exports,__nested_webpack_require_170291__){"use strict";var bsearch=__nested_webpack_require_170291__(2478);module.exports=classifyFaces;function FaceIndex(cells,neighbor,constraint,flags,active,next,boundary){this.cells=cells;this.neighbor=neighbor;this.flags=flags;this.constraint=constraint;this.active=active;this.next=next;this.boundary=boundary;}var proto=FaceIndex.prototype;function compareCell(a,b){return a[0]-b[0]||a[1]-b[1]||a[2]-b[2];}proto.locate=function(){var key=[0,0,0];return function(a,b,c){var x=a,y=b,z=c;if(b0||next.length>0){while(active.length>0){var t=active.pop();if(flags[t]===-side){continue;}flags[t]=side;var c=cells[t];for(var j=0;j<3;++j){var f=neighbor[3*t+j];if(f>=0&&flags[f]===0){if(constraint[3*t+j]){next.push(f);}else{active.push(f);flags[f]=side;}}}}//Swap arrays and loop
var tmp=next;next=active;active=tmp;next.length=0;side=-side;}var result=filterCells(cells,flags,target);if(infinity){return result.concat(index.boundary);}return result;}/***/},/***/8902:/***/function(module,__unused_webpack_exports,__nested_webpack_require_172942__){"use strict";var bsearch=__nested_webpack_require_172942__(2478);var orient=__nested_webpack_require_172942__(3250)[3];var EVENT_POINT=0;var EVENT_END=1;var EVENT_START=2;module.exports=monotoneTriangulate;//A partial convex hull fragment, made of two unimonotone polygons
function PartialHull(a,b,idx,lowerIds,upperIds){this.a=a;this.b=b;this.idx=idx;this.lowerIds=lowerIds;this.upperIds=upperIds;}//An event in the sweep line procedure
function Event(a,b,type,idx){this.a=a;this.b=b;this.type=type;this.idx=idx;}//This is used to compare events for the sweep line procedure
// Points are:
// 1. sorted lexicographically
// 2. sorted by type (point < end < start)
// 3. segments sorted by winding order
// 4. sorted by index
function compareEvent(a,b){var d=a.a[0]-b.a[0]||a.a[1]-b.a[1]||a.type-b.type;if(d){return d;}if(a.type!==EVENT_POINT){d=orient(a.a,a.b,b.b);if(d){return d;}}return a.idx-b.idx;}function testPoint(hull,p){return orient(hull.a,hull.b,p);}function addPoint(cells,hulls,points,p,idx){var lo=bsearch.lt(hulls,p,testPoint);var hi=bsearch.gt(hulls,p,testPoint);for(var i=lo;i1&&orient(points[lowerIds[m-2]],points[lowerIds[m-1]],p)>0){cells.push([lowerIds[m-1],lowerIds[m-2],idx]);m-=1;}lowerIds.length=m;lowerIds.push(idx);//Insert p into upper hull
var upperIds=hull.upperIds;var m=upperIds.length;while(m>1&&orient(points[upperIds[m-2]],points[upperIds[m-1]],p)<0){cells.push([upperIds[m-2],upperIds[m-1],idx]);m-=1;}upperIds.length=m;upperIds.push(idx);}}function findSplit(hull,edge){var d;if(hull.a[0]b[0]){events.push(new Event(b,a,EVENT_START,i),new Event(a,b,EVENT_END,i));}}//Sort events
events.sort(compareEvent);//Initialize hull
var minX=events[0].a[0]-(1+Math.abs(events[0].a[0]))*Math.pow(2,-52);var hull=[new PartialHull([minX,1],[minX,0],-1,[],[],[],[])];//Process events in order
var cells=[];for(var i=0,numEvents=events.length;i=0;};}();proto.removeTriangle=function(i,j,k){var stars=this.stars;removePair(stars[i],j,k);removePair(stars[j],k,i);removePair(stars[k],i,j);};proto.addTriangle=function(i,j,k){var stars=this.stars;stars[i].push(j,k);stars[j].push(k,i);stars[k].push(i,j);};proto.opposite=function(j,i){var list=this.stars[i];for(var k=1,n=list.length;k=0;--i){var junction=junctions[i];e=junction[0];var edge=edges[e];var s=edge[0];var t=edge[1];// Check if edge is not lexicographically sorted
var a=floatPoints[s];var b=floatPoints[t];if((a[0]-b[0]||a[1]-b[1])<0){var tmp=s;s=t;t=tmp;}// Split leading edge
edge[0]=s;var last=edge[1]=junction[1];// If we are grouping edges by color, remember to track data
var color;if(useColor){color=edge[2];}// Split other edges
while(i>0&&junctions[i-1][0]===e){var junction=junctions[--i];var next=junction[1];if(useColor){edges.push([last,next,color]);}else{edges.push([last,next]);}last=next;}// Add final edge
if(useColor){edges.push([last,t,color]);}else{edges.push([last,t]);}}// Return constructed rational points
return ratPoints;}// Merge overlapping points
function dedupPoints(floatPoints,ratPoints,floatBounds){var numPoints=ratPoints.length;var uf=new UnionFind(numPoints);// Compute rational bounds
var bounds=[];for(var i=0;ib[2]){return 1;}return 0;}// Remove duplicate edge labels
function dedupEdges(edges,labels,useColor){if(edges.length===0){return;}if(labels){for(var i=0;i0||tjunctions.length>0;}// More iterations necessary
return true;}// Main loop, runs PSLG clean up until completion
function cleanPSLG(points,edges,colors){// If using colors, augment edges with color data
var prevEdges;if(colors){prevEdges=edges;var augEdges=new Array(edges.length);for(var i=0;inshades+1){throw new Error(colormap+' map requires nshades to be at least size '+cmap.length);}if(!Array.isArray(spec.alpha)){if(typeof spec.alpha==='number'){alpha=[spec.alpha,spec.alpha];}else{alpha=[1,1];}}else if(spec.alpha.length!==2){alpha=[1,1];}else{alpha=spec.alpha.slice();}// map index points from 0..1 to 0..n-1
indicies=cmap.map(function(c){return Math.round(c.index*nshades);});// Add alpha channel to the map
alpha[0]=Math.min(Math.max(alpha[0],0),1);alpha[1]=Math.min(Math.max(alpha[1],0),1);var steps=cmap.map(function(c,i){var index=cmap[i].index;var rgba=cmap[i].rgb.slice();// if user supplies their own map use it
if(rgba.length===4&&rgba[3]>=0&&rgba[3]<=1){return rgba;}rgba[3]=alpha[0]+(alpha[1]-alpha[0])*index;return rgba;});/*
* map increasing linear values between indicies to
* linear steps in colorvalues
*/var colors=[];for(i=0;i=0;}function compareAngle(a,b,c,d){var bcd=orient(b,c,d);if(bcd===0){//Handle degenerate cases
var sabc=sgn(orient(a,b,c));var sabd=sgn(orient(a,b,d));if(sabc===sabd){if(sabc===0){var ic=testInterior(a,b,c);var id=testInterior(a,b,d);if(ic===id){return 0;}else if(ic){return 1;}else{return-1;}}return 0;}else if(sabd===0){if(sabc>0){return-1;}else if(testInterior(a,b,d)){return-1;}else{return 1;}}else if(sabc===0){if(sabd>0){return 1;}else if(testInterior(a,b,c)){return 1;}else{return-1;}}return sgn(sabd-sabc);}var abc=orient(a,b,c);if(abc>0){if(bcd>0&&orient(a,b,d)>0){return 1;}return-1;}else if(abc<0){if(bcd>0||orient(a,b,d)>0){return 1;}return-1;}else{var abd=orient(a,b,d);if(abd>0){return 1;}else{if(testInterior(a,b,c)){return 1;}else{return-1;}}}}/***/},/***/8572:/***/function(module){"use strict";module.exports=function signum(x){if(x<0){return-1;}if(x>0){return 1;}return 0.0;};/***/},/***/8507:/***/function(module){module.exports=compareCells;var min=Math.min;function compareInt(a,b){return a-b;}function compareCells(a,b){var n=a.length,t=a.length-b.length;if(t){return t;}switch(n){case 0:return 0;case 1:return a[0]-b[0];case 2:return a[0]+a[1]-b[0]-b[1]||min(a[0],a[1])-min(b[0],b[1]);case 3:var l1=a[0]+a[1],m1=b[0]+b[1];t=l1+a[2]-(m1+b[2]);if(t){return t;}var l0=min(a[0],a[1]),m0=min(b[0],b[1]);return min(l0,a[2])-min(m0,b[2])||min(l0+a[2],l1)-min(m0+b[2],m1);case 4:var aw=a[0],ax=a[1],ay=a[2],az=a[3],bw=b[0],bx=b[1],by=b[2],bz=b[3];return aw+ax+ay+az-(bw+bx+by+bz)||min(aw,ax,ay,az)-min(bw,bx,by,bz,bw)||min(aw+ax,aw+ay,aw+az,ax+ay,ax+az,ay+az)-min(bw+bx,bw+by,bw+bz,bx+by,bx+bz,by+bz)||min(aw+ax+ay,aw+ax+az,aw+ay+az,ax+ay+az)-min(bw+bx+by,bw+bx+bz,bw+by+bz,bx+by+bz);default:var as=a.slice().sort(compareInt);var bs=b.slice().sort(compareInt);for(var i=0;ipoints[hi][0]){hi=i;}}if(lohi){return[[hi],[lo]];}else{return[[lo]];}}/***/},/***/4750:/***/function(module,__unused_webpack_exports,__nested_webpack_require_205357__){"use strict";module.exports=convexHull2D;var monotoneHull=__nested_webpack_require_205357__(3090);function convexHull2D(points){var hull=monotoneHull(points);var h=hull.length;if(h<=2){return[];}var edges=new Array(h);var a=hull[h-1];for(var i=0;i=front[k]){x+=1;}}c[j]=x;}}}return cells;}function convexHullnD(points,d){try{return ich(points,true);}catch(e){//If point set is degenerate, try to find a basis and rerun it
var ah=aff(points);if(ah.length<=d){//No basis, no try
return[];}var npoints=permute(points,ah);var nhull=ich(npoints,true);return invPermute(nhull,ah);}}/***/},/***/4769:/***/function(module){"use strict";function dcubicHermite(p0,v0,p1,v1,t,f){var dh00=6*t*t-6*t,dh10=3*t*t-4*t+1,dh01=-6*t*t+6*t,dh11=3*t*t-2*t;if(p0.length){if(!f){f=new Array(p0.length);}for(var i=p0.length-1;i>=0;--i){f[i]=dh00*p0[i]+dh10*v0[i]+dh01*p1[i]+dh11*v1[i];}return f;}return dh00*p0+dh10*v0+dh01*p1[i]+dh11*v1;}function cubicHermite(p0,v0,p1,v1,t,f){var ti=t-1,t2=t*t,ti2=ti*ti,h00=(1+2*t)*ti2,h10=t*ti2,h01=t2*(3-2*t),h11=t2*ti;if(p0.length){if(!f){f=new Array(p0.length);}for(var i=p0.length-1;i>=0;--i){f[i]=h00*p0[i]+h10*v0[i]+h01*p1[i]+h11*v1[i];}return f;}return h00*p0+h10*v0+h01*p1+h11*v1;}module.exports=cubicHermite;module.exports.derivative=dcubicHermite;/***/},/***/7642:/***/function(module,__unused_webpack_exports,__nested_webpack_require_207403__){"use strict";var ch=__nested_webpack_require_207403__(8954);var uniq=__nested_webpack_require_207403__(1682);module.exports=triangulate;function LiftedPoint(p,i){this.point=p;this.index=i;}function compareLifted(a,b){var ap=a.point;var bp=b.point;var d=ap.length;for(var i=0;i=2){return false;}}cell[j]=v;}return true;});}else{hull=hull.filter(function(cell){for(var i=0;i<=d;++i){var v=dindex[cell[i]];if(v<0){return false;}cell[i]=v;}return true;});}if(d&1){for(var i=0;i>>31;};module.exports.exponent=function(n){var b=module.exports.hi(n);return(b<<1>>>21)-1023;};module.exports.fraction=function(n){var lo=module.exports.lo(n);var hi=module.exports.hi(n);var b=hi&(1<<20)-1;if(hi&0x7ff00000){b+=1<<20;}return[lo,b];};module.exports.denormalized=function(n){var hi=module.exports.hi(n);return!(hi&0x7ff00000);};/***/},/***/1338:/***/function(module){"use strict";function dupe_array(count,value,i){var c=count[i]|0;if(c<=0){return[];}var result=new Array(c),j;if(i===count.length-1){for(j=0;j0){return dupe_number(count|0,value);}break;case"object":if(typeof count.length==="number"){return dupe_array(count,value,0);}break;}return[];}module.exports=dupe;/***/},/***/3134:/***/function(module,__unused_webpack_exports,__nested_webpack_require_212399__){"use strict";module.exports=edgeToAdjacency;var uniq=__nested_webpack_require_212399__(1682);function edgeToAdjacency(edges,numVertices){var numEdges=edges.length;if(typeof numVertices!=="number"){numVertices=0;for(var i=0;i=n-1){var ptr=state.length-1;var tf=t-time[n-1];for(var i=0;i=n-1){var ptr=state.length-1;var tf=t-time[n-1];for(var i=0;i=0;--i){if(velocity[--ptr]){return false;}}return true;};proto.jump=function(t){var t0=this.lastT();var d=this.dimension;if(t0;--i){state.push(clamp(lo[i-1],hi[i-1],arguments[i]));velocity.push(0);}};proto.push=function(t){var t0=this.lastT();var d=this.dimension;if(t1e-6?1/dt:0;this._time.push(t);for(var i=d;i>0;--i){var xc=clamp(lo[i-1],hi[i-1],arguments[i]);state.push(xc);velocity.push((xc-state[ptr++])*sf);}};proto.set=function(t){var d=this.dimension;if(t0;--i){state.push(clamp(lo[i-1],hi[i-1],arguments[i]));velocity.push(0);}};proto.move=function(t){var t0=this.lastT();var d=this.dimension;if(t<=t0||arguments.length!==d+1){return;}var state=this._state;var velocity=this._velocity;var statePtr=state.length-this.dimension;var bounds=this.bounds;var lo=bounds[0];var hi=bounds[1];var dt=t-t0;var sf=dt>1e-6?1/dt:0.0;this._time.push(t);for(var i=d;i>0;--i){var dx=arguments[i];state.push(clamp(lo[i-1],hi[i-1],state[statePtr++]+dx));velocity.push(dx*sf);}};proto.idle=function(t){var t0=this.lastT();if(t=0;--i){state.push(clamp(lo[i],hi[i],state[statePtr]+dt*velocity[statePtr]));velocity.push(0);statePtr+=1;}};function getZero(d){var result=new Array(d);for(var i=0;i=0;--s){var n=n_stack[s];if(d_stack[s]<=0){n_stack[s]=new RBNode(n._color,n.key,n.value,n_stack[s+1],n.right,n._count+1);}else{n_stack[s]=new RBNode(n._color,n.key,n.value,n.left,n_stack[s+1],n._count+1);}}//Rebalance tree using rotations
//console.log("start insert", key, d_stack)
for(var s=n_stack.length-1;s>1;--s){var p=n_stack[s-1];var n=n_stack[s];if(p._color===BLACK||n._color===BLACK){break;}var pp=n_stack[s-2];if(pp.left===p){if(p.left===n){var y=pp.right;if(y&&y._color===RED){//console.log("LLr")
p._color=BLACK;pp.right=repaint(BLACK,y);pp._color=RED;s-=1;}else{//console.log("LLb")
pp._color=RED;pp.left=p.right;p._color=BLACK;p.right=pp;n_stack[s-2]=p;n_stack[s-1]=n;recount(pp);recount(p);if(s>=3){var ppp=n_stack[s-3];if(ppp.left===pp){ppp.left=p;}else{ppp.right=p;}}break;}}else{var y=pp.right;if(y&&y._color===RED){//console.log("LRr")
p._color=BLACK;pp.right=repaint(BLACK,y);pp._color=RED;s-=1;}else{//console.log("LRb")
p.right=n.left;pp._color=RED;pp.left=n.right;n._color=BLACK;n.left=p;n.right=pp;n_stack[s-2]=n;n_stack[s-1]=p;recount(pp);recount(p);recount(n);if(s>=3){var ppp=n_stack[s-3];if(ppp.left===pp){ppp.left=n;}else{ppp.right=n;}}break;}}}else{if(p.right===n){var y=pp.left;if(y&&y._color===RED){//console.log("RRr", y.key)
p._color=BLACK;pp.left=repaint(BLACK,y);pp._color=RED;s-=1;}else{//console.log("RRb")
pp._color=RED;pp.right=p.left;p._color=BLACK;p.left=pp;n_stack[s-2]=p;n_stack[s-1]=n;recount(pp);recount(p);if(s>=3){var ppp=n_stack[s-3];if(ppp.right===pp){ppp.right=p;}else{ppp.left=p;}}break;}}else{var y=pp.left;if(y&&y._color===RED){//console.log("RLr")
p._color=BLACK;pp.left=repaint(BLACK,y);pp._color=RED;s-=1;}else{//console.log("RLb")
p.left=n.right;pp._color=RED;pp.right=n.left;n._color=BLACK;n.right=p;n.left=pp;n_stack[s-2]=n;n_stack[s-1]=p;recount(pp);recount(p);recount(n);if(s>=3){var ppp=n_stack[s-3];if(ppp.right===pp){ppp.right=n;}else{ppp.left=n;}}break;}}}}//Return new tree
n_stack[0]._color=BLACK;return new RedBlackTree(cmp,n_stack[0]);};//Visit all nodes inorder
function doVisitFull(visit,node){if(node.left){var v=doVisitFull(visit,node.left);if(v){return v;}}var v=visit(node.key,node.value);if(v){return v;}if(node.right){return doVisitFull(visit,node.right);}}//Visit half nodes in order
function doVisitHalf(lo,compare,visit,node){var l=compare(lo,node.key);if(l<=0){if(node.left){var v=doVisitHalf(lo,compare,visit,node.left);if(v){return v;}}var v=visit(node.key,node.value);if(v){return v;}}if(node.right){return doVisitHalf(lo,compare,visit,node.right);}}//Visit all nodes within a range
function doVisit(lo,hi,compare,visit,node){var l=compare(lo,node.key);var h=compare(hi,node.key);var v;if(l<=0){if(node.left){v=doVisit(lo,hi,compare,visit,node.left);if(v){return v;}}if(h>0){v=visit(node.key,node.value);if(v){return v;}}}if(h>0&&node.right){return doVisit(lo,hi,compare,visit,node.right);}}proto.forEach=function rbTreeForEach(visit,lo,hi){if(!this.root){return;}switch(arguments.length){case 1:return doVisitFull(visit,this.root);break;case 2:return doVisitHalf(lo,this._compare,visit,this.root);break;case 3:if(this._compare(lo,hi)>=0){return;}return doVisit(lo,hi,this._compare,visit,this.root);break;}};//First item in list
Object.defineProperty(proto,"begin",{get:function(){var stack=[];var n=this.root;while(n){stack.push(n);n=n.left;}return new RedBlackTreeIterator(this,stack);}});//Last item in list
Object.defineProperty(proto,"end",{get:function(){var stack=[];var n=this.root;while(n){stack.push(n);n=n.right;}return new RedBlackTreeIterator(this,stack);}});//Find the ith item in the tree
proto.at=function(idx){if(idx<0){return new RedBlackTreeIterator(this,[]);}var n=this.root;var stack=[];while(true){stack.push(n);if(n.left){if(idx=n.right._count){break;}n=n.right;}else{break;}}return new RedBlackTreeIterator(this,[]);};proto.ge=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d<=0){last_ptr=stack.length;}if(d<=0){n=n.left;}else{n=n.right;}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack);};proto.gt=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d<0){last_ptr=stack.length;}if(d<0){n=n.left;}else{n=n.right;}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack);};proto.lt=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d>0){last_ptr=stack.length;}if(d<=0){n=n.left;}else{n=n.right;}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack);};proto.le=function(key){var cmp=this._compare;var n=this.root;var stack=[];var last_ptr=0;while(n){var d=cmp(key,n.key);stack.push(n);if(d>=0){last_ptr=stack.length;}if(d<0){n=n.left;}else{n=n.right;}}stack.length=last_ptr;return new RedBlackTreeIterator(this,stack);};//Finds the item with key if it exists
proto.find=function(key){var cmp=this._compare;var n=this.root;var stack=[];while(n){var d=cmp(key,n.key);stack.push(n);if(d===0){return new RedBlackTreeIterator(this,stack);}if(d<=0){n=n.left;}else{n=n.right;}}return new RedBlackTreeIterator(this,[]);};//Removes item with key from tree
proto.remove=function(key){var iter=this.find(key);if(iter){return iter.remove();}return this;};//Returns the item at `key`
proto.get=function(key){var cmp=this._compare;var n=this.root;while(n){var d=cmp(key,n.key);if(d===0){return n.value;}if(d<=0){n=n.left;}else{n=n.right;}}return;};//Iterator for red black tree
function RedBlackTreeIterator(tree,stack){this.tree=tree;this._stack=stack;}var iproto=RedBlackTreeIterator.prototype;//Test if iterator is valid
Object.defineProperty(iproto,"valid",{get:function(){return this._stack.length>0;}});//Node of the iterator
Object.defineProperty(iproto,"node",{get:function(){if(this._stack.length>0){return this._stack[this._stack.length-1];}return null;},enumerable:true});//Makes a copy of an iterator
iproto.clone=function(){return new RedBlackTreeIterator(this.tree,this._stack.slice());};//Swaps two nodes
function swapNode(n,v){n.key=v.key;n.value=v.value;n.left=v.left;n.right=v.right;n._color=v._color;n._count=v._count;}//Fix up a double black node in a tree
function fixDoubleBlack(stack){var n,p,s,z;for(var i=stack.length-1;i>=0;--i){n=stack[i];if(i===0){n._color=BLACK;return;}//console.log("visit node:", n.key, i, stack[i].key, stack[i-1].key)
p=stack[i-1];if(p.left===n){//console.log("left child")
s=p.right;if(s.right&&s.right._color===RED){//console.log("case 1: right sibling child red")
s=p.right=cloneNode(s);z=s.right=cloneNode(s.right);p.right=s.left;s.left=p;s.right=z;s._color=p._color;n._color=BLACK;p._color=BLACK;z._color=BLACK;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.left===p){pp.left=s;}else{pp.right=s;}}stack[i-1]=s;return;}else if(s.left&&s.left._color===RED){//console.log("case 1: left sibling child red")
s=p.right=cloneNode(s);z=s.left=cloneNode(s.left);p.right=z.left;s.left=z.right;z.left=p;z.right=s;z._color=p._color;p._color=BLACK;s._color=BLACK;n._color=BLACK;recount(p);recount(s);recount(z);if(i>1){var pp=stack[i-2];if(pp.left===p){pp.left=z;}else{pp.right=z;}}stack[i-1]=z;return;}if(s._color===BLACK){if(p._color===RED){//console.log("case 2: black sibling, red parent", p.right.value)
p._color=BLACK;p.right=repaint(RED,s);return;}else{//console.log("case 2: black sibling, black parent", p.right.value)
p.right=repaint(RED,s);continue;}}else{//console.log("case 3: red sibling")
s=cloneNode(s);p.right=s.left;s.left=p;s._color=p._color;p._color=RED;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.left===p){pp.left=s;}else{pp.right=s;}}stack[i-1]=s;stack[i]=p;if(i+11){var pp=stack[i-2];if(pp.right===p){pp.right=s;}else{pp.left=s;}}stack[i-1]=s;return;}else if(s.right&&s.right._color===RED){//console.log("case 1: right sibling child red")
s=p.left=cloneNode(s);z=s.right=cloneNode(s.right);p.left=z.right;s.right=z.left;z.right=p;z.left=s;z._color=p._color;p._color=BLACK;s._color=BLACK;n._color=BLACK;recount(p);recount(s);recount(z);if(i>1){var pp=stack[i-2];if(pp.right===p){pp.right=z;}else{pp.left=z;}}stack[i-1]=z;return;}if(s._color===BLACK){if(p._color===RED){//console.log("case 2: black sibling, red parent")
p._color=BLACK;p.left=repaint(RED,s);return;}else{//console.log("case 2: black sibling, black parent")
p.left=repaint(RED,s);continue;}}else{//console.log("case 3: red sibling")
s=cloneNode(s);p.left=s.right;s.right=p;s._color=p._color;p._color=RED;recount(p);recount(s);if(i>1){var pp=stack[i-2];if(pp.right===p){pp.right=s;}else{pp.left=s;}}stack[i-1]=s;stack[i]=p;if(i+1=0;--i){var n=stack[i];if(n.left===stack[i+1]){cstack[i]=new RBNode(n._color,n.key,n.value,cstack[i+1],n.right,n._count);}else{cstack[i]=new RBNode(n._color,n.key,n.value,n.left,cstack[i+1],n._count);}}//Get node
n=cstack[cstack.length-1];//console.log("start remove: ", n.value)
//If not leaf, then swap with previous node
if(n.left&&n.right){//console.log("moving to leaf")
//First walk to previous leaf
var split=cstack.length;n=n.left;while(n.right){cstack.push(n);n=n.right;}//Copy path to leaf
var v=cstack[split-1];cstack.push(new RBNode(n._color,v.key,v.value,n.left,n.right,n._count));cstack[split-1].key=n.key;cstack[split-1].value=n.value;//Fix up stack
for(var i=cstack.length-2;i>=split;--i){n=cstack[i];cstack[i]=new RBNode(n._color,n.key,n.value,n.left,cstack[i+1],n._count);}cstack[split-1].left=cstack[split];}//console.log("stack=", cstack.map(function(v) { return v.value }))
//Remove leaf node
n=cstack[cstack.length-1];if(n._color===RED){//Easy case: removing red leaf
//console.log("RED leaf")
var p=cstack[cstack.length-2];if(p.left===n){p.left=null;}else if(p.right===n){p.right=null;}cstack.pop();for(var i=0;i0){return this._stack[this._stack.length-1].key;}return;},enumerable:true});//Returns value
Object.defineProperty(iproto,"value",{get:function(){if(this._stack.length>0){return this._stack[this._stack.length-1].value;}return;},enumerable:true});//Returns the position of this iterator in the sorted list
Object.defineProperty(iproto,"index",{get:function(){var idx=0;var stack=this._stack;if(stack.length===0){var r=this.tree.root;if(r){return r._count;}return 0;}else if(stack[stack.length-1].left){idx=stack[stack.length-1].left._count;}for(var s=stack.length-2;s>=0;--s){if(stack[s+1]===stack[s].right){++idx;if(stack[s].left){idx+=stack[s].left._count;}}}return idx;},enumerable:true});//Advances iterator to next element in list
iproto.next=function(){var stack=this._stack;if(stack.length===0){return;}var n=stack[stack.length-1];if(n.right){n=n.right;while(n){stack.push(n);n=n.left;}}else{stack.pop();while(stack.length>0&&stack[stack.length-1].right===n){n=stack[stack.length-1];stack.pop();}}};//Checks if iterator is at end of tree
Object.defineProperty(iproto,"hasNext",{get:function(){var stack=this._stack;if(stack.length===0){return false;}if(stack[stack.length-1].right){return true;}for(var s=stack.length-1;s>0;--s){if(stack[s-1].left===stack[s]){return true;}}return false;}});//Update value
iproto.update=function(value){var stack=this._stack;if(stack.length===0){throw new Error("Can't update empty node!");}var cstack=new Array(stack.length);var n=stack[stack.length-1];cstack[cstack.length-1]=new RBNode(n._color,n.key,value,n.left,n.right,n._count);for(var i=stack.length-2;i>=0;--i){n=stack[i];if(n.left===stack[i+1]){cstack[i]=new RBNode(n._color,n.key,n.value,cstack[i+1],n.right,n._count);}else{cstack[i]=new RBNode(n._color,n.key,n.value,n.left,cstack[i+1],n._count);}}return new RedBlackTree(this.tree._compare,cstack[0]);};//Moves iterator backward one element
iproto.prev=function(){var stack=this._stack;if(stack.length===0){return;}var n=stack[stack.length-1];if(n.left){n=n.left;while(n){stack.push(n);n=n.right;}}else{stack.pop();while(stack.length>0&&stack[stack.length-1].left===n){n=stack[stack.length-1];stack.pop();}}};//Checks if iterator is at start of tree
Object.defineProperty(iproto,"hasPrev",{get:function(){var stack=this._stack;if(stack.length===0){return false;}if(stack[stack.length-1].left){return true;}for(var s=stack.length-1;s>0;--s){if(stack[s-1].right===stack[s]){return true;}}return false;}});//Default comparison function
function defaultCompare(a,b){if(ab){return 1;}return 0;}//Build a tree
function createRBTree(compare){return new RedBlackTree(compare||defaultCompare,null);}/***/},/***/3837:/***/function(module,__unused_webpack_exports,__nested_webpack_require_234991__){"use strict";module.exports=createAxes;var createText=__nested_webpack_require_234991__(4935);var createLines=__nested_webpack_require_234991__(501);var createBackground=__nested_webpack_require_234991__(5304);var getCubeProperties=__nested_webpack_require_234991__(6429);var Ticks=__nested_webpack_require_234991__(6444);var identity=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function copyVec3(a,b){a[0]=b[0];a[1]=b[1];a[2]=b[2];return a;}function Axes(gl){this.gl=gl;this.pixelRatio=1;this.bounds=[[-10,-10,-10],[10,10,10]];this.ticks=[[],[],[]];this.autoTicks=true;this.tickSpacing=[1,1,1];this.tickEnable=[true,true,true];this.tickFont=['sans-serif','sans-serif','sans-serif'];this.tickSize=[12,12,12];this.tickAngle=[0,0,0];this.tickAlign=['auto','auto','auto'];this.tickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.tickPad=[10,10,10];this.lastCubeProps={cubeEdges:[0,0,0],axis:[0,0,0]};this.labels=['x','y','z'];this.labelEnable=[true,true,true];this.labelFont='sans-serif';this.labelSize=[20,20,20];this.labelAngle=[0,0,0];this.labelAlign=['auto','auto','auto'];this.labelColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.labelPad=[10,10,10];this.lineEnable=[true,true,true];this.lineMirror=[false,false,false];this.lineWidth=[1,1,1];this.lineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.lineTickEnable=[true,true,true];this.lineTickMirror=[false,false,false];this.lineTickLength=[0,0,0];this.lineTickWidth=[1,1,1];this.lineTickColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.gridEnable=[true,true,true];this.gridWidth=[1,1,1];this.gridColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.zeroEnable=[true,true,true];this.zeroLineColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.zeroLineWidth=[2,2,2];this.backgroundEnable=[false,false,false];this.backgroundColor=[[0.8,0.8,0.8,0.5],[0.8,0.8,0.8,0.5],[0.8,0.8,0.8,0.5]];this._firstInit=true;this._text=null;this._lines=null;this._background=createBackground(gl);}var proto=Axes.prototype;proto.update=function(options){options=options||{};//Option parsing helper functions
function parseOption(nest,cons,name){if(name in options){var opt=options[name];var prev=this[name];var next;if(nest?Array.isArray(opt)&&Array.isArray(opt[0]):Array.isArray(opt)){this[name]=next=[cons(opt[0]),cons(opt[1]),cons(opt[2])];}else{this[name]=next=[cons(opt),cons(opt),cons(opt)];}for(var i=0;i<3;++i){if(next[i]!==prev[i]){return true;}}}return false;}var NUMBER=parseOption.bind(this,false,Number);var BOOLEAN=parseOption.bind(this,false,Boolean);var STRING=parseOption.bind(this,false,String);var COLOR=parseOption.bind(this,true,function(v){if(Array.isArray(v)){if(v.length===3){return[+v[0],+v[1],+v[2],1.0];}else if(v.length===4){return[+v[0],+v[1],+v[2],+v[3]];}}return[0,0,0,1];});//Tick marks and bounds
var nextTicks;var ticksUpdate=false;var boundsChanged=false;if('bounds'in options){var bounds=options.bounds;i_loop:for(var i=0;i<2;++i){for(var j=0;j<3;++j){if(bounds[i][j]!==this.bounds[i][j]){boundsChanged=true;}this.bounds[i][j]=bounds[i][j];}}}if('ticks'in options){nextTicks=options.ticks;ticksUpdate=true;this.autoTicks=false;for(var i=0;i<3;++i){this.tickSpacing[i]=0.0;}}else if(NUMBER('tickSpacing')){this.autoTicks=true;boundsChanged=true;}if(this._firstInit){if(!('ticks'in options||'tickSpacing'in options)){this.autoTicks=true;}//Force tick recomputation on first update
boundsChanged=true;ticksUpdate=true;this._firstInit=false;}if(boundsChanged&&this.autoTicks){nextTicks=Ticks.create(this.bounds,this.tickSpacing);ticksUpdate=true;}//Compare next ticks to previous ticks, only update if needed
if(ticksUpdate){for(var i=0;i<3;++i){nextTicks[i].sort(function(a,b){return a.x-b.x;});}if(Ticks.equal(nextTicks,this.ticks)){ticksUpdate=false;}else{this.ticks=nextTicks;}}//Parse tick properties
BOOLEAN('tickEnable');if(STRING('tickFont')){ticksUpdate=true;//If font changes, must rebuild vbo
}NUMBER('tickSize');NUMBER('tickAngle');NUMBER('tickPad');COLOR('tickColor');//Axis labels
var labelUpdate=STRING('labels');if(STRING('labelFont')){labelUpdate=true;}BOOLEAN('labelEnable');NUMBER('labelSize');NUMBER('labelPad');COLOR('labelColor');//Axis lines
BOOLEAN('lineEnable');BOOLEAN('lineMirror');NUMBER('lineWidth');COLOR('lineColor');//Axis line ticks
BOOLEAN('lineTickEnable');BOOLEAN('lineTickMirror');NUMBER('lineTickLength');NUMBER('lineTickWidth');COLOR('lineTickColor');//Grid lines
BOOLEAN('gridEnable');NUMBER('gridWidth');COLOR('gridColor');//Zero line
BOOLEAN('zeroEnable');COLOR('zeroLineColor');NUMBER('zeroLineWidth');//Background
BOOLEAN('backgroundEnable');COLOR('backgroundColor');//Update text if necessary
if(!this._text){this._text=createText(this.gl,this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont);}else if(this._text&&(labelUpdate||ticksUpdate)){this._text.update(this.bounds,this.labels,this.labelFont,this.ticks,this.tickFont);}//Update lines if necessary
if(this._lines&&ticksUpdate){this._lines.dispose();this._lines=null;}if(!this._lines){this._lines=createLines(this.gl,this.bounds,this.ticks);}};function OffsetInfo(){this.primalOffset=[0,0,0];this.primalMinor=[0,0,0];this.mirrorOffset=[0,0,0];this.mirrorMinor=[0,0,0];}var LINE_OFFSET=[new OffsetInfo(),new OffsetInfo(),new OffsetInfo()];function computeLineOffset(result,i,bounds,cubeEdges,cubeAxis){var primalOffset=result.primalOffset;var primalMinor=result.primalMinor;var dualOffset=result.mirrorOffset;var dualMinor=result.mirrorMinor;var e=cubeEdges[i];//Calculate offsets
for(var j=0;j<3;++j){if(i===j){continue;}var a=primalOffset,b=dualOffset,c=primalMinor,d=dualMinor;if(e&1<0){c[j]=-1;d[j]=0;}else{c[j]=0;d[j]=+1;}}}var CUBE_ENABLE=[0,0,0];var DEFAULT_PARAMS={model:identity,view:identity,projection:identity,_ortho:false};proto.isOpaque=function(){return true;};proto.isTransparent=function(){return false;};proto.drawTransparent=function(params){};var ALIGN_OPTION_AUTO=0;// i.e. as defined in the shader the text would rotate to stay upwards range: [-90,90]
var PRIMAL_MINOR=[0,0,0];var MIRROR_MINOR=[0,0,0];var PRIMAL_OFFSET=[0,0,0];proto.draw=function(params){params=params||DEFAULT_PARAMS;var gl=this.gl;//Geometry for camera and axes
var model=params.model||identity;var view=params.view||identity;var projection=params.projection||identity;var bounds=this.bounds;var isOrtho=params._ortho||false;//Unpack axis info
var cubeParams=getCubeProperties(model,view,projection,bounds,isOrtho);var cubeEdges=cubeParams.cubeEdges;var cubeAxis=cubeParams.axis;var cx=view[12];var cy=view[13];var cz=view[14];var cw=view[15];var orthoFix=isOrtho?2:1;// double up padding for orthographic ticks & labels
var pixelScaleF=orthoFix*this.pixelRatio*(projection[3]*cx+projection[7]*cy+projection[11]*cz+projection[15]*cw)/gl.drawingBufferHeight;for(var i=0;i<3;++i){this.lastCubeProps.cubeEdges[i]=cubeEdges[i];this.lastCubeProps.axis[i]=cubeAxis[i];}//Compute axis info
var lineOffset=LINE_OFFSET;for(var i=0;i<3;++i){computeLineOffset(LINE_OFFSET[i],i,this.bounds,cubeEdges,cubeAxis);}//Set up state parameters
var gl=this.gl;//Draw background first
var cubeEnable=CUBE_ENABLE;for(var i=0;i<3;++i){if(this.backgroundEnable[i]){cubeEnable[i]=cubeAxis[i];}else{cubeEnable[i]=0;}}this._background.draw(model,view,projection,bounds,cubeEnable,this.backgroundColor);//Draw lines
this._lines.bind(model,view,projection,this);//First draw grid lines and zero lines
for(var i=0;i<3;++i){var x=[0,0,0];if(cubeAxis[i]>0){x[i]=bounds[1][i];}else{x[i]=bounds[0][i];}//Draw grid lines
for(var j=0;j<2;++j){var u=(i+1+j)%3;var v=(i+1+(j^1))%3;if(this.gridEnable[u]){this._lines.drawGrid(u,v,this.bounds,x,this.gridColor[u],this.gridWidth[u]*this.pixelRatio);}}//Draw zero lines (need to do this AFTER all grid lines are drawn)
for(var j=0;j<2;++j){var u=(i+1+j)%3;var v=(i+1+(j^1))%3;if(this.zeroEnable[v]){//Check if zero line in bounds
if(Math.min(bounds[0][v],bounds[1][v])<=0&&Math.max(bounds[0][v],bounds[1][v])>=0){this._lines.drawZero(u,v,this.bounds,x,this.zeroLineColor[v],this.zeroLineWidth[v]*this.pixelRatio);}}}}//Then draw axis lines and tick marks
for(var i=0;i<3;++i){//Draw axis lines
if(this.lineEnable[i]){this._lines.drawAxisLine(i,this.bounds,lineOffset[i].primalOffset,this.lineColor[i],this.lineWidth[i]*this.pixelRatio);}if(this.lineMirror[i]){this._lines.drawAxisLine(i,this.bounds,lineOffset[i].mirrorOffset,this.lineColor[i],this.lineWidth[i]*this.pixelRatio);}//Compute minor axes
var primalMinor=copyVec3(PRIMAL_MINOR,lineOffset[i].primalMinor);var mirrorMinor=copyVec3(MIRROR_MINOR,lineOffset[i].mirrorMinor);var tickLength=this.lineTickLength;for(var j=0;j<3;++j){var scaleFactor=pixelScaleF/model[5*j];primalMinor[j]*=tickLength[j]*scaleFactor;mirrorMinor[j]*=tickLength[j]*scaleFactor;}//Draw axis line ticks
if(this.lineTickEnable[i]){this._lines.drawAxisTicks(i,lineOffset[i].primalOffset,primalMinor,this.lineTickColor[i],this.lineTickWidth[i]*this.pixelRatio);}if(this.lineTickMirror[i]){this._lines.drawAxisTicks(i,lineOffset[i].mirrorOffset,mirrorMinor,this.lineTickColor[i],this.lineTickWidth[i]*this.pixelRatio);}}this._lines.unbind();//Draw text sprites
this._text.bind(model,view,projection,this.pixelRatio);var alignOpt;// options in shader are from this list {-1, 0, 1, 2, 3, ..., n}
// -1: backward compatible
// 0: raw data
// 1: auto align, free angles
// 2: auto align, horizontal or vertical
//3-n: auto align, round to n directions e.g. 12 -> round to angles with 30-degree steps
var hv_ratio=0.5;// can have an effect on the ratio between horizontals and verticals when using option 2
var enableAlign;var alignDir;function alignTo(i){alignDir=[0,0,0];alignDir[i]=1;}function solveTickAlignments(i,minor,major){var i1=(i+1)%3;var i2=(i+2)%3;var A=minor[i1];var B=minor[i2];var C=major[i1];var D=major[i2];if(A>0&&D>0){alignTo(i1);return;}else if(A>0&&D<0){alignTo(i1);return;}else if(A<0&&D>0){alignTo(i1);return;}else if(A<0&&D<0){alignTo(i1);return;}else if(B>0&&C>0){alignTo(i2);return;}else if(B>0&&C<0){alignTo(i2);return;}else if(B<0&&C>0){alignTo(i2);return;}else if(B<0&&C<0){alignTo(i2);return;}}for(var i=0;i<3;++i){var minor=lineOffset[i].primalMinor;var major=lineOffset[i].mirrorMinor;var offset=copyVec3(PRIMAL_OFFSET,lineOffset[i].primalOffset);for(var j=0;j<3;++j){if(this.lineTickEnable[i]){offset[j]+=pixelScaleF*minor[j]*Math.max(this.lineTickLength[j],0)/model[5*j];}}var axis=[0,0,0];axis[i]=1;//Draw tick text
if(this.tickEnable[i]){if(this.tickAngle[i]===-3600){this.tickAngle[i]=0;this.tickAlign[i]='auto';}else{this.tickAlign[i]=-1;}enableAlign=1;alignOpt=[this.tickAlign[i],hv_ratio,enableAlign];if(alignOpt[0]==='auto')alignOpt[0]=ALIGN_OPTION_AUTO;else alignOpt[0]=parseInt(''+alignOpt[0]);alignDir=[0,0,0];solveTickAlignments(i,minor,major);//Add tick padding
for(var j=0;j<3;++j){offset[j]+=pixelScaleF*minor[j]*this.tickPad[j]/model[5*j];}//Draw axis
this._text.drawTicks(i,this.tickSize[i],this.tickAngle[i],offset,this.tickColor[i],axis,alignDir,alignOpt);}//Draw labels
if(this.labelEnable[i]){enableAlign=0;alignDir=[0,0,0];if(this.labels[i].length>4){// for large label axis enable alignDir to axis
alignTo(i);enableAlign=1;}alignOpt=[this.labelAlign[i],hv_ratio,enableAlign];if(alignOpt[0]==='auto')alignOpt[0]=ALIGN_OPTION_AUTO;else alignOpt[0]=parseInt(''+alignOpt[0]);//Add label padding
for(var j=0;j<3;++j){offset[j]+=pixelScaleF*minor[j]*this.labelPad[j]/model[5*j];}offset[i]+=0.5*(bounds[0][i]+bounds[1][i]);//Draw axis
this._text.drawLabel(i,this.labelSize[i],this.labelAngle[i],offset,this.labelColor[i],[0,0,0],alignDir,alignOpt);}}this._text.unbind();};proto.dispose=function(){this._text.dispose();this._lines.dispose();this._background.dispose();this._lines=null;this._text=null;this._background=null;this.gl=null;};function createAxes(gl,options){var axes=new Axes(gl);axes.update(options);return axes;}/***/},/***/5304:/***/function(module,__unused_webpack_exports,__nested_webpack_require_246858__){"use strict";module.exports=createBackgroundCube;var createBuffer=__nested_webpack_require_246858__(2762);var createVAO=__nested_webpack_require_246858__(8116);var createShader=__nested_webpack_require_246858__(1879).bg;function BackgroundCube(gl,buffer,vao,shader){this.gl=gl;this.buffer=buffer;this.vao=vao;this.shader=shader;}var proto=BackgroundCube.prototype;proto.draw=function(model,view,projection,bounds,enable,colors){var needsBG=false;for(var i=0;i<3;++i){needsBG=needsBG||enable[i];}if(!needsBG){return;}var gl=this.gl;gl.enable(gl.POLYGON_OFFSET_FILL);gl.polygonOffset(1,2);this.shader.bind();this.shader.uniforms={model:model,view:view,projection:projection,bounds:bounds,enable:enable,colors:colors};this.vao.bind();this.vao.draw(this.gl.TRIANGLES,36);this.vao.unbind();gl.disable(gl.POLYGON_OFFSET_FILL);};proto.dispose=function(){this.vao.dispose();this.buffer.dispose();this.shader.dispose();};function createBackgroundCube(gl){//Create cube vertices
var vertices=[];var indices=[];var ptr=0;for(var d=0;d<3;++d){var u=(d+1)%3;var v=(d+2)%3;var x=[0,0,0];var c=[0,0,0];for(var s=-1;s<=1;s+=2){indices.push(ptr,ptr+2,ptr+1,ptr+1,ptr+2,ptr+3);x[d]=s;c[d]=s;for(var i=-1;i<=1;i+=2){x[u]=i;for(var j=-1;j<=1;j+=2){x[v]=j;vertices.push(x[0],x[1],x[2],c[0],c[1],c[2]);ptr+=1;}}//Swap u and v
var tt=u;u=v;v=tt;}}//Allocate buffer and vertex array
var buffer=createBuffer(gl,new Float32Array(vertices));var elements=createBuffer(gl,new Uint16Array(indices),gl.ELEMENT_ARRAY_BUFFER);var vao=createVAO(gl,[{buffer:buffer,type:gl.FLOAT,size:3,offset:0,stride:24},{buffer:buffer,type:gl.FLOAT,size:3,offset:12,stride:24}],elements);//Create shader object
var shader=createShader(gl);shader.attributes.position.location=0;shader.attributes.normal.location=1;return new BackgroundCube(gl,buffer,vao,shader);}/***/},/***/6429:/***/function(module,__unused_webpack_exports,__nested_webpack_require_248713__){"use strict";module.exports=getCubeEdges;var bits=__nested_webpack_require_248713__(8828);var multiply=__nested_webpack_require_248713__(6760);var splitPoly=__nested_webpack_require_248713__(5202);var orient=__nested_webpack_require_248713__(3250);var mvp=new Array(16);var pCubeVerts=new Array(8);var cubeVerts=new Array(8);var x=new Array(3);var zero3=[0,0,0];(function(){for(var i=0;i<8;++i){pCubeVerts[i]=[1,1,1,1];cubeVerts[i]=[1,1,1];}})();function transformHg(result,x,mat){for(var i=0;i<4;++i){result[i]=mat[12+i];for(var j=0;j<3;++j){result[i]+=x[j]*mat[4*j+i];}}}var FRUSTUM_PLANES=[[0,0,1,0,0],[0,0,-1,1,0],[0,-1,0,1,0],[0,1,0,1,0],[-1,0,0,1,0],[1,0,0,1,0]];function polygonArea(p){for(var i=0;io0){closest|=1<o0){closest|=1<cubeVerts[i][1]){bottom=i;}}//Find left/right neighbors of bottom vertex
var left=-1;for(var i=0;i<3;++i){var idx=bottom^1<cubeVerts[right][0]){right=idx;}}//Determine edge axis coordinates
var cubeEdges=CUBE_EDGES;cubeEdges[0]=cubeEdges[1]=cubeEdges[2]=0;cubeEdges[bits.log2(left^bottom)]=bottom&left;cubeEdges[bits.log2(bottom^right)]=bottom&right;var top=right^7;if(top===closest||top===farthest){top=left^7;cubeEdges[bits.log2(right^top)]=top&right;}else{cubeEdges[bits.log2(left^top)]=top&left;}//Determine visible faces
var axis=CUBE_AXIS;var cutCorner=closest;for(var d=0;d<3;++d){if(cutCorner&1< HALF_PI) && (b <= ONE_AND_HALF_PI)) ?\n b - PI :\n b;\n}\n\nfloat look_horizontal_or_vertical(float a, float ratio) {\n // ratio controls the ratio between being horizontal to (vertical + horizontal)\n // if ratio is set to 0.5 then it is 50%, 50%.\n // when using a higher ratio e.g. 0.75 the result would\n // likely be more horizontal than vertical.\n\n float b = positive_angle(a);\n\n return\n (b < ( ratio) * HALF_PI) ? 0.0 :\n (b < (2.0 - ratio) * HALF_PI) ? -HALF_PI :\n (b < (2.0 + ratio) * HALF_PI) ? 0.0 :\n (b < (4.0 - ratio) * HALF_PI) ? HALF_PI :\n 0.0;\n}\n\nfloat roundTo(float a, float b) {\n return float(b * floor((a + 0.5 * b) / b));\n}\n\nfloat look_round_n_directions(float a, int n) {\n float b = positive_angle(a);\n float div = TWO_PI / float(n);\n float c = roundTo(b, div);\n return look_upwards(c);\n}\n\nfloat applyAlignOption(float rawAngle, float delta) {\n return\n (option > 2) ? look_round_n_directions(rawAngle + delta, option) : // option 3-n: round to n directions\n (option == 2) ? look_horizontal_or_vertical(rawAngle + delta, hv_ratio) : // horizontal or vertical\n (option == 1) ? rawAngle + delta : // use free angle, and flip to align with one direction of the axis\n (option == 0) ? look_upwards(rawAngle) : // use free angle, and stay upwards\n (option ==-1) ? 0.0 : // useful for backward compatibility, all texts remains horizontal\n rawAngle; // otherwise return back raw input angle\n}\n\nbool isAxisTitle = (axis.x == 0.0) &&\n (axis.y == 0.0) &&\n (axis.z == 0.0);\n\nvoid main() {\n //Compute world offset\n float axisDistance = position.z;\n vec3 dataPosition = axisDistance * axis + offset;\n\n float beta = angle; // i.e. user defined attributes for each tick\n\n float axisAngle;\n float clipAngle;\n float flip;\n\n if (enableAlign) {\n axisAngle = (isAxisTitle) ? HALF_PI :\n computeViewAngle(dataPosition, dataPosition + axis);\n clipAngle = computeViewAngle(dataPosition, dataPosition + alignDir);\n\n axisAngle += (sin(axisAngle) < 0.0) ? PI : 0.0;\n clipAngle += (sin(clipAngle) < 0.0) ? PI : 0.0;\n\n flip = (dot(vec2(cos(axisAngle), sin(axisAngle)),\n vec2(sin(clipAngle),-cos(clipAngle))) > 0.0) ? 1.0 : 0.0;\n\n beta += applyAlignOption(clipAngle, flip * PI);\n }\n\n //Compute plane offset\n vec2 planeCoord = position.xy * pixelScale;\n\n mat2 planeXform = scale * mat2(\n cos(beta), sin(beta),\n -sin(beta), cos(beta)\n );\n\n vec2 viewOffset = 2.0 * planeXform * planeCoord / resolution;\n\n //Compute clip position\n vec3 clipPosition = project(dataPosition);\n\n //Apply text offset in clip coordinates\n clipPosition += vec3(viewOffset, 0.0);\n\n //Done\n gl_Position = vec4(clipPosition, 1.0);\n}"]);var textFrag=glslify(["precision highp float;\n#define GLSLIFY 1\n\nuniform vec4 color;\nvoid main() {\n gl_FragColor = color;\n}"]);exports.Q=function(gl){return createShader(gl,textVert,textFrag,null,[{name:'position',type:'vec3'}]);};var bgVert=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 model, view, projection;\nuniform vec3 enable;\nuniform vec3 bounds[2];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n\n vec3 signAxis = sign(bounds[1] - bounds[0]);\n\n vec3 realNormal = signAxis * normal;\n\n if(dot(realNormal, enable) > 0.0) {\n vec3 minRange = min(bounds[0], bounds[1]);\n vec3 maxRange = max(bounds[0], bounds[1]);\n vec3 nPosition = mix(minRange, maxRange, 0.5 * (position + 1.0));\n gl_Position = projection * view * model * vec4(nPosition, 1.0);\n } else {\n gl_Position = vec4(0,0,0,0);\n }\n\n colorChannel = abs(realNormal);\n}"]);var bgFrag=glslify(["precision highp float;\n#define GLSLIFY 1\n\nuniform vec4 colors[3];\n\nvarying vec3 colorChannel;\n\nvoid main() {\n gl_FragColor = colorChannel.x * colors[0] +\n colorChannel.y * colors[1] +\n colorChannel.z * colors[2];\n}"]);exports.bg=function(gl){return createShader(gl,bgVert,bgFrag,null,[{name:'position',type:'vec3'},{name:'normal',type:'vec3'}]);};/***/},/***/4935:/***/function(module,__unused_webpack_exports,__nested_webpack_require_263397__){"use strict";module.exports=createTextSprites;var createBuffer=__nested_webpack_require_263397__(2762);var createVAO=__nested_webpack_require_263397__(8116);var vectorizeText=__nested_webpack_require_263397__(4359);var createShader=__nested_webpack_require_263397__(1879)/* .text */.Q;var globals=window||process.global||{};var __TEXT_CACHE=globals.__TEXT_CACHE||{};globals.__TEXT_CACHE={};//Vertex buffer format for text is:
//
/// [x,y,z] = Spatial coordinate
//
var VERTEX_SIZE=3;function TextSprites(gl,shader,buffer,vao){this.gl=gl;this.shader=shader;this.buffer=buffer;this.vao=vao;this.tickOffset=this.tickCount=this.labelOffset=this.labelCount=null;}var proto=TextSprites.prototype;//Bind textures for rendering
var SHAPE=[0,0];proto.bind=function(model,view,projection,pixelScale){this.vao.bind();this.shader.bind();var uniforms=this.shader.uniforms;uniforms.model=model;uniforms.view=view;uniforms.projection=projection;uniforms.pixelScale=pixelScale;SHAPE[0]=this.gl.drawingBufferWidth;SHAPE[1]=this.gl.drawingBufferHeight;this.shader.uniforms.resolution=SHAPE;};proto.unbind=function(){this.vao.unbind();};proto.update=function(bounds,labels,labelFont,ticks,tickFont){var data=[];function addItem(t,text,font,size,lineSpacing,styletags){var fontcache=__TEXT_CACHE[font];if(!fontcache){fontcache=__TEXT_CACHE[font]={};}var mesh=fontcache[text];if(!mesh){mesh=fontcache[text]=tryVectorizeText(text,{triangles:true,font:font,textAlign:'center',textBaseline:'middle',lineSpacing:lineSpacing,styletags:styletags});}var scale=(size||12)/12;var positions=mesh.positions;var cells=mesh.cells;for(var i=0,nc=cells.length;i=0;--j){var p=positions[c[j]];data.push(scale*p[0],-scale*p[1],t);}}}//Generate sprites for all 3 axes, store data in texture atlases
var tickOffset=[0,0,0];var tickCount=[0,0,0];var labelOffset=[0,0,0];var labelCount=[0,0,0];var lineSpacing=1.25;var styletags={breaklines:true,bolds:true,italics:true,subscripts:true,superscripts:true};for(var d=0;d<3;++d){//Generate label
labelOffset[d]=data.length/VERTEX_SIZE|0;addItem(0.5*(bounds[0][d]+bounds[1][d]),labels[d],labelFont[d],12,// labelFontSize
lineSpacing,styletags);labelCount[d]=(data.length/VERTEX_SIZE|0)-labelOffset[d];//Generate sprites for tick marks
tickOffset[d]=data.length/VERTEX_SIZE|0;for(var i=0;i=0){sigFigs=stepStr.length-u-1;}var shift=Math.pow(10,sigFigs);var x=Math.round(spacing*i*shift);var xstr=x+"";if(xstr.indexOf("e")>=0){return xstr;}var xi=x/shift,xf=x%shift;if(x<0){xi=-Math.ceil(xi)|0;xf=-xf|0;}else{xi=Math.floor(xi)|0;xf=xf|0;}var xis=""+xi;if(x<0){xis="-"+xis;}if(sigFigs){var xs=""+xf;while(xs.length=bounds[0][d];--t){ticks.push({x:t*tickSpacing[d],text:prettyPrint(tickSpacing[d],t)});}array.push(ticks);}return array;}function ticksEqual(ticksA,ticksB){for(var i=0;i<3;++i){if(ticksA[i].length!==ticksB[i].length){return false;}for(var j=0;jlen){throw new Error("gl-buffer: If resizing buffer, must not specify offset");}gl.bufferSubData(type,offset,data);return len;}function makeScratchTypeArray(array,dtype){var res=pool.malloc(array.length,dtype);var n=array.length;for(var i=0;i=0;--i){if(stride[i]!==n){return false;}n*=shape[i];}return true;}proto.update=function(array,offset){if(typeof offset!=="number"){offset=-1;}this.bind();if(typeof array==="object"&&typeof array.shape!=="undefined"){//ndarray
var dtype=array.dtype;if(SUPPORTED_TYPES.indexOf(dtype)<0){dtype="float32";}if(this.type===this.gl.ELEMENT_ARRAY_BUFFER){var ext=gl.getExtension('OES_element_index_uint');if(ext&&dtype!=="uint16"){dtype="uint32";}else{dtype="uint16";}}if(dtype===array.dtype&&isPacked(array.shape,array.stride)){if(array.offset===0&&array.data.length===array.shape[0]){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array.data,offset);}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array.data.subarray(array.offset,array.shape[0]),offset);}}else{var tmp=pool.malloc(array.size,dtype);var ndt=ndarray(tmp,array.shape);ops.assign(ndt,array);if(offset<0){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,tmp,offset);}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,tmp.subarray(0,array.size),offset);}pool.free(tmp);}}else if(Array.isArray(array)){//Vanilla array
var t;if(this.type===this.gl.ELEMENT_ARRAY_BUFFER){t=makeScratchTypeArray(array,"uint16");}else{t=makeScratchTypeArray(array,"float32");}if(offset<0){this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,t,offset);}else{this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,t.subarray(0,array.length),offset);}pool.free(t);}else if(typeof array==="object"&&typeof array.length==="number"){//Typed array
this.length=updateTypeArray(this.gl,this.type,this.length,this.usage,array,offset);}else if(typeof array==="number"||array===undefined){//Number/default
if(offset>=0){throw new Error("gl-buffer: Cannot specify offset when resizing buffer");}array=array|0;if(array<=0){array=1;}this.gl.bufferData(this.type,array|0,this.usage);this.length=array;}else{//Error, case should not happen
throw new Error("gl-buffer: Invalid data type");}};function createBuffer(gl,data,type,usage){type=type||gl.ARRAY_BUFFER;usage=usage||gl.DYNAMIC_DRAW;if(type!==gl.ARRAY_BUFFER&&type!==gl.ELEMENT_ARRAY_BUFFER){throw new Error("gl-buffer: Invalid type for webgl buffer, must be either gl.ARRAY_BUFFER or gl.ELEMENT_ARRAY_BUFFER");}if(usage!==gl.DYNAMIC_DRAW&&usage!==gl.STATIC_DRAW&&usage!==gl.STREAM_DRAW){throw new Error("gl-buffer: Invalid usage for buffer, must be either gl.DYNAMIC_DRAW, gl.STATIC_DRAW or gl.STREAM_DRAW");}var handle=gl.createBuffer();var result=new GLBuffer(gl,type,handle,0,usage);result.update(data);return result;}module.exports=createBuffer;/***/},/***/6405:/***/function(module,__unused_webpack_exports,__nested_webpack_require_275746__){"use strict";var vec3=__nested_webpack_require_275746__(2931);module.exports=function(vectorfield,bounds){var positions=vectorfield.positions;var vectors=vectorfield.vectors;var geo={positions:[],vertexIntensity:[],vertexIntensityBounds:vectorfield.vertexIntensityBounds,vectors:[],cells:[],coneOffset:vectorfield.coneOffset,colormap:vectorfield.colormap};if(vectorfield.positions.length===0){if(bounds){bounds[0]=[0,0,0];bounds[1]=[0,0,0];}return geo;}// Compute bounding box for the dataset.
// Compute maximum velocity for the dataset to use for scaling the cones.
var maxNorm=0;var minX=Infinity,maxX=-Infinity;var minY=Infinity,maxY=-Infinity;var minZ=Infinity,maxZ=-Infinity;var p2=null;var u2=null;var positionVectors=[];var vectorScale=Infinity;var skipIt=false;var rawSizemodemode=vectorfield.coneSizemode==='raw';for(var i=0;imaxNorm){maxNorm=vec3.length(u);}if(i&&!rawSizemodemode){// Find vector scale [w/ units of time] using "successive" positions
// (not "adjacent" with would be O(n^2)),
//
// The vector scale corresponds to the minimum "time" to travel across two
// two adjacent positions at the average velocity of those two adjacent positions
var q=2*vec3.distance(p2,p)/(vec3.length(u2)+vec3.length(u));if(q){vectorScale=Math.min(vectorScale,q);skipIt=false;}else{skipIt=true;}}if(!skipIt){p2=p;u2=u;}positionVectors.push(u);}var minV=[minX,minY,minZ];var maxV=[maxX,maxY,maxZ];if(bounds){bounds[0]=minV;bounds[1]=maxV;}if(maxNorm===0){maxNorm=1;}// Inverted max norm would map vector with norm maxNorm to 1 coord space units in length
var invertedMaxNorm=1/maxNorm;if(!isFinite(vectorScale)){vectorScale=1.0;}geo.vectorScale=vectorScale;var coneScale=vectorfield.coneSize||(rawSizemodemode?1:0.5);if(vectorfield.absoluteConeSize){coneScale=vectorfield.absoluteConeSize*invertedMaxNorm;}geo.coneScale=coneScale;// Build the cone model.
for(var i=0,j=0;i=1;};proto.isTransparent=function(){return this.opacity<1;};proto.pickSlots=1;proto.setPickBase=function(id){this.pickId=id;};function genColormap(param){var colors=colormap({colormap:param,nshades:256,format:'rgba'});var result=new Uint8Array(256*4);for(var i=0;i<256;++i){var c=colors[i];for(var j=0;j<3;++j){result[4*i+j]=c[j];}result[4*i+3]=c[3]*255;}return ndarray(result,[256,256,4],[4,0,1]);}function takeZComponent(array){var n=array.length;var result=new Array(n);for(var i=0;i0){var shader=this.triShader;shader.bind();shader.uniforms=uniforms;this.triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,this.triangleCount*3);this.triangleVAO.unbind();}};proto.drawPick=function(params){params=params||{};var gl=this.gl;var model=params.model||IDENTITY;var view=params.view||IDENTITY;var projection=params.projection||IDENTITY;var clipBounds=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]];for(var i=0;i<3;++i){clipBounds[0][i]=Math.max(clipBounds[0][i],this.clipBounds[0][i]);clipBounds[1][i]=Math.min(clipBounds[1][i],this.clipBounds[1][i]);}//Save camera parameters
this._model=[].slice.call(model);this._view=[].slice.call(view);this._projection=[].slice.call(projection);this._resolution=[gl.drawingBufferWidth,gl.drawingBufferHeight];var uniforms={model:model,view:view,projection:projection,clipBounds:clipBounds,tubeScale:this.tubeScale,vectorScale:this.vectorScale,coneScale:this.coneScale,coneOffset:this.coneOffset,pickId:this.pickId/255.0};var shader=this.pickShader;shader.bind();shader.uniforms=uniforms;if(this.triangleCount>0){this.triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,this.triangleCount*3);this.triangleVAO.unbind();}};proto.pick=function(pickData){if(!pickData){return null;}if(pickData.id!==this.pickId){return null;}var cellId=pickData.value[0]+256*pickData.value[1]+65536*pickData.value[2];var cell=this.cells[cellId];var pos=this.positions[cell[1]].slice(0,3);var result={position:pos,dataCoordinate:pos,index:Math.floor(cell[1]/48)};if(this.traceType==='cone'){result.index=Math.floor(cell[1]/48);}else if(this.traceType==='streamtube'){result.intensity=this.intensity[cell[1]];result.velocity=this.vectors[cell[1]].slice(0,3);result.divergence=this.vectors[cell[1]][3];result.index=cellId;}return result;};proto.dispose=function(){this.texture.dispose();this.triShader.dispose();this.pickShader.dispose();this.triangleVAO.dispose();this.trianglePositions.dispose();this.triangleVectors.dispose();this.triangleColors.dispose();this.triangleUVs.dispose();this.triangleIds.dispose();};function createMeshShader(gl,shaders){var shader=createShader(gl,shaders.meshShader.vertex,shaders.meshShader.fragment,null,shaders.meshShader.attributes);shader.attributes.position.location=0;shader.attributes.color.location=2;shader.attributes.uv.location=3;shader.attributes.vector.location=4;return shader;}function createPickShader(gl,shaders){var shader=createShader(gl,shaders.pickShader.vertex,shaders.pickShader.fragment,null,shaders.pickShader.attributes);shader.attributes.position.location=0;shader.attributes.id.location=1;shader.attributes.vector.location=4;return shader;}function createVectorMesh(gl,params,opts){var shaders=opts.shaders;if(arguments.length===1){params=gl;gl=params.gl;}var triShader=createMeshShader(gl,shaders);var pickShader=createPickShader(gl,shaders);var meshTexture=createTexture(gl,ndarray(new Uint8Array([255,255,255,255]),[1,1,4]));meshTexture.generateMipmap();meshTexture.minFilter=gl.LINEAR_MIPMAP_LINEAR;meshTexture.magFilter=gl.LINEAR;var trianglePositions=createBuffer(gl);var triangleVectors=createBuffer(gl);var triangleColors=createBuffer(gl);var triangleUVs=createBuffer(gl);var triangleIds=createBuffer(gl);var triangleVAO=createVAO(gl,[{buffer:trianglePositions,type:gl.FLOAT,size:4},{buffer:triangleIds,type:gl.UNSIGNED_BYTE,size:4,normalized:true},{buffer:triangleColors,type:gl.FLOAT,size:4},{buffer:triangleUVs,type:gl.FLOAT,size:2},{buffer:triangleVectors,type:gl.FLOAT,size:4}]);var mesh=new VectorMesh(gl,meshTexture,triShader,pickShader,trianglePositions,triangleVectors,triangleIds,triangleColors,triangleUVs,triangleVAO,opts.traceType||'cone');mesh.update(params);return mesh;}module.exports=createVectorMesh;/***/},/***/614:/***/function(__unused_webpack_module,exports,__nested_webpack_require_289417__){var glslify=__nested_webpack_require_289417__(3236);var triVertSrc=glslify(["precision highp float;\n\nprecision highp float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float rawIndex, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n float index = rawIndex - floor(rawIndex /\n (segmentCount * 6.0)) *\n (segmentCount * 6.0);\n\n float segment = floor(0.001 + index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex > 2.99 && segmentIndex < 3.01) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n float nextAngle = (\n (segmentIndex > 0.99 && segmentIndex < 1.01) ||\n (segmentIndex > 4.99 && segmentIndex < 5.01)\n ) ? 1.0 : 0.0;\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex < 3.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec3 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\n\nuniform float vectorScale, coneScale, coneOffset;\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 eyePosition, lightPosition;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * conePosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n f_lightDirection = lightPosition - cameraCoordinate.xyz;\n f_eyeDirection = eyePosition - cameraCoordinate.xyz;\n f_normal = normalize((vec4(normal, 0.0) * inverseModel).xyz);\n\n // vec4 m_position = model * vec4(conePosition, 1.0);\n vec4 t_position = view * conePosition;\n gl_Position = projection * t_position;\n\n f_color = color;\n f_data = conePosition.xyz;\n f_position = position.xyz;\n f_uv = uv;\n}\n"]);var triFragSrc=glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = min(1.0, max(0.0, cookTorranceSpecular(L, V, N, roughness, fresnel)));\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]);var pickVertSrc=glslify(["precision highp float;\n\nprecision highp float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the cone vertex and normal at the given index.\n//\n// The returned vertex is for a cone with its top at origin and height of 1.0,\n// pointing in the direction of the vector attribute.\n//\n// Each cone is made up of a top vertex, a center base vertex and base perimeter vertices.\n// These vertices are used to make up the triangles of the cone by the following:\n// segment + 0 top vertex\n// segment + 1 perimeter vertex a+1\n// segment + 2 perimeter vertex a\n// segment + 3 center base vertex\n// segment + 4 perimeter vertex a\n// segment + 5 perimeter vertex a+1\n// Where segment is the number of the radial segment * 6 and a is the angle at that radial segment.\n// To go from index to segment, floor(index / 6)\n// To go from segment to angle, 2*pi * (segment/segmentCount)\n// To go from index to segment index, index - (segment*6)\n//\nvec3 getConePosition(vec3 d, float rawIndex, float coneOffset, out vec3 normal) {\n\n const float segmentCount = 8.0;\n\n float index = rawIndex - floor(rawIndex /\n (segmentCount * 6.0)) *\n (segmentCount * 6.0);\n\n float segment = floor(0.001 + index/6.0);\n float segmentIndex = index - (segment*6.0);\n\n normal = -normalize(d);\n\n if (segmentIndex > 2.99 && segmentIndex < 3.01) {\n return mix(vec3(0.0), -d, coneOffset);\n }\n\n float nextAngle = (\n (segmentIndex > 0.99 && segmentIndex < 1.01) ||\n (segmentIndex > 4.99 && segmentIndex < 5.01)\n ) ? 1.0 : 0.0;\n float angle = 2.0 * 3.14159 * ((segment + nextAngle) / segmentCount);\n\n vec3 v1 = mix(d, vec3(0.0), coneOffset);\n vec3 v2 = v1 - d;\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d)*0.25;\n vec3 y = v * sin(angle) * length(d)*0.25;\n vec3 v3 = v2 + x + y;\n if (segmentIndex < 3.0) {\n vec3 tx = u * sin(angle);\n vec3 ty = v * -cos(angle);\n vec3 tangent = tx + ty;\n normal = normalize(cross(v3 - v1, tangent));\n }\n\n if (segmentIndex == 0.0) {\n return mix(d, vec3(0.0), coneOffset);\n }\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float vectorScale, coneScale, coneOffset;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getConePosition(mat3(model) * ((vectorScale * coneScale) * vector.xyz), position.w, coneOffset, normal);\n vec4 conePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n gl_Position = projection * view * conePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]);var pickFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);exports.meshShader={vertex:triVertSrc,fragment:triFragSrc,attributes:[{name:'position',type:'vec4'},{name:'color',type:'vec4'},{name:'uv',type:'vec2'},{name:'vector',type:'vec3'}]};exports.pickShader={vertex:pickVertSrc,fragment:pickFragSrc,attributes:[{name:'position',type:'vec4'},{name:'id',type:'vec4'},{name:'vector',type:'vec3'}]};/***/},/***/737:/***/function(module){module.exports={0:'NONE',1:'ONE',2:'LINE_LOOP',3:'LINE_STRIP',4:'TRIANGLES',5:'TRIANGLE_STRIP',6:'TRIANGLE_FAN',256:'DEPTH_BUFFER_BIT',512:'NEVER',513:'LESS',514:'EQUAL',515:'LEQUAL',516:'GREATER',517:'NOTEQUAL',518:'GEQUAL',519:'ALWAYS',768:'SRC_COLOR',769:'ONE_MINUS_SRC_COLOR',770:'SRC_ALPHA',771:'ONE_MINUS_SRC_ALPHA',772:'DST_ALPHA',773:'ONE_MINUS_DST_ALPHA',774:'DST_COLOR',775:'ONE_MINUS_DST_COLOR',776:'SRC_ALPHA_SATURATE',1024:'STENCIL_BUFFER_BIT',1028:'FRONT',1029:'BACK',1032:'FRONT_AND_BACK',1280:'INVALID_ENUM',1281:'INVALID_VALUE',1282:'INVALID_OPERATION',1285:'OUT_OF_MEMORY',1286:'INVALID_FRAMEBUFFER_OPERATION',2304:'CW',2305:'CCW',2849:'LINE_WIDTH',2884:'CULL_FACE',2885:'CULL_FACE_MODE',2886:'FRONT_FACE',2928:'DEPTH_RANGE',2929:'DEPTH_TEST',2930:'DEPTH_WRITEMASK',2931:'DEPTH_CLEAR_VALUE',2932:'DEPTH_FUNC',2960:'STENCIL_TEST',2961:'STENCIL_CLEAR_VALUE',2962:'STENCIL_FUNC',2963:'STENCIL_VALUE_MASK',2964:'STENCIL_FAIL',2965:'STENCIL_PASS_DEPTH_FAIL',2966:'STENCIL_PASS_DEPTH_PASS',2967:'STENCIL_REF',2968:'STENCIL_WRITEMASK',2978:'VIEWPORT',3024:'DITHER',3042:'BLEND',3088:'SCISSOR_BOX',3089:'SCISSOR_TEST',3106:'COLOR_CLEAR_VALUE',3107:'COLOR_WRITEMASK',3317:'UNPACK_ALIGNMENT',3333:'PACK_ALIGNMENT',3379:'MAX_TEXTURE_SIZE',3386:'MAX_VIEWPORT_DIMS',3408:'SUBPIXEL_BITS',3410:'RED_BITS',3411:'GREEN_BITS',3412:'BLUE_BITS',3413:'ALPHA_BITS',3414:'DEPTH_BITS',3415:'STENCIL_BITS',3553:'TEXTURE_2D',4352:'DONT_CARE',4353:'FASTEST',4354:'NICEST',5120:'BYTE',5121:'UNSIGNED_BYTE',5122:'SHORT',5123:'UNSIGNED_SHORT',5124:'INT',5125:'UNSIGNED_INT',5126:'FLOAT',5386:'INVERT',5890:'TEXTURE',6401:'STENCIL_INDEX',6402:'DEPTH_COMPONENT',6406:'ALPHA',6407:'RGB',6408:'RGBA',6409:'LUMINANCE',6410:'LUMINANCE_ALPHA',7680:'KEEP',7681:'REPLACE',7682:'INCR',7683:'DECR',7936:'VENDOR',7937:'RENDERER',7938:'VERSION',9728:'NEAREST',9729:'LINEAR',9984:'NEAREST_MIPMAP_NEAREST',9985:'LINEAR_MIPMAP_NEAREST',9986:'NEAREST_MIPMAP_LINEAR',9987:'LINEAR_MIPMAP_LINEAR',10240:'TEXTURE_MAG_FILTER',10241:'TEXTURE_MIN_FILTER',10242:'TEXTURE_WRAP_S',10243:'TEXTURE_WRAP_T',10497:'REPEAT',10752:'POLYGON_OFFSET_UNITS',16384:'COLOR_BUFFER_BIT',32769:'CONSTANT_COLOR',32770:'ONE_MINUS_CONSTANT_COLOR',32771:'CONSTANT_ALPHA',32772:'ONE_MINUS_CONSTANT_ALPHA',32773:'BLEND_COLOR',32774:'FUNC_ADD',32777:'BLEND_EQUATION_RGB',32778:'FUNC_SUBTRACT',32779:'FUNC_REVERSE_SUBTRACT',32819:'UNSIGNED_SHORT_4_4_4_4',32820:'UNSIGNED_SHORT_5_5_5_1',32823:'POLYGON_OFFSET_FILL',32824:'POLYGON_OFFSET_FACTOR',32854:'RGBA4',32855:'RGB5_A1',32873:'TEXTURE_BINDING_2D',32926:'SAMPLE_ALPHA_TO_COVERAGE',32928:'SAMPLE_COVERAGE',32936:'SAMPLE_BUFFERS',32937:'SAMPLES',32938:'SAMPLE_COVERAGE_VALUE',32939:'SAMPLE_COVERAGE_INVERT',32968:'BLEND_DST_RGB',32969:'BLEND_SRC_RGB',32970:'BLEND_DST_ALPHA',32971:'BLEND_SRC_ALPHA',33071:'CLAMP_TO_EDGE',33170:'GENERATE_MIPMAP_HINT',33189:'DEPTH_COMPONENT16',33306:'DEPTH_STENCIL_ATTACHMENT',33635:'UNSIGNED_SHORT_5_6_5',33648:'MIRRORED_REPEAT',33901:'ALIASED_POINT_SIZE_RANGE',33902:'ALIASED_LINE_WIDTH_RANGE',33984:'TEXTURE0',33985:'TEXTURE1',33986:'TEXTURE2',33987:'TEXTURE3',33988:'TEXTURE4',33989:'TEXTURE5',33990:'TEXTURE6',33991:'TEXTURE7',33992:'TEXTURE8',33993:'TEXTURE9',33994:'TEXTURE10',33995:'TEXTURE11',33996:'TEXTURE12',33997:'TEXTURE13',33998:'TEXTURE14',33999:'TEXTURE15',34000:'TEXTURE16',34001:'TEXTURE17',34002:'TEXTURE18',34003:'TEXTURE19',34004:'TEXTURE20',34005:'TEXTURE21',34006:'TEXTURE22',34007:'TEXTURE23',34008:'TEXTURE24',34009:'TEXTURE25',34010:'TEXTURE26',34011:'TEXTURE27',34012:'TEXTURE28',34013:'TEXTURE29',34014:'TEXTURE30',34015:'TEXTURE31',34016:'ACTIVE_TEXTURE',34024:'MAX_RENDERBUFFER_SIZE',34041:'DEPTH_STENCIL',34055:'INCR_WRAP',34056:'DECR_WRAP',34067:'TEXTURE_CUBE_MAP',34068:'TEXTURE_BINDING_CUBE_MAP',34069:'TEXTURE_CUBE_MAP_POSITIVE_X',34070:'TEXTURE_CUBE_MAP_NEGATIVE_X',34071:'TEXTURE_CUBE_MAP_POSITIVE_Y',34072:'TEXTURE_CUBE_MAP_NEGATIVE_Y',34073:'TEXTURE_CUBE_MAP_POSITIVE_Z',34074:'TEXTURE_CUBE_MAP_NEGATIVE_Z',34076:'MAX_CUBE_MAP_TEXTURE_SIZE',34338:'VERTEX_ATTRIB_ARRAY_ENABLED',34339:'VERTEX_ATTRIB_ARRAY_SIZE',34340:'VERTEX_ATTRIB_ARRAY_STRIDE',34341:'VERTEX_ATTRIB_ARRAY_TYPE',34342:'CURRENT_VERTEX_ATTRIB',34373:'VERTEX_ATTRIB_ARRAY_POINTER',34466:'NUM_COMPRESSED_TEXTURE_FORMATS',34467:'COMPRESSED_TEXTURE_FORMATS',34660:'BUFFER_SIZE',34661:'BUFFER_USAGE',34816:'STENCIL_BACK_FUNC',34817:'STENCIL_BACK_FAIL',34818:'STENCIL_BACK_PASS_DEPTH_FAIL',34819:'STENCIL_BACK_PASS_DEPTH_PASS',34877:'BLEND_EQUATION_ALPHA',34921:'MAX_VERTEX_ATTRIBS',34922:'VERTEX_ATTRIB_ARRAY_NORMALIZED',34930:'MAX_TEXTURE_IMAGE_UNITS',34962:'ARRAY_BUFFER',34963:'ELEMENT_ARRAY_BUFFER',34964:'ARRAY_BUFFER_BINDING',34965:'ELEMENT_ARRAY_BUFFER_BINDING',34975:'VERTEX_ATTRIB_ARRAY_BUFFER_BINDING',35040:'STREAM_DRAW',35044:'STATIC_DRAW',35048:'DYNAMIC_DRAW',35632:'FRAGMENT_SHADER',35633:'VERTEX_SHADER',35660:'MAX_VERTEX_TEXTURE_IMAGE_UNITS',35661:'MAX_COMBINED_TEXTURE_IMAGE_UNITS',35663:'SHADER_TYPE',35664:'FLOAT_VEC2',35665:'FLOAT_VEC3',35666:'FLOAT_VEC4',35667:'INT_VEC2',35668:'INT_VEC3',35669:'INT_VEC4',35670:'BOOL',35671:'BOOL_VEC2',35672:'BOOL_VEC3',35673:'BOOL_VEC4',35674:'FLOAT_MAT2',35675:'FLOAT_MAT3',35676:'FLOAT_MAT4',35678:'SAMPLER_2D',35680:'SAMPLER_CUBE',35712:'DELETE_STATUS',35713:'COMPILE_STATUS',35714:'LINK_STATUS',35715:'VALIDATE_STATUS',35716:'INFO_LOG_LENGTH',35717:'ATTACHED_SHADERS',35718:'ACTIVE_UNIFORMS',35719:'ACTIVE_UNIFORM_MAX_LENGTH',35720:'SHADER_SOURCE_LENGTH',35721:'ACTIVE_ATTRIBUTES',35722:'ACTIVE_ATTRIBUTE_MAX_LENGTH',35724:'SHADING_LANGUAGE_VERSION',35725:'CURRENT_PROGRAM',36003:'STENCIL_BACK_REF',36004:'STENCIL_BACK_VALUE_MASK',36005:'STENCIL_BACK_WRITEMASK',36006:'FRAMEBUFFER_BINDING',36007:'RENDERBUFFER_BINDING',36048:'FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE',36049:'FRAMEBUFFER_ATTACHMENT_OBJECT_NAME',36050:'FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL',36051:'FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE',36053:'FRAMEBUFFER_COMPLETE',36054:'FRAMEBUFFER_INCOMPLETE_ATTACHMENT',36055:'FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT',36057:'FRAMEBUFFER_INCOMPLETE_DIMENSIONS',36061:'FRAMEBUFFER_UNSUPPORTED',36064:'COLOR_ATTACHMENT0',36096:'DEPTH_ATTACHMENT',36128:'STENCIL_ATTACHMENT',36160:'FRAMEBUFFER',36161:'RENDERBUFFER',36162:'RENDERBUFFER_WIDTH',36163:'RENDERBUFFER_HEIGHT',36164:'RENDERBUFFER_INTERNAL_FORMAT',36168:'STENCIL_INDEX8',36176:'RENDERBUFFER_RED_SIZE',36177:'RENDERBUFFER_GREEN_SIZE',36178:'RENDERBUFFER_BLUE_SIZE',36179:'RENDERBUFFER_ALPHA_SIZE',36180:'RENDERBUFFER_DEPTH_SIZE',36181:'RENDERBUFFER_STENCIL_SIZE',36194:'RGB565',36336:'LOW_FLOAT',36337:'MEDIUM_FLOAT',36338:'HIGH_FLOAT',36339:'LOW_INT',36340:'MEDIUM_INT',36341:'HIGH_INT',36346:'SHADER_COMPILER',36347:'MAX_VERTEX_UNIFORM_VECTORS',36348:'MAX_VARYING_VECTORS',36349:'MAX_FRAGMENT_UNIFORM_VECTORS',37440:'UNPACK_FLIP_Y_WEBGL',37441:'UNPACK_PREMULTIPLY_ALPHA_WEBGL',37442:'CONTEXT_LOST_WEBGL',37443:'UNPACK_COLORSPACE_CONVERSION_WEBGL',37444:'BROWSER_DEFAULT_WEBGL'};/***/},/***/5171:/***/function(module,__unused_webpack_exports,__nested_webpack_require_307512__){var gl10=__nested_webpack_require_307512__(737);module.exports=function lookupConstant(number){return gl10[number];};/***/},/***/9165:/***/function(module,__unused_webpack_exports,__nested_webpack_require_307699__){"use strict";module.exports=createErrorBars;var createBuffer=__nested_webpack_require_307699__(2762);var createVAO=__nested_webpack_require_307699__(8116);var createShader=__nested_webpack_require_307699__(3436);var IDENTITY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function ErrorBars(gl,buffer,vao,shader){this.gl=gl;this.shader=shader;this.buffer=buffer;this.vao=vao;this.pixelRatio=1;this.bounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];this.clipBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.lineWidth=[1,1,1];this.capSize=[10,10,10];this.lineCount=[0,0,0];this.lineOffset=[0,0,0];this.opacity=1;this.hasAlpha=false;}var proto=ErrorBars.prototype;proto.isOpaque=function(){return!this.hasAlpha;};proto.isTransparent=function(){return this.hasAlpha;};proto.drawTransparent=proto.draw=function(cameraParams){var gl=this.gl;var uniforms=this.shader.uniforms;this.shader.bind();var view=uniforms.view=cameraParams.view||IDENTITY;var projection=uniforms.projection=cameraParams.projection||IDENTITY;uniforms.model=cameraParams.model||IDENTITY;uniforms.clipBounds=this.clipBounds;uniforms.opacity=this.opacity;var cx=view[12];var cy=view[13];var cz=view[14];var cw=view[15];var isOrtho=cameraParams._ortho||false;var orthoFix=isOrtho?2:1;// double up padding for orthographic ticks & labels
var pixelScaleF=orthoFix*this.pixelRatio*(projection[3]*cx+projection[7]*cy+projection[11]*cz+projection[15]*cw)/gl.drawingBufferHeight;this.vao.bind();for(var i=0;i<3;++i){gl.lineWidth(this.lineWidth[i]*this.pixelRatio);uniforms.capSize=this.capSize[i]*pixelScaleF;if(this.lineCount[i]){gl.drawArrays(gl.LINES,this.lineOffset[i],this.lineCount[i]);}}this.vao.unbind();};function updateBounds(bounds,point){for(var i=0;i<3;++i){bounds[0][i]=Math.min(bounds[0][i],point[i]);bounds[1][i]=Math.max(bounds[1][i],point[i]);}}var FACE_TABLE=function(){var table=new Array(3);for(var d=0;d<3;++d){var row=[];for(var j=1;j<=2;++j){for(var s=-1;s<=1;s+=2){var u=(j+d)%3;var y=[0,0,0];y[u]=s;row.push(y);}}table[d]=row;}return table;}();function emitFace(verts,x,c,d){var offsets=FACE_TABLE[d];for(var i=0;i0){var x=p.slice();x[j]+=e[1][j];verts.push(p[0],p[1],p[2],c[0],c[1],c[2],c[3],0,0,0,x[0],x[1],x[2],c[0],c[1],c[2],c[3],0,0,0);updateBounds(this.bounds,x);vertexCount+=2+emitFace(verts,x,c,j);}}this.lineCount[j]=vertexCount-this.lineOffset[j];}this.buffer.update(verts);}};proto.dispose=function(){this.shader.dispose();this.buffer.dispose();this.vao.dispose();};function createErrorBars(options){var gl=options.gl;var buffer=createBuffer(gl);var vao=createVAO(gl,[{buffer:buffer,type:gl.FLOAT,size:3,offset:0,stride:40},{buffer:buffer,type:gl.FLOAT,size:4,offset:12,stride:40},{buffer:buffer,type:gl.FLOAT,size:3,offset:28,stride:40}]);var shader=createShader(gl);shader.attributes.position.location=0;shader.attributes.color.location=1;shader.attributes.offset.location=2;var result=new ErrorBars(gl,buffer,vao,shader);result.update(options);return result;}/***/},/***/3436:/***/function(module,__unused_webpack_exports,__nested_webpack_require_312338__){"use strict";var glslify=__nested_webpack_require_312338__(3236);var createShader=__nested_webpack_require_312338__(9405);var vertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, offset;\nattribute vec4 color;\nuniform mat4 model, view, projection;\nuniform float capSize;\nvarying vec4 fragColor;\nvarying vec3 fragPosition;\n\nvoid main() {\n vec4 worldPosition = model * vec4(position, 1.0);\n worldPosition = (worldPosition / worldPosition.w) + vec4(capSize * offset, 0.0);\n gl_Position = projection * view * worldPosition;\n fragColor = color;\n fragPosition = position;\n}"]);var fragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float opacity;\nvarying vec3 fragPosition;\nvarying vec4 fragColor;\n\nvoid main() {\n if (\n outOfRange(clipBounds[0], clipBounds[1], fragPosition) ||\n fragColor.a * opacity == 0.\n ) discard;\n\n gl_FragColor = opacity * fragColor;\n}"]);module.exports=function(gl){return createShader(gl,vertSrc,fragSrc,null,[{name:'position',type:'vec3'},{name:'color',type:'vec4'},{name:'offset',type:'vec3'}]);};/***/},/***/2260:/***/function(module,__unused_webpack_exports,__nested_webpack_require_314061__){"use strict";var createTexture=__nested_webpack_require_314061__(7766);module.exports=createFBO;var colorAttachmentArrays=null;var FRAMEBUFFER_UNSUPPORTED;var FRAMEBUFFER_INCOMPLETE_ATTACHMENT;var FRAMEBUFFER_INCOMPLETE_DIMENSIONS;var FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;function saveFBOState(gl){var fbo=gl.getParameter(gl.FRAMEBUFFER_BINDING);var rbo=gl.getParameter(gl.RENDERBUFFER_BINDING);var tex=gl.getParameter(gl.TEXTURE_BINDING_2D);return[fbo,rbo,tex];}function restoreFBOState(gl,data){gl.bindFramebuffer(gl.FRAMEBUFFER,data[0]);gl.bindRenderbuffer(gl.RENDERBUFFER,data[1]);gl.bindTexture(gl.TEXTURE_2D,data[2]);}function lazyInitColorAttachments(gl,ext){var maxColorAttachments=gl.getParameter(ext.MAX_COLOR_ATTACHMENTS_WEBGL);colorAttachmentArrays=new Array(maxColorAttachments+1);for(var i=0;i<=maxColorAttachments;++i){var x=new Array(maxColorAttachments);for(var j=0;j1){ext.drawBuffersWEBGL(colorAttachmentArrays[numColors]);}//Allocate depth/stencil buffers
var WEBGL_depth_texture=gl.getExtension('WEBGL_depth_texture');if(WEBGL_depth_texture){if(useStencil){fbo.depth=initTexture(gl,width,height,WEBGL_depth_texture.UNSIGNED_INT_24_8_WEBGL,gl.DEPTH_STENCIL,gl.DEPTH_STENCIL_ATTACHMENT);}else if(useDepth){fbo.depth=initTexture(gl,width,height,gl.UNSIGNED_SHORT,gl.DEPTH_COMPONENT,gl.DEPTH_ATTACHMENT);}}else{if(useDepth&&useStencil){fbo._depth_rb=initRenderBuffer(gl,width,height,gl.DEPTH_STENCIL,gl.DEPTH_STENCIL_ATTACHMENT);}else if(useDepth){fbo._depth_rb=initRenderBuffer(gl,width,height,gl.DEPTH_COMPONENT16,gl.DEPTH_ATTACHMENT);}else if(useStencil){fbo._depth_rb=initRenderBuffer(gl,width,height,gl.STENCIL_INDEX,gl.STENCIL_ATTACHMENT);}}//Check frame buffer state
var status=gl.checkFramebufferStatus(gl.FRAMEBUFFER);if(status!==gl.FRAMEBUFFER_COMPLETE){//Release all partially allocated resources
fbo._destroyed=true;//Release all resources
gl.bindFramebuffer(gl.FRAMEBUFFER,null);gl.deleteFramebuffer(fbo.handle);fbo.handle=null;if(fbo.depth){fbo.depth.dispose();fbo.depth=null;}if(fbo._depth_rb){gl.deleteRenderbuffer(fbo._depth_rb);fbo._depth_rb=null;}for(var i=0;imaxFBOSize||h<0||h>maxFBOSize){throw new Error('gl-fbo: Can\'t resize FBO, invalid dimensions');}//Update shape
fbo._shape[0]=w;fbo._shape[1]=h;//Save framebuffer state
var state=saveFBOState(gl);//Resize framebuffer attachments
for(var i=0;imaxFBOSize||height<0||height>maxFBOSize){throw new Error('gl-fbo: Parameters are too large for FBO');}//Handle each option type
options=options||{};//Figure out number of color buffers to use
var numColors=1;if('color'in options){numColors=Math.max(options.color|0,0);if(numColors<0){throw new Error('gl-fbo: Must specify a nonnegative number of colors');}if(numColors>1){//Check if multiple render targets supported
if(!WEBGL_draw_buffers){throw new Error('gl-fbo: Multiple draw buffer extension not supported');}else if(numColors>gl.getParameter(WEBGL_draw_buffers.MAX_COLOR_ATTACHMENTS_WEBGL)){throw new Error('gl-fbo: Context does not support '+numColors+' draw buffers');}}}//Determine whether to use floating point textures
var colorType=gl.UNSIGNED_BYTE;var OES_texture_float=gl.getExtension('OES_texture_float');if(options.float&&numColors>0){if(!OES_texture_float){throw new Error('gl-fbo: Context does not support floating point textures');}colorType=gl.FLOAT;}else if(options.preferFloat&&numColors>0){if(OES_texture_float){colorType=gl.FLOAT;}}//Check if we should use depth buffer
var useDepth=true;if('depth'in options){useDepth=!!options.depth;}//Check if we should use a stencil buffer
var useStencil=false;if('stencil'in options){useStencil=!!options.stencil;}return new Framebuffer(gl,width,height,colorType,numColors,useDepth,useStencil,WEBGL_draw_buffers);}/***/},/***/2992:/***/function(module,__unused_webpack_exports,__nested_webpack_require_324521__){var sprintf=__nested_webpack_require_324521__(3387).sprintf;var glConstants=__nested_webpack_require_324521__(5171);var shaderName=__nested_webpack_require_324521__(1848);var addLineNumbers=__nested_webpack_require_324521__(1085);module.exports=formatCompilerError;function formatCompilerError(errLog,src,type){"use strict";var name=shaderName(src)||'of unknown name (see npm glsl-shader-name)';var typeName='unknown type';if(type!==undefined){typeName=type===glConstants.FRAGMENT_SHADER?'fragment':'vertex';}var longForm=sprintf('Error compiling %s shader %s:\n',typeName,name);var shortForm=sprintf("%s%s",longForm,errLog);var errorStrings=errLog.split('\n');var errors={};for(var i=0;i>i*8&0xff;}this.pickOffset=pickOffset;shader.bind();var uniforms=shader.uniforms;uniforms.viewTransform=MATRIX;uniforms.pickOffset=PICK_VECTOR;uniforms.shape=this.shape;var attributes=shader.attributes;this.positionBuffer.bind();attributes.position.pointer();this.weightBuffer.bind();attributes.weight.pointer(gl.UNSIGNED_BYTE,false);this.idBuffer.bind();attributes.pickId.pointer(gl.UNSIGNED_BYTE,false);gl.drawArrays(gl.TRIANGLES,0,numVertices);return pickOffset+this.shape[0]*this.shape[1];};}();proto.pick=function(x,y,value){var pickOffset=this.pickOffset;var pointCount=this.shape[0]*this.shape[1];if(value=pickOffset+pointCount){return null;}var pointId=value-pickOffset;var xData=this.xData;var yData=this.yData;return{object:this,pointId:pointId,dataCoord:[xData[pointId%this.shape[0]],yData[pointId/this.shape[0]|0]]};};proto.update=function(options){options=options||{};var shape=options.shape||[0,0];var x=options.x||iota(shape[0]);var y=options.y||iota(shape[1]);var z=options.z||new Float32Array(shape[0]*shape[1]);var isSmooth=options.zsmooth!==false;this.xData=x;this.yData=y;var colorLevels=options.colorLevels||[0];var colorValues=options.colorValues||[0,0,0,1];var colorCount=colorLevels.length;var bounds=this.bounds;var lox,loy,hix,hiy;if(isSmooth){lox=bounds[0]=x[0];loy=bounds[1]=y[0];hix=bounds[2]=x[x.length-1];hiy=bounds[3]=y[y.length-1];}else{// To get squares to centre on data values
lox=bounds[0]=x[0]+(x[1]-x[0])/2;// starting x value
loy=bounds[1]=y[0]+(y[1]-y[0])/2;// starting y value
// Bounds needs to add half a square on each end
hix=bounds[2]=x[x.length-1]+(x[x.length-1]-x[x.length-2])/2;hiy=bounds[3]=y[y.length-1]+(y[y.length-1]-y[y.length-2])/2;// N.B. Resolution = 1 / range
}var xs=1.0/(hix-lox);var ys=1.0/(hiy-loy);var numX=shape[0];var numY=shape[1];this.shape=[numX,numY];var numVerts=(isSmooth?(numX-1)*(numY-1):numX*numY)*(WEIGHTS.length>>>1);this.numVertices=numVerts;var colors=pool.mallocUint8(numVerts*4);var positions=pool.mallocFloat32(numVerts*2);var weights=pool.mallocUint8(numVerts*2);var ids=pool.mallocUint32(numVerts);var ptr=0;var ni=isSmooth?numX-1:numX;var nj=isSmooth?numY-1:numY;for(var j=0;j max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D dashTexture;\nuniform float dashScale;\nuniform float opacity;\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (\n outOfRange(clipBounds[0], clipBounds[1], worldPosition) ||\n fragColor.a * opacity == 0.\n ) discard;\n\n float dashWeight = texture2D(dashTexture, vec2(dashScale * pixelArcLength, 0)).r;\n if(dashWeight < 0.5) {\n discard;\n }\n gl_FragColor = fragColor * opacity;\n}\n"]);var pickFrag=glslify(["precision highp float;\n#define GLSLIFY 1\n\n#define FLOAT_MAX 1.70141184e38\n#define FLOAT_MIN 1.17549435e-38\n\n// https://github.com/mikolalysenko/glsl-read-float/blob/master/index.glsl\nvec4 packFloat(float v) {\n float av = abs(v);\n\n //Handle special cases\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(127.0, 128.0, 0.0, 0.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(255.0, 128.0, 0.0, 0.0) / 255.0;\n }\n\n vec4 c = vec4(0,0,0,0);\n\n //Compute exponent and mantissa\n float e = floor(log2(av));\n float m = av * pow(2.0, -e) - 1.0;\n\n //Unpack mantissa\n c[1] = floor(128.0 * m);\n m -= c[1] / 128.0;\n c[2] = floor(32768.0 * m);\n m -= c[2] / 32768.0;\n c[3] = floor(8388608.0 * m);\n\n //Unpack exponent\n float ebias = e + 127.0;\n c[0] = floor(ebias / 2.0);\n ebias -= c[0] * 2.0;\n c[1] += floor(ebias) * 128.0;\n\n //Unpack sign bit\n c[0] += 128.0 * step(0.0, -v);\n\n //Scale back to range\n return c / 255.0;\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform float pickId;\nuniform vec3 clipBounds[2];\n\nvarying vec3 worldPosition;\nvarying float pixelArcLength;\nvarying vec4 fragColor;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], worldPosition)) discard;\n\n gl_FragColor = vec4(pickId/255.0, packFloat(pixelArcLength).xyz);\n}"]);var ATTRIBUTES=[{name:'position',type:'vec3'},{name:'nextPosition',type:'vec3'},{name:'arcLength',type:'float'},{name:'lineWidth',type:'float'},{name:'color',type:'vec4'}];exports.createShader=function(gl){return createShader(gl,vertSrc,forwardFrag,null,ATTRIBUTES);};exports.createPickShader=function(gl){return createShader(gl,vertSrc,pickFrag,null,ATTRIBUTES);};/***/},/***/5714:/***/function(module,__unused_webpack_exports,__nested_webpack_require_338868__){"use strict";module.exports=createLinePlot;var createBuffer=__nested_webpack_require_338868__(2762);var createVAO=__nested_webpack_require_338868__(8116);var createTexture=__nested_webpack_require_338868__(7766);var UINT8_VIEW=new Uint8Array(4);var FLOAT_VIEW=new Float32Array(UINT8_VIEW.buffer);// https://github.com/mikolalysenko/glsl-read-float/blob/master/index.js
function unpackFloat(x,y,z,w){UINT8_VIEW[0]=w;UINT8_VIEW[1]=z;UINT8_VIEW[2]=y;UINT8_VIEW[3]=x;return FLOAT_VIEW[0];}var bsearch=__nested_webpack_require_338868__(2478);var ndarray=__nested_webpack_require_338868__(9618);var shaders=__nested_webpack_require_338868__(7319);var createShader=shaders.createShader;var createPickShader=shaders.createPickShader;var identity=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function distance(a,b){var s=0.0;for(var i=0;i<3;++i){var d=a[i]-b[i];s+=d*d;}return Math.sqrt(s);}function filterClipBounds(bounds){var result=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]];for(var i=0;i<3;++i){result[0][i]=Math.max(bounds[0][i],result[0][i]);result[1][i]=Math.min(bounds[1][i],result[1][i]);}return result;}function PickResult(tau,position,index,dataCoordinate){this.arcLength=tau;this.position=position;this.index=index;this.dataCoordinate=dataCoordinate;}function LinePlot(gl,shader,pickShader,buffer,vao,texture){this.gl=gl;this.shader=shader;this.pickShader=pickShader;this.buffer=buffer;this.vao=vao;this.clipBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.points=[];this.arcLength=[];this.vertexCount=0;this.bounds=[[0,0,0],[0,0,0]];this.pickId=0;this.lineWidth=1;this.texture=texture;this.dashScale=1;this.opacity=1;this.hasAlpha=false;this.dirty=true;this.pixelRatio=1;}var proto=LinePlot.prototype;proto.isTransparent=function(){return this.hasAlpha;};proto.isOpaque=function(){return!this.hasAlpha;};proto.pickSlots=1;proto.setPickBase=function(id){this.pickId=id;};proto.drawTransparent=proto.draw=function(camera){if(!this.vertexCount)return;var gl=this.gl;var shader=this.shader;var vao=this.vao;shader.bind();shader.uniforms={model:camera.model||identity,view:camera.view||identity,projection:camera.projection||identity,clipBounds:filterClipBounds(this.clipBounds),dashTexture:this.texture.bind(),dashScale:this.dashScale/this.arcLength[this.arcLength.length-1],opacity:this.opacity,screenShape:[gl.drawingBufferWidth,gl.drawingBufferHeight],pixelRatio:this.pixelRatio};vao.bind();vao.draw(gl.TRIANGLE_STRIP,this.vertexCount);vao.unbind();};proto.drawPick=function(camera){if(!this.vertexCount)return;var gl=this.gl;var shader=this.pickShader;var vao=this.vao;shader.bind();shader.uniforms={model:camera.model||identity,view:camera.view||identity,projection:camera.projection||identity,pickId:this.pickId,clipBounds:filterClipBounds(this.clipBounds),screenShape:[gl.drawingBufferWidth,gl.drawingBufferHeight],pixelRatio:this.pixelRatio};vao.bind();vao.draw(gl.TRIANGLE_STRIP,this.vertexCount);vao.unbind();};proto.update=function(options){var i,j;this.dirty=true;var connectGaps=!!options.connectGaps;if('dashScale'in options){this.dashScale=options.dashScale;}this.hasAlpha=false;// default to no transparent draw
if('opacity'in options){this.opacity=+options.opacity;if(this.opacity<1){this.hasAlpha=true;}}// Recalculate buffer data
var buffer=[];var arcLengthArray=[];var pointArray=[];var arcLength=0.0;var vertexCount=0;var bounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];var positions=options.position||options.positions;if(positions){// Default color
var colors=options.color||options.colors||[0,0,0,1];var lineWidth=options.lineWidth||1;var hadGap=false;fill_loop:for(i=1;i0){for(var k=0;k<24;++k){buffer.push(buffer[buffer.length-12]);}vertexCount+=2;hadGap=true;}continue fill_loop;}bounds[0][j]=Math.min(bounds[0][j],a[j],b[j]);bounds[1][j]=Math.max(bounds[1][j],a[j],b[j]);}var acolor,bcolor;if(Array.isArray(colors[0])){acolor=colors.length>i-1?colors[i-1]:// using index value
colors.length>0?colors[colors.length-1]:// using last item
[0,0,0,1];// using black
bcolor=colors.length>i?colors[i]:// using index value
colors.length>0?colors[colors.length-1]:// using last item
[0,0,0,1];// using black
}else{acolor=bcolor=colors;}if(acolor.length===3){acolor=[acolor[0],acolor[1],acolor[2],1];}if(bcolor.length===3){bcolor=[bcolor[0],bcolor[1],bcolor[2],1];}if(!this.hasAlpha&&acolor[3]<1)this.hasAlpha=true;var w0;if(Array.isArray(lineWidth)){w0=lineWidth.length>i-1?lineWidth[i-1]:// using index value
lineWidth.length>0?lineWidth[lineWidth.length-1]:// using last item
[0,0,0,1];// using black
}else{w0=lineWidth;}var t0=arcLength;arcLength+=distance(a,b);if(hadGap){for(j=0;j<2;++j){buffer.push(a[0],a[1],a[2],b[0],b[1],b[2],t0,w0,acolor[0],acolor[1],acolor[2],acolor[3]);}vertexCount+=2;hadGap=false;}buffer.push(a[0],a[1],a[2],b[0],b[1],b[2],t0,w0,acolor[0],acolor[1],acolor[2],acolor[3],a[0],a[1],a[2],b[0],b[1],b[2],t0,-w0,acolor[0],acolor[1],acolor[2],acolor[3],b[0],b[1],b[2],a[0],a[1],a[2],arcLength,-w0,bcolor[0],bcolor[1],bcolor[2],bcolor[3],b[0],b[1],b[2],a[0],a[1],a[2],arcLength,w0,bcolor[0],bcolor[1],bcolor[2],bcolor[3]);vertexCount+=4;}}this.buffer.update(buffer);arcLengthArray.push(arcLength);pointArray.push(positions[positions.length-1].slice());this.bounds=bounds;this.vertexCount=vertexCount;this.points=pointArray;this.arcLength=arcLengthArray;if('dashes'in options){var dashArray=options.dashes;// Calculate prefix sum
var prefixSum=dashArray.slice();prefixSum.unshift(0);for(i=1;i1.0001){return null;}s+=weights[i];}if(Math.abs(s-1.0)>0.001){return null;}return[closestIndex,interpolate(simplex,weights),weights];}/***/},/***/840:/***/function(__unused_webpack_module,exports,__nested_webpack_require_364052__){var glslify=__nested_webpack_require_364052__(3236);var triVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position, normal;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model\n , view\n , projection\n , inverseModel;\nuniform vec3 eyePosition\n , lightPosition;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvec4 project(vec3 p) {\n return projection * view * model * vec4(p, 1.0);\n}\n\nvoid main() {\n gl_Position = project(position);\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * vec4(position , 1.0);\n cameraCoordinate.xyz /= cameraCoordinate.w;\n f_lightDirection = lightPosition - cameraCoordinate.xyz;\n f_eyeDirection = eyePosition - cameraCoordinate.xyz;\n f_normal = normalize((vec4(normal, 0.0) * inverseModel).xyz);\n\n f_color = color;\n f_data = position;\n f_uv = uv;\n}\n"]);var triFragSrc=glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\n//#pragma glslify: beckmann = require(glsl-specular-beckmann) // used in gl-surface3d\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness\n , fresnel\n , kambient\n , kdiffuse\n , kspecular;\nuniform sampler2D texture;\n\nvarying vec3 f_normal\n , f_lightDirection\n , f_eyeDirection\n , f_data;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (f_color.a == 0.0 ||\n outOfRange(clipBounds[0], clipBounds[1], f_data)\n ) discard;\n\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = min(1.0, max(0.0, cookTorranceSpecular(L, V, N, roughness, fresnel)));\n //float specular = max(0.0, beckmann(L, V, N, roughness)); // used in gl-surface3d\n\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = vec4(f_color.rgb, 1.0) * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * f_color.a;\n}\n"]);var edgeVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\n\nuniform mat4 model, view, projection;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_color = color;\n f_data = position;\n f_uv = uv;\n}"]);var edgeFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec3 f_data;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_data)) discard;\n\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]);var pointVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 uv;\nattribute float pointSize;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0.0, 0.0 ,0.0 ,0.0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n }\n gl_PointSize = pointSize;\n f_color = color;\n f_uv = uv;\n}"]);var pointFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nuniform sampler2D texture;\nuniform float opacity;\n\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n vec2 pointR = gl_PointCoord.xy - vec2(0.5, 0.5);\n if(dot(pointR, pointR) > 0.25) {\n discard;\n }\n gl_FragColor = f_color * texture2D(texture, f_uv) * opacity;\n}"]);var pickVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n f_id = id;\n f_position = position;\n}"]);var pickFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);var pickPointVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute float pointSize;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0.0, 0.0, 0.0, 0.0);\n } else {\n gl_Position = projection * view * model * vec4(position, 1.0);\n gl_PointSize = pointSize;\n }\n f_id = id;\n f_position = position;\n}"]);var contourVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec3 position;\n\nuniform mat4 model, view, projection;\n\nvoid main() {\n gl_Position = projection * view * model * vec4(position, 1.0);\n}"]);var contourFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nuniform vec3 contourColor;\n\nvoid main() {\n gl_FragColor = vec4(contourColor, 1.0);\n}\n"]);exports.meshShader={vertex:triVertSrc,fragment:triFragSrc,attributes:[{name:'position',type:'vec3'},{name:'normal',type:'vec3'},{name:'color',type:'vec4'},{name:'uv',type:'vec2'}]};exports.wireShader={vertex:edgeVertSrc,fragment:edgeFragSrc,attributes:[{name:'position',type:'vec3'},{name:'color',type:'vec4'},{name:'uv',type:'vec2'}]};exports.pointShader={vertex:pointVertSrc,fragment:pointFragSrc,attributes:[{name:'position',type:'vec3'},{name:'color',type:'vec4'},{name:'uv',type:'vec2'},{name:'pointSize',type:'float'}]};exports.pickShader={vertex:pickVertSrc,fragment:pickFragSrc,attributes:[{name:'position',type:'vec3'},{name:'id',type:'vec4'}]};exports.pointPickShader={vertex:pickPointVertSrc,fragment:pickFragSrc,attributes:[{name:'position',type:'vec3'},{name:'pointSize',type:'float'},{name:'id',type:'vec4'}]};exports.contourShader={vertex:contourVertSrc,fragment:contourFragSrc,attributes:[{name:'position',type:'vec3'}]};/***/},/***/7201:/***/function(module,__unused_webpack_exports,__nested_webpack_require_374441__){"use strict";var DEFAULT_VERTEX_NORMALS_EPSILON=1e-6;// may be too large if triangles are very small
var DEFAULT_FACE_NORMALS_EPSILON=1e-6;var createShader=__nested_webpack_require_374441__(9405);var createBuffer=__nested_webpack_require_374441__(2762);var createVAO=__nested_webpack_require_374441__(8116);var createTexture=__nested_webpack_require_374441__(7766);var normals=__nested_webpack_require_374441__(8406);var multiply=__nested_webpack_require_374441__(6760);var invert=__nested_webpack_require_374441__(7608);var ndarray=__nested_webpack_require_374441__(9618);var colormap=__nested_webpack_require_374441__(6729);var getContour=__nested_webpack_require_374441__(7765);var pool=__nested_webpack_require_374441__(1888);var shaders=__nested_webpack_require_374441__(840);var closestPoint=__nested_webpack_require_374441__(7626);var meshShader=shaders.meshShader;var wireShader=shaders.wireShader;var pointShader=shaders.pointShader;var pickShader=shaders.pickShader;var pointPickShader=shaders.pointPickShader;var contourShader=shaders.contourShader;var IDENTITY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function SimplicialMesh(gl,texture,triShader,lineShader,pointShader,pickShader,pointPickShader,contourShader,trianglePositions,triangleIds,triangleColors,triangleUVs,triangleNormals,triangleVAO,edgePositions,edgeIds,edgeColors,edgeUVs,edgeVAO,pointPositions,pointIds,pointColors,pointUVs,pointSizes,pointVAO,contourPositions,contourVAO){this.gl=gl;this.pixelRatio=1;this.cells=[];this.positions=[];this.intensity=[];this.texture=texture;this.dirty=true;this.triShader=triShader;this.lineShader=lineShader;this.pointShader=pointShader;this.pickShader=pickShader;this.pointPickShader=pointPickShader;this.contourShader=contourShader;this.trianglePositions=trianglePositions;this.triangleColors=triangleColors;this.triangleNormals=triangleNormals;this.triangleUVs=triangleUVs;this.triangleIds=triangleIds;this.triangleVAO=triangleVAO;this.triangleCount=0;this.lineWidth=1;this.edgePositions=edgePositions;this.edgeColors=edgeColors;this.edgeUVs=edgeUVs;this.edgeIds=edgeIds;this.edgeVAO=edgeVAO;this.edgeCount=0;this.pointPositions=pointPositions;this.pointColors=pointColors;this.pointUVs=pointUVs;this.pointSizes=pointSizes;this.pointIds=pointIds;this.pointVAO=pointVAO;this.pointCount=0;this.contourLineWidth=1;this.contourPositions=contourPositions;this.contourVAO=contourVAO;this.contourCount=0;this.contourColor=[0,0,0];this.contourEnable=true;this.pickVertex=true;this.pickId=1;this.bounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];this.clipBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.lightPosition=[1e5,1e5,0];this.ambientLight=0.8;this.diffuseLight=0.8;this.specularLight=2.0;this.roughness=0.5;this.fresnel=1.5;this.opacity=1.0;this.hasAlpha=false;this.opacityscale=false;this._model=IDENTITY;this._view=IDENTITY;this._projection=IDENTITY;this._resolution=[1,1];}var proto=SimplicialMesh.prototype;proto.isOpaque=function(){return!this.hasAlpha;};proto.isTransparent=function(){return this.hasAlpha;};proto.pickSlots=1;proto.setPickBase=function(id){this.pickId=id;};function getOpacityFromScale(ratio,opacityscale){if(!opacityscale)return 1;if(!opacityscale.length)return 1;for(var i=0;iratio&&i>0){var d=(opacityscale[i][0]-ratio)/(opacityscale[i][0]-opacityscale[i-1][0]);return opacityscale[i][1]*(1-d)+d*opacityscale[i-1][1];}}return 1;}function genColormap(param,opacityscale){var colors=colormap({colormap:param,nshades:256,format:'rgba'});var result=new Uint8Array(256*4);for(var i=0;i<256;++i){var c=colors[i];for(var j=0;j<3;++j){result[4*i+j]=c[j];}if(!opacityscale){result[4*i+3]=255*c[3];}else{result[4*i+3]=255*getOpacityFromScale(i/255.0,opacityscale);}}return ndarray(result,[256,256,4],[4,0,1]);}function takeZComponent(array){var n=array.length;var result=new Array(n);for(var i=0;i0){var shader=this.triShader;shader.bind();shader.uniforms=uniforms;this.triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,this.triangleCount*3);this.triangleVAO.unbind();}if(this.edgeCount>0&&this.lineWidth>0){var shader=this.lineShader;shader.bind();shader.uniforms=uniforms;this.edgeVAO.bind();gl.lineWidth(this.lineWidth*this.pixelRatio);gl.drawArrays(gl.LINES,0,this.edgeCount*2);this.edgeVAO.unbind();}if(this.pointCount>0){var shader=this.pointShader;shader.bind();shader.uniforms=uniforms;this.pointVAO.bind();gl.drawArrays(gl.POINTS,0,this.pointCount);this.pointVAO.unbind();}if(this.contourEnable&&this.contourCount>0&&this.contourLineWidth>0){var shader=this.contourShader;shader.bind();shader.uniforms=uniforms;this.contourVAO.bind();gl.drawArrays(gl.LINES,0,this.contourCount);this.contourVAO.unbind();}};proto.drawPick=function(params){params=params||{};var gl=this.gl;var model=params.model||IDENTITY;var view=params.view||IDENTITY;var projection=params.projection||IDENTITY;var clipBounds=[[-1e6,-1e6,-1e6],[1e6,1e6,1e6]];for(var i=0;i<3;++i){clipBounds[0][i]=Math.max(clipBounds[0][i],this.clipBounds[0][i]);clipBounds[1][i]=Math.min(clipBounds[1][i],this.clipBounds[1][i]);}//Save camera parameters
this._model=[].slice.call(model);this._view=[].slice.call(view);this._projection=[].slice.call(projection);this._resolution=[gl.drawingBufferWidth,gl.drawingBufferHeight];var uniforms={model:model,view:view,projection:projection,clipBounds:clipBounds,pickId:this.pickId/255.0};var shader=this.pickShader;shader.bind();shader.uniforms=uniforms;if(this.triangleCount>0){this.triangleVAO.bind();gl.drawArrays(gl.TRIANGLES,0,this.triangleCount*3);this.triangleVAO.unbind();}if(this.edgeCount>0){this.edgeVAO.bind();gl.lineWidth(this.lineWidth*this.pixelRatio);gl.drawArrays(gl.LINES,0,this.edgeCount*2);this.edgeVAO.unbind();}if(this.pointCount>0){var shader=this.pointPickShader;shader.bind();shader.uniforms=uniforms;this.pointVAO.bind();gl.drawArrays(gl.POINTS,0,this.pointCount);this.pointVAO.unbind();}};proto.pick=function(pickData){if(!pickData){return null;}if(pickData.id!==this.pickId){return null;}var cellId=pickData.value[0]+256*pickData.value[1]+65536*pickData.value[2];var cell=this.cells[cellId];var positions=this.positions;var simplex=new Array(cell.length);for(var i=0;itickOffset[start]){shader.uniforms.dataAxis=DATA_AXIS;shader.uniforms.screenOffset=SCREEN_OFFSET;shader.uniforms.color=textColor[axis];shader.uniforms.angle=textAngle[axis];gl.drawArrays(gl.TRIANGLES,tickOffset[start],tickOffset[end]-tickOffset[start]);}}if(labelEnable[axis]&&labelCount){SCREEN_OFFSET[axis^1]-=screenScale*pixelRatio*labelPad[axis];shader.uniforms.dataAxis=ZERO_2;shader.uniforms.screenOffset=SCREEN_OFFSET;shader.uniforms.color=labelColor[axis];shader.uniforms.angle=labelAngle[axis];gl.drawArrays(gl.TRIANGLES,labelOffset,labelCount);}SCREEN_OFFSET[axis^1]=screenScale*viewBox[2+(axis^1)]-1.0;if(tickEnable[axis+2]){SCREEN_OFFSET[axis^1]+=screenScale*pixelRatio*tickPad[axis+2];if(starttickOffset[start]){shader.uniforms.dataAxis=DATA_AXIS;shader.uniforms.screenOffset=SCREEN_OFFSET;shader.uniforms.color=textColor[axis+2];shader.uniforms.angle=textAngle[axis+2];gl.drawArrays(gl.TRIANGLES,tickOffset[start],tickOffset[end]-tickOffset[start]);}}if(labelEnable[axis+2]&&labelCount){SCREEN_OFFSET[axis^1]+=screenScale*pixelRatio*labelPad[axis+2];shader.uniforms.dataAxis=ZERO_2;shader.uniforms.screenOffset=SCREEN_OFFSET;shader.uniforms.color=labelColor[axis+2];shader.uniforms.angle=labelAngle[axis+2];gl.drawArrays(gl.TRIANGLES,labelOffset,labelCount);}};}();proto.drawTitle=function(){var DATA_AXIS=[0,0];var SCREEN_OFFSET=[0,0];return function(){var plot=this.plot;var shader=this.shader;var gl=plot.gl;var screenBox=plot.screenBox;var titleCenter=plot.titleCenter;var titleAngle=plot.titleAngle;var titleColor=plot.titleColor;var pixelRatio=plot.pixelRatio;if(!this.titleCount){return;}for(var i=0;i<2;++i){SCREEN_OFFSET[i]=2.0*(titleCenter[i]*pixelRatio-screenBox[i])/(screenBox[2+i]-screenBox[i])-1;}shader.bind();shader.uniforms.dataAxis=DATA_AXIS;shader.uniforms.screenOffset=SCREEN_OFFSET;shader.uniforms.angle=titleAngle;shader.uniforms.color=titleColor;gl.drawArrays(gl.TRIANGLES,this.titleOffset,this.titleCount);};}();proto.bind=function(){var DATA_SHIFT=[0,0];var DATA_SCALE=[0,0];var TEXT_SCALE=[0,0];return function(){var plot=this.plot;var shader=this.shader;var bounds=plot._tickBounds;var dataBox=plot.dataBox;var screenBox=plot.screenBox;var viewBox=plot.viewBox;shader.bind();//Set up coordinate scaling uniforms
for(var i=0;i<2;++i){var lo=bounds[i];var hi=bounds[i+2];var boundScale=hi-lo;var dataCenter=0.5*(dataBox[i+2]+dataBox[i]);var dataWidth=dataBox[i+2]-dataBox[i];var viewLo=viewBox[i];var viewHi=viewBox[i+2];var viewScale=viewHi-viewLo;var screenLo=screenBox[i];var screenHi=screenBox[i+2];var screenScale=screenHi-screenLo;DATA_SCALE[i]=2.0*boundScale/dataWidth*viewScale/screenScale;DATA_SHIFT[i]=2.0*(lo-dataCenter)/dataWidth*viewScale/screenScale;}TEXT_SCALE[1]=2.0*plot.pixelRatio/(screenBox[3]-screenBox[1]);TEXT_SCALE[0]=TEXT_SCALE[1]*(screenBox[3]-screenBox[1])/(screenBox[2]-screenBox[0]);shader.uniforms.dataScale=DATA_SCALE;shader.uniforms.dataShift=DATA_SHIFT;shader.uniforms.textScale=TEXT_SCALE;//Set attributes
this.vbo.bind();shader.attributes.textCoordinate.pointer();};}();proto.update=function(options){var vertices=[];var axesTicks=options.ticks;var bounds=options.bounds;var i,j,k,data,scale,dimension;for(dimension=0;dimension<2;++dimension){var offsets=[Math.floor(vertices.length/3)],tickX=[-Infinity];//Copy vertices over to buffer
var ticks=axesTicks[dimension];for(i=0;i=0)){continue;}var zeroIntercept=screenBox[i]-dataBox[i]*(screenBox[i+2]-screenBox[i])/(dataBox[i+2]-dataBox[i]);if(i===0){line.drawLine(zeroIntercept,screenBox[1],zeroIntercept,screenBox[3],zeroLineWidth[i],zeroLineColor[i]);}else{line.drawLine(screenBox[0],zeroIntercept,screenBox[2],zeroIntercept,zeroLineWidth[i],zeroLineColor[i]);}}}//Draw traces
for(var i=0;i=0;--i){this.objects[i].dispose();}this.objects.length=0;for(var i=this.overlays.length-1;i>=0;--i){this.overlays[i].dispose();}this.overlays.length=0;this.gl=null;};proto.addObject=function(object){if(this.objects.indexOf(object)<0){this.objects.push(object);this.setDirty();}};proto.removeObject=function(object){var objects=this.objects;for(var i=0;iMath.abs(dy)){view.rotate(t,0,0,-dx*flipX*Math.PI*camera.rotateSpeed/window.innerWidth);}else{if(!camera._ortho){var kzoom=-camera.zoomSpeed*flipY*dy/window.innerHeight*(t-view.lastT())/20.0;view.pan(t,0,0,distance*(Math.exp(kzoom)-1));}}},true);};camera.enableMouseListeners();return camera;}/***/},/***/799:/***/function(module,__unused_webpack_exports,__nested_webpack_require_431926__){var glslify=__nested_webpack_require_431926__(3236);var createShader=__nested_webpack_require_431926__(9405);var vertSrc=glslify(["precision mediump float;\n#define GLSLIFY 1\nattribute vec2 position;\nvarying vec2 uv;\nvoid main() {\n uv = position;\n gl_Position = vec4(position, 0, 1);\n}"]);var fragSrc=glslify(["precision mediump float;\n#define GLSLIFY 1\n\nuniform sampler2D accumBuffer;\nvarying vec2 uv;\n\nvoid main() {\n vec4 accum = texture2D(accumBuffer, 0.5 * (uv + 1.0));\n gl_FragColor = min(vec4(1,1,1,1), accum);\n}"]);module.exports=function(gl){return createShader(gl,vertSrc,fragSrc,null,[{name:'position',type:'vec2'}]);};/***/},/***/4100:/***/function(module,__unused_webpack_exports,__nested_webpack_require_432630__){"use strict";var createCamera=__nested_webpack_require_432630__(4437);var createAxes=__nested_webpack_require_432630__(3837);var axesRanges=__nested_webpack_require_432630__(5445);var createSpikes=__nested_webpack_require_432630__(4449);var createSelect=__nested_webpack_require_432630__(3589);var createFBO=__nested_webpack_require_432630__(2260);var drawTriangle=__nested_webpack_require_432630__(7169);var mouseChange=__nested_webpack_require_432630__(351);var perspective=__nested_webpack_require_432630__(4772);var ortho=__nested_webpack_require_432630__(4040);var createShader=__nested_webpack_require_432630__(799);var isMobile=__nested_webpack_require_432630__(9216)({tablet:true,featureDetect:true});module.exports={createScene:createScene,createCamera:createCamera};function MouseSelect(){this.mouse=[-1,-1];this.screen=null;this.distance=Infinity;this.index=null;this.dataCoordinate=null;this.dataPosition=null;this.object=null;this.data=null;}function getContext(canvas,options){var gl=null;try{gl=canvas.getContext('webgl',options);if(!gl){gl=canvas.getContext('experimental-webgl',options);}}catch(e){return null;}return gl;}function roundUpPow10(x){var y=Math.round(Math.log(Math.abs(x))/Math.log(10));if(y<0){var base=Math.round(Math.pow(10,-y));return Math.ceil(x*base)/base;}else if(y>0){var base=Math.round(Math.pow(10,y));return Math.ceil(x/base)*base;}return Math.ceil(x);}function defaultBool(x){if(typeof x==='boolean'){return x;}return true;}function createScene(options){options=options||{};options.camera=options.camera||{};var canvas=options.canvas;if(!canvas){canvas=document.createElement('canvas');if(options.container){var container=options.container;container.appendChild(canvas);}else{document.body.appendChild(canvas);}}var gl=options.gl;if(!gl){if(options.glOptions){isMobile=!!options.glOptions.preserveDrawingBuffer;}gl=getContext(canvas,options.glOptions||{premultipliedAlpha:true,antialias:true,preserveDrawingBuffer:isMobile});}if(!gl){throw new Error('webgl not supported');}//Initial bounds
var bounds=options.bounds||[[-10,-10,-10],[10,10,10]];//Create selection
var selection=new MouseSelect();//Accumulation buffer
var accumBuffer=createFBO(gl,gl.drawingBufferWidth,gl.drawingBufferHeight,{preferFloat:!isMobile});var accumShader=createShader(gl);var isOrtho=options.cameraObject&&options.cameraObject._ortho===true||options.camera.projection&&options.camera.projection.type==='orthographic'||false;//Create a camera
var cameraOptions={eye:options.camera.eye||[2,0,0],center:options.camera.center||[0,0,0],up:options.camera.up||[0,1,0],zoomMin:options.camera.zoomMax||0.1,zoomMax:options.camera.zoomMin||100,mode:options.camera.mode||'turntable',_ortho:isOrtho};//Create axes
var axesOptions=options.axes||{};var axes=createAxes(gl,axesOptions);axes.enable=!axesOptions.disable;//Create spikes
var spikeOptions=options.spikes||{};var spikes=createSpikes(gl,spikeOptions);//Object list is empty initially
var objects=[];var pickBufferIds=[];var pickBufferCount=[];var pickBuffers=[];//Dirty flag, skip redraw if scene static
var dirty=true;var pickDirty=true;var projection=new Array(16);var model=new Array(16);var cameraParams={view:null,projection:projection,model:model,_ortho:false};var pickDirty=true;var viewShape=[gl.drawingBufferWidth,gl.drawingBufferHeight];var camera=options.cameraObject||createCamera(canvas,cameraOptions);//Create scene object
var scene={gl:gl,contextLost:false,pixelRatio:options.pixelRatio||1,canvas:canvas,selection:selection,camera:camera,axes:axes,axesPixels:null,spikes:spikes,bounds:bounds,objects:objects,shape:viewShape,aspect:options.aspectRatio||[1,1,1],pickRadius:options.pickRadius||10,zNear:options.zNear||0.01,zFar:options.zFar||1000,fovy:options.fovy||Math.PI/4,clearColor:options.clearColor||[0,0,0,0],autoResize:defaultBool(options.autoResize),autoBounds:defaultBool(options.autoBounds),autoScale:!!options.autoScale,autoCenter:defaultBool(options.autoCenter),clipToBounds:defaultBool(options.clipToBounds),snapToData:!!options.snapToData,onselect:options.onselect||null,onrender:options.onrender||null,onclick:options.onclick||null,cameraParams:cameraParams,oncontextloss:null,mouseListener:null,_stopped:false,getAspectratio:function(){return{x:this.aspect[0],y:this.aspect[1],z:this.aspect[2]};},setAspectratio:function(aspectratio){this.aspect[0]=aspectratio.x;this.aspect[1]=aspectratio.y;this.aspect[2]=aspectratio.z;pickDirty=true;},setBounds:function(axisIndex,range){this.bounds[0][axisIndex]=range.min;this.bounds[1][axisIndex]=range.max;},setClearColor:function(clearColor){this.clearColor=clearColor;},clearRGBA:function(){this.gl.clearColor(this.clearColor[0],this.clearColor[1],this.clearColor[2],this.clearColor[3]);this.gl.clear(this.gl.COLOR_BUFFER_BIT|this.gl.DEPTH_BUFFER_BIT);}};var pickShape=[gl.drawingBufferWidth/scene.pixelRatio|0,gl.drawingBufferHeight/scene.pixelRatio|0];function resizeListener(){if(scene._stopped){return;}if(!scene.autoResize){return;}var parent=canvas.parentNode;var width=1;var height=1;if(parent&&parent!==document.body){width=parent.clientWidth;height=parent.clientHeight;}else{width=window.innerWidth;height=window.innerHeight;}var nextWidth=Math.ceil(width*scene.pixelRatio)|0;var nextHeight=Math.ceil(height*scene.pixelRatio)|0;if(nextWidth!==canvas.width||nextHeight!==canvas.height){canvas.width=nextWidth;canvas.height=nextHeight;var style=canvas.style;style.position=style.position||'absolute';style.left='0px';style.top='0px';style.width=width+'px';style.height=height+'px';dirty=true;}}if(scene.autoResize){resizeListener();}window.addEventListener('resize',resizeListener);function reallocPickIds(){var numObjs=objects.length;var numPick=pickBuffers.length;for(var i=0;i0&&pickBufferCount[numPick-1]===0){pickBufferCount.pop();pickBuffers.pop().dispose();}}scene.update=function(options){if(scene._stopped){return;}options=options||{};dirty=true;pickDirty=true;};scene.add=function(obj){if(scene._stopped){return;}obj.axes=axes;objects.push(obj);pickBufferIds.push(-1);dirty=true;pickDirty=true;reallocPickIds();};scene.remove=function(obj){if(scene._stopped){return;}var idx=objects.indexOf(obj);if(idx<0){return;}objects.splice(idx,1);pickBufferIds.pop();dirty=true;pickDirty=true;reallocPickIds();};scene.dispose=function(){if(scene._stopped){return;}scene._stopped=true;window.removeEventListener('resize',resizeListener);canvas.removeEventListener('webglcontextlost',checkContextLoss);scene.mouseListener.enabled=false;if(scene.contextLost){return;}//Destroy objects
axes.dispose();spikes.dispose();for(var i=0;iselection.distance){continue;}for(var j=0;j 1.0) {\n discard;\n }\n baseColor = mix(borderColor, color, step(radius, centerFraction));\n gl_FragColor = vec4(baseColor.rgb * baseColor.a, baseColor.a);\n }\n}\n"]);exports.pickVertex=glslify(["precision mediump float;\n#define GLSLIFY 1\n\nattribute vec2 position;\nattribute vec4 pickId;\n\nuniform mat3 matrix;\nuniform float pointSize;\nuniform vec4 pickOffset;\n\nvarying vec4 fragId;\n\nvoid main() {\n vec3 hgPosition = matrix * vec3(position, 1);\n gl_Position = vec4(hgPosition.xy, 0, hgPosition.z);\n gl_PointSize = pointSize;\n\n vec4 id = pickId + pickOffset;\n id.y += floor(id.x / 256.0);\n id.x -= floor(id.x / 256.0) * 256.0;\n\n id.z += floor(id.y / 256.0);\n id.y -= floor(id.y / 256.0) * 256.0;\n\n id.w += floor(id.z / 256.0);\n id.z -= floor(id.z / 256.0) * 256.0;\n\n fragId = id;\n}\n"]);exports.pickFragment=glslify(["precision mediump float;\n#define GLSLIFY 1\n\nvarying vec4 fragId;\n\nvoid main() {\n float radius = length(2.0 * gl_PointCoord.xy - 1.0);\n if(radius > 1.0) {\n discard;\n }\n gl_FragColor = fragId / 255.0;\n}\n"]);/***/},/***/4696:/***/function(module,__unused_webpack_exports,__nested_webpack_require_450781__){"use strict";var createShader=__nested_webpack_require_450781__(9405);var createBuffer=__nested_webpack_require_450781__(2762);var pool=__nested_webpack_require_450781__(1888);var SHADERS=__nested_webpack_require_450781__(6640);module.exports=createPointcloud2D;function Pointcloud2D(plot,offsetBuffer,pickBuffer,shader,pickShader){this.plot=plot;this.offsetBuffer=offsetBuffer;this.pickBuffer=pickBuffer;this.shader=shader;this.pickShader=pickShader;this.sizeMin=0.5;this.sizeMinCap=2;this.sizeMax=20;this.areaRatio=1.0;this.pointCount=0;this.color=[1,0,0,1];this.borderColor=[0,0,0,1];this.blend=false;this.pickOffset=0;this.points=null;}var proto=Pointcloud2D.prototype;proto.dispose=function(){this.shader.dispose();this.pickShader.dispose();this.offsetBuffer.dispose();this.pickBuffer.dispose();this.plot.removeObject(this);};proto.update=function(options){var i;options=options||{};function dflt(opt,value){if(opt in options){return options[opt];}return value;}this.sizeMin=dflt('sizeMin',0.5);// this.sizeMinCap = dflt('sizeMinCap', 2)
this.sizeMax=dflt('sizeMax',20);this.color=dflt('color',[1,0,0,1]).slice();this.areaRatio=dflt('areaRatio',1);this.borderColor=dflt('borderColor',[0,0,0,1]).slice();this.blend=dflt('blend',false);//Update point data
// Attempt straight-through processing (STP) to avoid allocation and copy
// TODO eventually abstract out STP logic, maybe into `pool` or a layer above
var pointCount=options.positions.length>>>1;var dataStraightThrough=options.positions instanceof Float32Array;var idStraightThrough=options.idToIndex instanceof Int32Array&&options.idToIndex.length>=pointCount;// permit larger to help reuse
var data=options.positions;var packed=dataStraightThrough?data:pool.mallocFloat32(data.length);var packedId=idStraightThrough?options.idToIndex:pool.mallocInt32(pointCount);if(!dataStraightThrough){packed.set(data);}if(!idStraightThrough){packed.set(data);for(i=0;i>>1;var i;for(i=0;i=dataBox[0]&&x<=dataBox[2]&&y>=dataBox[1]&&y<=dataBox[3])visiblePointCountEstimate++;}return visiblePointCountEstimate;}proto.unifiedDraw=function(){var MATRIX=[1,0,0,0,1,0,0,0,1];var PICK_VEC4=[0,0,0,0];return function(pickOffset){var pick=pickOffset!==void 0;var shader=pick?this.pickShader:this.shader;var gl=this.plot.gl;var dataBox=this.plot.dataBox;if(this.pointCount===0){return pickOffset;}var dataX=dataBox[2]-dataBox[0];var dataY=dataBox[3]-dataBox[1];var visiblePointCountEstimate=count(this.points,dataBox);var basicPointSize=this.plot.pickPixelRatio*Math.max(Math.min(this.sizeMinCap,this.sizeMin),Math.min(this.sizeMax,this.sizeMax/Math.pow(visiblePointCountEstimate,0.33333)));MATRIX[0]=2.0/dataX;MATRIX[4]=2.0/dataY;MATRIX[6]=-2.0*dataBox[0]/dataX-1.0;MATRIX[7]=-2.0*dataBox[1]/dataY-1.0;this.offsetBuffer.bind();shader.bind();shader.attributes.position.pointer();shader.uniforms.matrix=MATRIX;shader.uniforms.color=this.color;shader.uniforms.borderColor=this.borderColor;shader.uniforms.pointCloud=basicPointSize<5;shader.uniforms.pointSize=basicPointSize;shader.uniforms.centerFraction=Math.min(1,Math.max(0,Math.sqrt(1-this.areaRatio)));if(pick){PICK_VEC4[0]=pickOffset&0xff;PICK_VEC4[1]=pickOffset>>8&0xff;PICK_VEC4[2]=pickOffset>>16&0xff;PICK_VEC4[3]=pickOffset>>24&0xff;this.pickBuffer.bind();shader.attributes.pickId.pointer(gl.UNSIGNED_BYTE);shader.uniforms.pickOffset=PICK_VEC4;this.pickOffset=pickOffset;}// Worth switching these off, but we can't make assumptions about other
// renderers, so let's restore it after each draw
var blend=gl.getParameter(gl.BLEND);var dither=gl.getParameter(gl.DITHER);if(blend&&!this.blend)gl.disable(gl.BLEND);if(dither)gl.disable(gl.DITHER);gl.drawArrays(gl.POINTS,0,this.pointCount);if(blend&&!this.blend)gl.enable(gl.BLEND);if(dither)gl.enable(gl.DITHER);return pickOffset+this.pointCount;};}();proto.draw=proto.unifiedDraw;proto.drawPick=proto.unifiedDraw;proto.pick=function(x,y,value){var pickOffset=this.pickOffset;var pointCount=this.pointCount;if(value=pickOffset+pointCount){return null;}var pointId=value-pickOffset;var points=this.points;return{object:this,pointId:pointId,dataCoord:[points[2*pointId],points[2*pointId+1]]};};function createPointcloud2D(plot,options){var gl=plot.gl;var buffer=createBuffer(gl);var pickBuffer=createBuffer(gl);var shader=createShader(gl,SHADERS.pointVertex,SHADERS.pointFragment);var pickShader=createShader(gl,SHADERS.pickVertex,SHADERS.pickFragment);var result=new Pointcloud2D(plot,buffer,pickBuffer,shader,pickShader);result.update(options);//Register with plot
plot.addObject(result);return result;}/***/},/***/783:/***/function(module){module.exports=slerp;/**
* Performs a spherical linear interpolation between two quat
*
* @param {quat} out the receiving quaternion
* @param {quat} a the first operand
* @param {quat} b the second operand
* @param {Number} t interpolation amount between the two inputs
* @returns {quat} out
*/function slerp(out,a,b,t){// benchmarks:
// http://jsperf.com/quaternion-slerp-implementations
var ax=a[0],ay=a[1],az=a[2],aw=a[3],bx=b[0],by=b[1],bz=b[2],bw=b[3];var omega,cosom,sinom,scale0,scale1;// calc cosine
cosom=ax*bx+ay*by+az*bz+aw*bw;// adjust signs (if necessary)
if(cosom<0.0){cosom=-cosom;bx=-bx;by=-by;bz=-bz;bw=-bw;}// calculate coefficients
if(1.0-cosom>0.000001){// standard case (slerp)
omega=Math.acos(cosom);sinom=Math.sin(omega);scale0=Math.sin((1.0-t)*omega)/sinom;scale1=Math.sin(t*omega)/sinom;}else{// "from" and "to" quaternions are very close
// ... so we can do a linear interpolation
scale0=1.0-t;scale1=t;}// calculate final values
out[0]=scale0*ax+scale1*bx;out[1]=scale0*ay+scale1*by;out[2]=scale0*az+scale1*bz;out[3]=scale0*aw+scale1*bw;return out;}/***/},/***/5964:/***/function(module){"use strict";module.exports=function(a){return!a&&a!==0?'':a.toString();};/***/},/***/9366:/***/function(module,__unused_webpack_exports,__nested_webpack_require_457012__){"use strict";var vectorizeText=__nested_webpack_require_457012__(4359);module.exports=getGlyph;var GLYPH_CACHE={};function getGlyph(symbol,font,pixelRatio){var fontCache=GLYPH_CACHE[font];if(!fontCache){fontCache=GLYPH_CACHE[font]={};}if(symbol in fontCache){return fontCache[symbol];}var config={textAlign:"center",textBaseline:"middle",lineHeight:1.0,font:font,lineSpacing:1.25,styletags:{breaklines:true,bolds:true,italics:true,subscripts:true,superscripts:true}};//Get line and triangle meshes for glyph
config.triangles=true;var triSymbol=vectorizeText(symbol,config);config.triangles=false;var lineSymbol=vectorizeText(symbol,config);var i,j;if(pixelRatio&&pixelRatio!==1){for(i=0;i max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform vec4 highlightId;\nuniform float highlightScale;\nuniform mat4 model, view, projection;\nuniform vec3 clipBounds[2];\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = 1.0;\n if(distance(highlightId, id) < 0.0001) {\n scale = highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1);\n vec4 viewPosition = view * worldPosition;\n viewPosition = viewPosition / viewPosition.w;\n vec4 clipPosition = projection * (viewPosition + scale * vec4(glyph.x, -glyph.y, 0, 0));\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]);var orthographicVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float highlightScale, pixelRatio;\nuniform vec4 highlightId;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float scale = pixelRatio;\n if(distance(highlightId.bgr, id.bgr) < 0.001) {\n scale *= highlightScale;\n }\n\n vec4 worldPosition = model * vec4(position, 1.0);\n vec4 viewPosition = view * worldPosition;\n vec4 clipPosition = projection * viewPosition;\n clipPosition /= clipPosition.w;\n\n gl_Position = clipPosition + vec4(screenSize * scale * vec2(glyph.x, -glyph.y), 0.0, 0.0);\n interpColor = color;\n pickId = id;\n dataCoordinate = position;\n }\n}"]);var projectionVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nattribute vec3 position;\nattribute vec4 color;\nattribute vec2 glyph;\nattribute vec4 id;\n\nuniform float highlightScale;\nuniform vec4 highlightId;\nuniform vec3 axes[2];\nuniform mat4 model, view, projection;\nuniform vec2 screenSize;\nuniform vec3 clipBounds[2];\nuniform float scale, pixelRatio;\n\nvarying vec4 interpColor;\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], position)) {\n\n gl_Position = vec4(0,0,0,0);\n } else {\n float lscale = pixelRatio * scale;\n if(distance(highlightId, id) < 0.0001) {\n lscale *= highlightScale;\n }\n\n vec4 clipCenter = projection * view * model * vec4(position, 1);\n vec3 dataPosition = position + 0.5*lscale*(axes[0] * glyph.x + axes[1] * glyph.y) * clipCenter.w * screenSize.y;\n vec4 clipPosition = projection * view * model * vec4(dataPosition, 1);\n\n gl_Position = clipPosition;\n interpColor = color;\n pickId = id;\n dataCoordinate = dataPosition;\n }\n}\n"]);var drawFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float opacity;\n\nvarying vec4 interpColor;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (\n outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate) ||\n interpColor.a * opacity == 0.\n ) discard;\n gl_FragColor = interpColor * opacity;\n}\n"]);var pickFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 fragClipBounds[2];\nuniform float pickGroup;\n\nvarying vec4 pickId;\nvarying vec3 dataCoordinate;\n\nvoid main() {\n if (outOfRange(fragClipBounds[0], fragClipBounds[1], dataCoordinate)) discard;\n\n gl_FragColor = vec4(pickGroup, pickId.bgr);\n}"]);var ATTRIBUTES=[{name:'position',type:'vec3'},{name:'color',type:'vec4'},{name:'glyph',type:'vec2'},{name:'id',type:'vec4'}];var perspective={vertex:perspectiveVertSrc,fragment:drawFragSrc,attributes:ATTRIBUTES},ortho={vertex:orthographicVertSrc,fragment:drawFragSrc,attributes:ATTRIBUTES},project={vertex:projectionVertSrc,fragment:drawFragSrc,attributes:ATTRIBUTES},pickPerspective={vertex:perspectiveVertSrc,fragment:pickFragSrc,attributes:ATTRIBUTES},pickOrtho={vertex:orthographicVertSrc,fragment:pickFragSrc,attributes:ATTRIBUTES},pickProject={vertex:projectionVertSrc,fragment:pickFragSrc,attributes:ATTRIBUTES};function createShader(gl,src){var shader=createShaderWrapper(gl,src);var attr=shader.attributes;attr.position.location=0;attr.color.location=1;attr.glyph.location=2;attr.id.location=3;return shader;}exports.createPerspective=function(gl){return createShader(gl,perspective);};exports.createOrtho=function(gl){return createShader(gl,ortho);};exports.createProject=function(gl){return createShader(gl,project);};exports.createPickPerspective=function(gl){return createShader(gl,pickPerspective);};exports.createPickOrtho=function(gl){return createShader(gl,pickOrtho);};exports.createPickProject=function(gl){return createShader(gl,pickProject);};/***/},/***/8418:/***/function(module,__unused_webpack_exports,__nested_webpack_require_466126__){"use strict";var isAllBlank=__nested_webpack_require_466126__(5219);var createBuffer=__nested_webpack_require_466126__(2762);var createVAO=__nested_webpack_require_466126__(8116);var pool=__nested_webpack_require_466126__(1888);var mat4mult=__nested_webpack_require_466126__(6760);var shaders=__nested_webpack_require_466126__(1283);var getGlyph=__nested_webpack_require_466126__(9366);var getSimpleString=__nested_webpack_require_466126__(5964);var IDENTITY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];module.exports=createPointCloud;function transformMat4(x,m){var x0=x[0];var x1=x[1];var x2=x[2];var x3=x[3];x[0]=m[0]*x0+m[4]*x1+m[8]*x2+m[12]*x3;x[1]=m[1]*x0+m[5]*x1+m[9]*x2+m[13]*x3;x[2]=m[2]*x0+m[6]*x1+m[10]*x2+m[14]*x3;x[3]=m[3]*x0+m[7]*x1+m[11]*x2+m[15]*x3;return x;}function project(p,v,m,x){transformMat4(x,x,m);transformMat4(x,x,v);return transformMat4(x,x,p);}function ScatterPlotPickResult(index,position){this.index=index;this.dataCoordinate=this.position=position;}function fixOpacity(a){if(a===true)return 1;if(a>1)return 1;return a;}function PointCloud(gl,shader,orthoShader,projectShader,pointBuffer,colorBuffer,glyphBuffer,idBuffer,vao,pickPerspectiveShader,pickOrthoShader,pickProjectShader){this.gl=gl;this.pixelRatio=1;this.shader=shader;this.orthoShader=orthoShader;this.projectShader=projectShader;this.pointBuffer=pointBuffer;this.colorBuffer=colorBuffer;this.glyphBuffer=glyphBuffer;this.idBuffer=idBuffer;this.vao=vao;this.vertexCount=0;this.lineVertexCount=0;this.opacity=1;this.hasAlpha=false;this.lineWidth=0;this.projectScale=[2.0/3.0,2.0/3.0,2.0/3.0];this.projectOpacity=[1,1,1];this.projectHasAlpha=false;this.pickId=0;this.pickPerspectiveShader=pickPerspectiveShader;this.pickOrthoShader=pickOrthoShader;this.pickProjectShader=pickProjectShader;this.points=[];this._selectResult=new ScatterPlotPickResult(0,[0,0,0]);this.useOrtho=true;this.bounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];//Axes projections
this.axesProject=[true,true,true];this.axesBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.highlightId=[1,1,1,1];this.highlightScale=2;this.clipBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.dirty=true;}var proto=PointCloud.prototype;proto.pickSlots=1;proto.setPickBase=function(pickBase){this.pickId=pickBase;};proto.isTransparent=function(){if(this.hasAlpha){return true;}for(var i=0;i<3;++i){if(this.axesProject[i]&&this.projectHasAlpha){return true;}}return false;};proto.isOpaque=function(){if(!this.hasAlpha){return true;}for(var i=0;i<3;++i){if(this.axesProject[i]&&!this.projectHasAlpha){return true;}}return false;};var VIEW_SHAPE=[0,0];var U_VEC=[0,0,0];var V_VEC=[0,0,0];var MU_VEC=[0,0,0,1];var MV_VEC=[0,0,0,1];var SCRATCH_MATRIX=IDENTITY.slice();var SCRATCH_VEC=[0,0,0];var CLIP_BOUNDS=[[0,0,0],[0,0,0]];function zeroVec(a){a[0]=a[1]=a[2]=0;return a;}function augment(hg,af){hg[0]=af[0];hg[1]=af[1];hg[2]=af[2];hg[3]=1;return hg;}function setComponent(out,v,i,x){out[0]=v[0];out[1]=v[1];out[2]=v[2];out[i]=x;return out;}function getClipBounds(bounds){var result=CLIP_BOUNDS;for(var i=0;i<2;++i){for(var j=0;j<3;++j){result[i][j]=Math.max(Math.min(bounds[i][j],1e8),-1e8);}}return result;}function drawProject(shader,points,camera,pixelRatio){var axesProject=points.axesProject;var gl=points.gl;var uniforms=shader.uniforms;var model=camera.model||IDENTITY;var view=camera.view||IDENTITY;var projection=camera.projection||IDENTITY;var bounds=points.axesBounds;var clipBounds=getClipBounds(points.clipBounds);var cubeAxis;if(points.axes&&points.axes.lastCubeProps){cubeAxis=points.axes.lastCubeProps.axis;}else{cubeAxis=[1,1,1];}VIEW_SHAPE[0]=2.0/gl.drawingBufferWidth;VIEW_SHAPE[1]=2.0/gl.drawingBufferHeight;shader.bind();uniforms.view=view;uniforms.projection=projection;uniforms.screenSize=VIEW_SHAPE;uniforms.highlightId=points.highlightId;uniforms.highlightScale=points.highlightScale;uniforms.clipBounds=clipBounds;uniforms.pickGroup=points.pickId/255.0;uniforms.pixelRatio=pixelRatio;for(var i=0;i<3;++i){if(!axesProject[i]){continue;}uniforms.scale=points.projectScale[i];uniforms.opacity=points.projectOpacity[i];//Project model matrix
var pmodel=SCRATCH_MATRIX;for(var j=0;j<16;++j){pmodel[j]=0;}for(var j=0;j<4;++j){pmodel[5*j]=1;}pmodel[5*i]=0;if(cubeAxis[i]<0){pmodel[12+i]=bounds[0][i];}else{pmodel[12+i]=bounds[1][i];}mat4mult(pmodel,model,pmodel);uniforms.model=pmodel;//Compute initial axes
var u=(i+1)%3;var v=(i+2)%3;var du=zeroVec(U_VEC);var dv=zeroVec(V_VEC);du[u]=1;dv[v]=1;//Align orientation relative to viewer
var mdu=project(projection,view,model,augment(MU_VEC,du));var mdv=project(projection,view,model,augment(MV_VEC,dv));if(Math.abs(mdu[1])>Math.abs(mdv[1])){var tmp=mdu;mdu=mdv;mdv=tmp;tmp=du;du=dv;dv=tmp;var t=u;u=v;v=t;}if(mdu[0]<0){du[u]=-1;}if(mdv[1]>0){dv[v]=-1;}var su=0.0;var sv=0.0;for(var j=0;j<4;++j){su+=Math.pow(model[4*u+j],2);sv+=Math.pow(model[4*v+j],2);}du[u]/=Math.sqrt(su);dv[v]/=Math.sqrt(sv);uniforms.axes[0]=du;uniforms.axes[1]=dv;//Update fragment clip bounds
uniforms.fragClipBounds[0]=setComponent(SCRATCH_VEC,clipBounds[0],i,-1e8);uniforms.fragClipBounds[1]=setComponent(SCRATCH_VEC,clipBounds[1],i,1e8);points.vao.bind();//Draw interior
points.vao.draw(gl.TRIANGLES,points.vertexCount);//Draw edges
if(points.lineWidth>0){gl.lineWidth(points.lineWidth*pixelRatio);points.vao.draw(gl.LINES,points.lineVertexCount,points.vertexCount);}points.vao.unbind();}}var NEG_INFINITY3=[-1e8,-1e8,-1e8];var POS_INFINITY3=[1e8,1e8,1e8];var CLIP_GROUP=[NEG_INFINITY3,POS_INFINITY3];function drawFull(shader,pshader,points,camera,pixelRatio,transparent,forceDraw){var gl=points.gl;if(transparent===points.projectHasAlpha||forceDraw){drawProject(pshader,points,camera,pixelRatio);}if(transparent===points.hasAlpha||forceDraw){shader.bind();var uniforms=shader.uniforms;uniforms.model=camera.model||IDENTITY;uniforms.view=camera.view||IDENTITY;uniforms.projection=camera.projection||IDENTITY;VIEW_SHAPE[0]=2.0/gl.drawingBufferWidth;VIEW_SHAPE[1]=2.0/gl.drawingBufferHeight;uniforms.screenSize=VIEW_SHAPE;uniforms.highlightId=points.highlightId;uniforms.highlightScale=points.highlightScale;uniforms.fragClipBounds=CLIP_GROUP;uniforms.clipBounds=points.axes.bounds;uniforms.opacity=points.opacity;uniforms.pickGroup=points.pickId/255.0;uniforms.pixelRatio=pixelRatio;points.vao.bind();//Draw interior
points.vao.draw(gl.TRIANGLES,points.vertexCount);//Draw edges
if(points.lineWidth>0){gl.lineWidth(points.lineWidth*pixelRatio);points.vao.draw(gl.LINES,points.lineVertexCount,points.vertexCount);}points.vao.unbind();}}proto.draw=function(camera){var shader=this.useOrtho?this.orthoShader:this.shader;drawFull(shader,this.projectShader,this,camera,this.pixelRatio,false,false);};proto.drawTransparent=function(camera){var shader=this.useOrtho?this.orthoShader:this.shader;drawFull(shader,this.projectShader,this,camera,this.pixelRatio,true,false);};proto.drawPick=function(camera){var shader=this.useOrtho?this.pickOrthoShader:this.pickPerspectiveShader;drawFull(shader,this.pickProjectShader,this,camera,1,true,true);};proto.pick=function(selected){if(!selected){return null;}if(selected.id!==this.pickId){return null;}var x=selected.value[2]+(selected.value[1]<<8)+(selected.value[0]<<16);if(x>=this.pointCount||x<0){return null;}//Unpack result
var coord=this.points[x];var result=this._selectResult;result.index=x;for(var i=0;i<3;++i){result.position[i]=result.dataCoordinate[i]=coord[i];}return result;};proto.highlight=function(selection){if(!selection){this.highlightId=[1,1,1,1];}else{var pointId=selection.index;var a0=pointId&0xff;var a1=pointId>>8&0xff;var a2=pointId>>16&0xff;this.highlightId=[a0/255.0,a1/255.0,a2/255.0,0];}};function get_glyphData(glyphs,index,font,pixelRatio){var str;// use the data if presented in an array
if(Array.isArray(glyphs)){if(index0){var triOffset=0;var lineOffset=triVertexCount;var color=[0,0,0,1];var lineColor=[0,0,0,1];var isColorArray=Array.isArray(colors)&&Array.isArray(colors[0]);var isLineColorArray=Array.isArray(lineColors)&&Array.isArray(lineColors[0]);fill_loop:for(var i=0;i0?1-glyphBounds[0][0]:textOffsetX<0?1+glyphBounds[1][0]:1;textOffsetY*=textOffsetY>0?1-glyphBounds[0][1]:textOffsetY<0?1+glyphBounds[1][1]:1;var textOffset=[textOffsetX,textOffsetY];//Write out inner marker
var cells=glyphMesh.cells||[];var verts=glyphMesh.positions||[];for(var j=0;j0){//Draw border
var w=lineWidth*pixelRatio;boxes.drawBox(loX-w,loY-w,hiX+w,loY+w,borderColor);boxes.drawBox(loX-w,hiY-w,hiX+w,hiY+w,borderColor);boxes.drawBox(loX-w,loY-w,loX+w,hiY+w,borderColor);boxes.drawBox(hiX-w,loY-w,hiX+w,hiY+w,borderColor);}};proto.update=function(options){options=options||{};this.innerFill=!!options.innerFill;this.outerFill=!!options.outerFill;this.innerColor=(options.innerColor||[0,0,0,0.5]).slice();this.outerColor=(options.outerColor||[0,0,0,0.5]).slice();this.borderColor=(options.borderColor||[0,0,0,1]).slice();this.borderWidth=options.borderWidth||0;this.selectBox=(options.selectBox||this.selectBox).slice();};proto.dispose=function(){this.boxBuffer.dispose();this.boxShader.dispose();this.plot.removeOverlay(this);};function createSelectBox(plot,options){var gl=plot.gl;var buffer=createBuffer(gl,[0,0,0,1,1,0,1,1]);var shader=createShader(gl,SHADERS.boxVertex,SHADERS.boxFragment);var selectBox=new SelectBox(plot,buffer,shader);selectBox.update(options);plot.addOverlay(selectBox);return selectBox;}/***/},/***/3589:/***/function(module,__unused_webpack_exports,__nested_webpack_require_485710__){"use strict";module.exports=createSelectBuffer;var createFBO=__nested_webpack_require_485710__(2260);var pool=__nested_webpack_require_485710__(1888);var ndarray=__nested_webpack_require_485710__(9618);var nextPow2=__nested_webpack_require_485710__(8828).nextPow2;var selectRange=function(arr,x,y){var closestD2=1e8;var closestX=-1;var closestY=-1;var ni=arr.shape[0];var nj=arr.shape[1];for(var i=0;ithis.buffer.length){pool.free(this.buffer);var buffer=this.buffer=pool.mallocUint8(nextPow2(r*c*4));for(var i=0;ioldAttribCount){for(i=oldAttribCount;inewAttribCount){for(i=newAttribCount;i=0){var size=attr.type.charAt(attr.type.length-1)|0;var locVector=new Array(size);for(var j=0;j=0){curLocation+=1;}attributeLocations[i]=curLocation;}}//Rebuild program and recompute all uniform locations
var uniformLocations=new Array(uniforms.length);function relink(){wrapper.program=shaderCache.program(gl,wrapper._vref,wrapper._fref,attributeNames,attributeLocations);for(var i=0;i=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new GLError('','Invalid data type for attribute '+name+': '+type);}addVectorAttribute(gl,wrapper,locs[0],locations,d,obj,name);}else if(type.indexOf('mat')>=0){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new GLError('','Invalid data type for attribute '+name+': '+type);}addMatrixAttribute(gl,wrapper,locs,locations,d,obj,name);}else{throw new GLError('','Unknown data type for attribute '+name+': '+type);}break;}}return obj;}/***/},/***/3327:/***/function(module,__unused_webpack_exports,__nested_webpack_require_499285__){"use strict";var coallesceUniforms=__nested_webpack_require_499285__(216);var GLError=__nested_webpack_require_499285__(8866);module.exports=createUniformWrapper;//Binds a function and returns a value
function identity(x){return function(){return x;};}function makeVector(length,fill){var result=new Array(length);for(var i=0;i4){throw new GLError('','Invalid data type');}switch(t.charAt(0)){case'b':case'i':gl['uniform'+d+'iv'](locations[idx],objPath);break;case'v':gl['uniform'+d+'fv'](locations[idx],objPath);break;default:throw new GLError('','Unrecognized data type for vector '+name+': '+t);}}else if(t.indexOf('mat')===0&&t.length===4){d=t.charCodeAt(t.length-1)-48;if(d<2||d>4){throw new GLError('','Invalid uniform dimension type for matrix '+name+': '+t);}gl['uniformMatrix'+d+'fv'](locations[idx],false,objPath);break;}else{throw new GLError('','Unknown uniform data type for '+name+': '+t);}}}}};}function enumerateIndices(prefix,type){if(typeof type!=='object'){return[[prefix,type]];}var indices=[];for(var id in type){var prop=type[id];var tprefix=prefix;if(parseInt(id)+''===id){tprefix+='['+id+']';}else{tprefix+='.'+id;}if(typeof prop==='object'){indices.push.apply(indices,enumerateIndices(tprefix,prop));}else{indices.push([tprefix,prop]);}}return indices;}function defaultValue(type){switch(type){case'bool':return false;case'int':case'sampler2D':case'samplerCube':return 0;case'float':return 0.0;default:var vidx=type.indexOf('vec');if(0<=vidx&&vidx<=1&&type.length===4+vidx){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new GLError('','Invalid data type');}if(type.charAt(0)==='b'){return makeVector(d,false);}return makeVector(d,0);}else if(type.indexOf('mat')===0&&type.length===4){var d=type.charCodeAt(type.length-1)-48;if(d<2||d>4){throw new GLError('','Invalid uniform dimension type for matrix '+name+': '+type);}return makeVector(d*d,0);}else{throw new GLError('','Unknown uniform data type for '+name+': '+type);}}}function storeProperty(obj,prop,type){if(typeof type==='object'){var child=processObject(type);Object.defineProperty(obj,prop,{get:identity(child),set:makeSetter(type),enumerable:true,configurable:false});}else{if(locations[type]){Object.defineProperty(obj,prop,{get:makeGetter(type),set:makeSetter(type),enumerable:true,configurable:false});}else{obj[prop]=defaultValue(uniforms[type].type);}}}function processObject(obj){var result;if(Array.isArray(obj)){result=new Array(obj.length);for(var i=0;i1){if(!(x[0]in o)){o[x[0]]=[];}o=o[x[0]];for(var k=1;k1){for(var j=0;j 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 color, position;\nattribute vec2 uv;\n\nuniform float vectorScale, tubeScale;\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 eyePosition, lightPosition;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n // Scale the vector magnitude to stay constant with\n // model & view changes.\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * tubePosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n f_lightDirection = lightPosition - cameraCoordinate.xyz;\n f_eyeDirection = eyePosition - cameraCoordinate.xyz;\n f_normal = normalize((vec4(normal, 0.0) * inverseModel).xyz);\n\n // vec4 m_position = model * vec4(tubePosition, 1.0);\n vec4 t_position = view * tubePosition;\n gl_Position = projection * t_position;\n\n f_color = color;\n f_data = tubePosition.xyz;\n f_position = position.xyz;\n f_uv = uv;\n}\n"]);var triFragSrc=glslify(["#extension GL_OES_standard_derivatives : enable\n\nprecision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat cookTorranceSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness,\n float fresnel) {\n\n float VdotN = max(dot(viewDirection, surfaceNormal), 0.0);\n float LdotN = max(dot(lightDirection, surfaceNormal), 0.0);\n\n //Half angle vector\n vec3 H = normalize(lightDirection + viewDirection);\n\n //Geometric term\n float NdotH = max(dot(surfaceNormal, H), 0.0);\n float VdotH = max(dot(viewDirection, H), 0.000001);\n float LdotH = max(dot(lightDirection, H), 0.000001);\n float G1 = (2.0 * NdotH * VdotN) / VdotH;\n float G2 = (2.0 * NdotH * LdotN) / LdotH;\n float G = min(1.0, min(G1, G2));\n \n //Distribution term\n float D = beckmannDistribution(NdotH, roughness);\n\n //Fresnel term\n float F = pow(1.0 - VdotN, fresnel);\n\n //Multiply terms and done\n return G * F * D / max(3.14159265 * VdotN, 0.000001);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform sampler2D texture;\n\nvarying vec3 f_normal, f_lightDirection, f_eyeDirection, f_data, f_position;\nvarying vec4 f_color;\nvarying vec2 f_uv;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n vec3 N = normalize(f_normal);\n vec3 L = normalize(f_lightDirection);\n vec3 V = normalize(f_eyeDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = min(1.0, max(0.0, cookTorranceSpecular(L, V, N, roughness, fresnel)));\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n vec4 surfaceColor = f_color * texture2D(texture, f_uv);\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = litColor * opacity;\n}\n"]);var pickVertSrc=glslify(["precision highp float;\n\nprecision highp float;\n#define GLSLIFY 1\n\nvec3 getOrthogonalVector(vec3 v) {\n // Return up-vector for only-z vector.\n // Return ax + by + cz = 0, a point that lies on the plane that has v as a normal and that isn't (0,0,0).\n // From the above if-statement we have ||a|| > 0 U ||b|| > 0.\n // Assign z = 0, x = -b, y = a:\n // a*-b + b*a + c*0 = -ba + ba + 0 = 0\n if (v.x*v.x > v.z*v.z || v.y*v.y > v.z*v.z) {\n return normalize(vec3(-v.y, v.x, 0.0));\n } else {\n return normalize(vec3(0.0, v.z, -v.y));\n }\n}\n\n// Calculate the tube vertex and normal at the given index.\n//\n// The returned vertex is for a tube ring with its center at origin, radius of length(d), pointing in the direction of d.\n//\n// Each tube segment is made up of a ring of vertices.\n// These vertices are used to make up the triangles of the tube by connecting them together in the vertex array.\n// The indexes of tube segments run from 0 to 8.\n//\nvec3 getTubePosition(vec3 d, float index, out vec3 normal) {\n float segmentCount = 8.0;\n\n float angle = 2.0 * 3.14159 * (index / segmentCount);\n\n vec3 u = getOrthogonalVector(d);\n vec3 v = normalize(cross(u, d));\n\n vec3 x = u * cos(angle) * length(d);\n vec3 y = v * sin(angle) * length(d);\n vec3 v3 = x + y;\n\n normal = normalize(v3);\n\n return v3;\n}\n\nattribute vec4 vector;\nattribute vec4 position;\nattribute vec4 id;\n\nuniform mat4 model, view, projection;\nuniform float tubeScale;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n vec3 normal;\n vec3 XYZ = getTubePosition(mat3(model) * (tubeScale * vector.w * normalize(vector.xyz)), position.w, normal);\n vec4 tubePosition = model * vec4(position.xyz, 1.0) + vec4(XYZ, 0.0);\n\n gl_Position = projection * view * tubePosition;\n f_id = id;\n f_position = position.xyz;\n}\n"]);var pickFragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying vec3 f_position;\nvarying vec4 f_id;\n\nvoid main() {\n if (outOfRange(clipBounds[0], clipBounds[1], f_position)) discard;\n\n gl_FragColor = vec4(pickId, f_id.xyz);\n}"]);exports.meshShader={vertex:triVertSrc,fragment:triFragSrc,attributes:[{name:'position',type:'vec4'},{name:'color',type:'vec4'},{name:'uv',type:'vec2'},{name:'vector',type:'vec4'}]};exports.pickShader={vertex:pickVertSrc,fragment:pickFragSrc,attributes:[{name:'position',type:'vec4'},{name:'id',type:'vec4'},{name:'vector',type:'vec4'}]};/***/},/***/7815:/***/function(module,__unused_webpack_exports,__nested_webpack_require_523578__){"use strict";var vec3=__nested_webpack_require_523578__(2931);var vec4=__nested_webpack_require_523578__(9970);var GRID_TYPES=['xyz','xzy','yxz','yzx','zxy','zyx'];var streamToTube=function(stream,maxDivergence,minDistance,maxNorm){var points=stream.points;var velocities=stream.velocities;var divergences=stream.divergences;var verts=[];var faces=[];var vectors=[];var previousVerts=[];var currentVerts=[];var intensities=[];var previousIntensity=0;var currentIntensity=0;var currentVector=vec4.create();var previousVector=vec4.create();var facets=8;for(var i=0;i0){for(var a=0;av)return i-1;}return i;};var clamp=function(v,min,max){return vmax?max:v;};var sampleMeshgrid=function(point,vectorField,gridInfo){var vectors=vectorField.vectors;var meshgrid=vectorField.meshgrid;var x=point[0];var y=point[1];var z=point[2];var w=meshgrid[0].length;var h=meshgrid[1].length;var d=meshgrid[2].length;// Find the index of the nearest smaller value in the meshgrid for each coordinate of (x,y,z).
// The nearest smaller value index for x is the index x0 such that
// meshgrid[0][x0] < x and for all x1 > x0, meshgrid[0][x1] >= x.
var x0=findLastSmallerIndex(meshgrid[0],x);var y0=findLastSmallerIndex(meshgrid[1],y);var z0=findLastSmallerIndex(meshgrid[2],z);// Get the nearest larger meshgrid value indices.
// From the above "nearest smaller value", we know that
// meshgrid[0][x0] < x
// meshgrid[0][x0+1] >= x
var x1=x0+1;var y1=y0+1;var z1=z0+1;x0=clamp(x0,0,w-1);x1=clamp(x1,0,w-1);y0=clamp(y0,0,h-1);y1=clamp(y1,0,h-1);z0=clamp(z0,0,d-1);z1=clamp(z1,0,d-1);// Reject points outside the meshgrid, return a zero vector.
if(x0<0||y0<0||z0<0||x1>w-1||y1>h-1||z1>d-1){return vec3.create();}// Normalize point coordinates to 0..1 scaling factor between x0 and x1.
var mX0=meshgrid[0][x0];var mX1=meshgrid[0][x1];var mY0=meshgrid[1][y0];var mY1=meshgrid[1][y1];var mZ0=meshgrid[2][z0];var mZ1=meshgrid[2][z1];var xf=(x-mX0)/(mX1-mX0);var yf=(y-mY0)/(mY1-mY0);var zf=(z-mZ0)/(mZ1-mZ0);if(!isFinite(xf))xf=0.5;if(!isFinite(yf))yf=0.5;if(!isFinite(zf))zf=0.5;var x0off;var x1off;var y0off;var y1off;var z0off;var z1off;if(gridInfo.reversedX){x0=w-1-x0;x1=w-1-x1;}if(gridInfo.reversedY){y0=h-1-y0;y1=h-1-y1;}if(gridInfo.reversedZ){z0=d-1-z0;z1=d-1-z1;}switch(gridInfo.filled){case 5:// 'zyx'
z0off=z0;z1off=z1;y0off=y0*d;y1off=y1*d;x0off=x0*d*h;x1off=x1*d*h;break;case 4:// 'zxy'
z0off=z0;z1off=z1;x0off=x0*d;x1off=x1*d;y0off=y0*d*w;y1off=y1*d*w;break;case 3:// 'yzx'
y0off=y0;y1off=y1;z0off=z0*h;z1off=z1*h;x0off=x0*h*d;x1off=x1*h*d;break;case 2:// 'yxz'
y0off=y0;y1off=y1;x0off=x0*h;x1off=x1*h;z0off=z0*h*w;z1off=z1*h*w;break;case 1:// 'xzy'
x0off=x0;x1off=x1;z0off=z0*w;z1off=z1*w;y0off=y0*w*d;y1off=y1*w*d;break;default:// case 0: // 'xyz'
x0off=x0;x1off=x1;y0off=y0*w;y1off=y1*w;z0off=z0*w*h;z1off=z1*w*h;break;}// Sample data vectors around the (x,y,z) point.
var v000=vectors[x0off+y0off+z0off];var v001=vectors[x0off+y0off+z1off];var v010=vectors[x0off+y1off+z0off];var v011=vectors[x0off+y1off+z1off];var v100=vectors[x1off+y0off+z0off];var v101=vectors[x1off+y0off+z1off];var v110=vectors[x1off+y1off+z0off];var v111=vectors[x1off+y1off+z1off];var c00=vec3.create();var c01=vec3.create();var c10=vec3.create();var c11=vec3.create();vec3.lerp(c00,v000,v100,xf);vec3.lerp(c01,v001,v101,xf);vec3.lerp(c10,v010,v110,xf);vec3.lerp(c11,v011,v111,xf);var c0=vec3.create();var c1=vec3.create();vec3.lerp(c0,c00,c10,yf);vec3.lerp(c1,c01,c11,yf);var c=vec3.create();vec3.lerp(c,c0,c1,zf);return c;};var vabs=function(dst,v){var x=v[0];var y=v[1];var z=v[2];dst[0]=x<0?-x:x;dst[1]=y<0?-y:y;dst[2]=z<0?-z:z;return dst;};var findMinSeparation=function(xs){var minSeparation=Infinity;xs.sort(function(a,b){return a-b;});var len=xs.length;for(var i=1;imaxX||ymaxY||zmaxZ);};var boundsSize=vec3.distance(bounds[0],bounds[1]);var maxStepSize=10*boundsSize/maxLength;var maxStepSizeSq=maxStepSize*maxStepSize;var minDistance=1;var maxDivergence=0;// For component-wise divergence vec3.create();
// In case we need to do component-wise divergence visualization
// var tmp = vec3.create();
var len=positions.length;if(len>1){minDistance=calculateMinPositionDistance(positions);}for(var i=0;imaxDivergence){maxDivergence=dvLength;}// In case we need to do component-wise divergence visualization
// vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv));
divergences.push(dvLength);streams.push({points:stream,velocities:velocities,divergences:divergences});var j=0;while(jmaxStepSizeSq){vec3.scale(np,np,maxStepSize/Math.sqrt(sqLen));}vec3.add(np,np,p);v=getVelocity(np);if(vec3.squaredDistance(op,np)-maxStepSizeSq>-0.0001*maxStepSizeSq){stream.push(np);op=np;velocities.push(v);var dv=getDivergence(np,v);var dvLength=vec3.length(dv);if(isFinite(dvLength)&&dvLength>maxDivergence){maxDivergence=dvLength;}// In case we need to do component-wise divergence visualization
//vec3.max(maxDivergence, maxDivergence, vabs(tmp, dv));
divergences.push(dvLength);}p=np;}}var tubes=createTubes(streams,vectorField.colormap,maxDivergence,minDistance);if(absoluteTubeSize){tubes.tubeScale=absoluteTubeSize;}else{// Avoid division by zero.
if(maxDivergence===0){maxDivergence=1;}tubes.tubeScale=tubeSize*0.5*minDistance/maxDivergence;}return tubes;};var shaders=__nested_webpack_require_523578__(6740);var createMesh=__nested_webpack_require_523578__(6405).createMesh;module.exports.createTubeMesh=function(gl,params){return createMesh(gl,params,{shaders:shaders,traceType:'streamtube'});};/***/},/***/990:/***/function(__unused_webpack_module,exports,__nested_webpack_require_534902__){var createShader=__nested_webpack_require_534902__(9405);var glslify=__nested_webpack_require_534902__(3236);var vertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute vec3 f;\nattribute vec3 normal;\n\nuniform vec3 objectOffset;\nuniform mat4 model, view, projection, inverseModel;\nuniform vec3 lightPosition, eyePosition;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 localCoordinate = vec3(uv.zw, f.x);\n worldCoordinate = objectOffset + localCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n vec4 clipPosition = projection * view * worldPosition;\n gl_Position = clipPosition;\n kill = f.y;\n value = f.z;\n planeCoordinate = uv.xy;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Lighting geometry parameters\n vec4 cameraCoordinate = view * worldPosition;\n cameraCoordinate.xyz /= cameraCoordinate.w;\n lightDirection = lightPosition - cameraCoordinate.xyz;\n eyeDirection = eyePosition - cameraCoordinate.xyz;\n surfaceNormal = normalize((vec4(normal,0) * inverseModel).xyz);\n}\n"]);var fragSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nfloat beckmannDistribution(float x, float roughness) {\n float NdotH = max(x, 0.0001);\n float cos2Alpha = NdotH * NdotH;\n float tan2Alpha = (cos2Alpha - 1.0) / cos2Alpha;\n float roughness2 = roughness * roughness;\n float denom = 3.141592653589793 * roughness2 * cos2Alpha * cos2Alpha;\n return exp(tan2Alpha / roughness2) / denom;\n}\n\nfloat beckmannSpecular(\n vec3 lightDirection,\n vec3 viewDirection,\n vec3 surfaceNormal,\n float roughness) {\n return beckmannDistribution(dot(surfaceNormal, normalize(lightDirection + viewDirection)), roughness);\n}\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec3 lowerBound, upperBound;\nuniform float contourTint;\nuniform vec4 contourColor;\nuniform sampler2D colormap;\nuniform vec3 clipBounds[2];\nuniform float roughness, fresnel, kambient, kdiffuse, kspecular, opacity;\nuniform float vertexColor;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n if (\n kill > 0.0 ||\n vColor.a == 0.0 ||\n outOfRange(clipBounds[0], clipBounds[1], worldCoordinate)\n ) discard;\n\n vec3 N = normalize(surfaceNormal);\n vec3 V = normalize(eyeDirection);\n vec3 L = normalize(lightDirection);\n\n if(gl_FrontFacing) {\n N = -N;\n }\n\n float specular = max(beckmannSpecular(L, V, N, roughness), 0.);\n float diffuse = min(kambient + kdiffuse * max(dot(N, L), 0.0), 1.0);\n\n //decide how to interpolate color — in vertex or in fragment\n vec4 surfaceColor =\n step(vertexColor, .5) * texture2D(colormap, vec2(value, value)) +\n step(.5, vertexColor) * vColor;\n\n vec4 litColor = surfaceColor.a * vec4(diffuse * surfaceColor.rgb + kspecular * vec3(1,1,1) * specular, 1.0);\n\n gl_FragColor = mix(litColor, contourColor, contourTint) * opacity;\n}\n"]);var contourVertSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nattribute vec4 uv;\nattribute float f;\n\nuniform vec3 objectOffset;\nuniform mat3 permutation;\nuniform mat4 model, view, projection;\nuniform float height, zOffset;\nuniform sampler2D colormap;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 lightDirection, eyeDirection, surfaceNormal;\nvarying vec4 vColor;\n\nvoid main() {\n vec3 dataCoordinate = permutation * vec3(uv.xy, height);\n worldCoordinate = objectOffset + dataCoordinate;\n vec4 worldPosition = model * vec4(worldCoordinate, 1.0);\n\n vec4 clipPosition = projection * view * worldPosition;\n clipPosition.z += zOffset;\n\n gl_Position = clipPosition;\n value = f + objectOffset.z;\n kill = -1.0;\n planeCoordinate = uv.zw;\n\n vColor = texture2D(colormap, vec2(value, value));\n\n //Don't do lighting for contours\n surfaceNormal = vec3(1,0,0);\n eyeDirection = vec3(0,1,0);\n lightDirection = vec3(0,0,1);\n}\n"]);var pickSrc=glslify(["precision highp float;\n#define GLSLIFY 1\n\nbool outOfRange(float a, float b, float p) {\n return ((p > max(a, b)) || \n (p < min(a, b)));\n}\n\nbool outOfRange(vec2 a, vec2 b, vec2 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y));\n}\n\nbool outOfRange(vec3 a, vec3 b, vec3 p) {\n return (outOfRange(a.x, b.x, p.x) ||\n outOfRange(a.y, b.y, p.y) ||\n outOfRange(a.z, b.z, p.z));\n}\n\nbool outOfRange(vec4 a, vec4 b, vec4 p) {\n return outOfRange(a.xyz, b.xyz, p.xyz);\n}\n\nuniform vec2 shape;\nuniform vec3 clipBounds[2];\nuniform float pickId;\n\nvarying float value, kill;\nvarying vec3 worldCoordinate;\nvarying vec2 planeCoordinate;\nvarying vec3 surfaceNormal;\n\nvec2 splitFloat(float v) {\n float vh = 255.0 * v;\n float upper = floor(vh);\n float lower = fract(vh);\n return vec2(upper / 255.0, floor(lower * 16.0) / 16.0);\n}\n\nvoid main() {\n if ((kill > 0.0) ||\n (outOfRange(clipBounds[0], clipBounds[1], worldCoordinate))) discard;\n\n vec2 ux = splitFloat(planeCoordinate.x / shape.x);\n vec2 uy = splitFloat(planeCoordinate.y / shape.y);\n gl_FragColor = vec4(pickId, ux.x, uy.x, ux.y + (uy.y/16.0));\n}\n"]);exports.createShader=function(gl){var shader=createShader(gl,vertSrc,fragSrc,null,[{name:'uv',type:'vec4'},{name:'f',type:'vec3'},{name:'normal',type:'vec3'}]);shader.attributes.uv.location=0;shader.attributes.f.location=1;shader.attributes.normal.location=2;return shader;};exports.createPickShader=function(gl){var shader=createShader(gl,vertSrc,pickSrc,null,[{name:'uv',type:'vec4'},{name:'f',type:'vec3'},{name:'normal',type:'vec3'}]);shader.attributes.uv.location=0;shader.attributes.f.location=1;shader.attributes.normal.location=2;return shader;};exports.createContourShader=function(gl){var shader=createShader(gl,contourVertSrc,fragSrc,null,[{name:'uv',type:'vec4'},{name:'f',type:'float'}]);shader.attributes.uv.location=0;shader.attributes.f.location=1;return shader;};exports.createPickContourShader=function(gl){var shader=createShader(gl,contourVertSrc,pickSrc,null,[{name:'uv',type:'vec4'},{name:'f',type:'float'}]);shader.attributes.uv.location=0;shader.attributes.f.location=1;return shader;};/***/},/***/9499:/***/function(module,__unused_webpack_exports,__nested_webpack_require_541866__){"use strict";module.exports=createSurfacePlot;var bits=__nested_webpack_require_541866__(8828);var createBuffer=__nested_webpack_require_541866__(2762);var createVAO=__nested_webpack_require_541866__(8116);var createTexture=__nested_webpack_require_541866__(7766);var pool=__nested_webpack_require_541866__(1888);var colormap=__nested_webpack_require_541866__(6729);var ops=__nested_webpack_require_541866__(5298);var pack=__nested_webpack_require_541866__(9994);var ndarray=__nested_webpack_require_541866__(9618);var surfaceNets=__nested_webpack_require_541866__(3711);var multiply=__nested_webpack_require_541866__(6760);var invert=__nested_webpack_require_541866__(7608);var bsearch=__nested_webpack_require_541866__(2478);var gradient=__nested_webpack_require_541866__(6199);var shaders=__nested_webpack_require_541866__(990);var createShader=shaders.createShader;var createContourShader=shaders.createContourShader;var createPickShader=shaders.createPickShader;var createPickContourShader=shaders.createPickContourShader;var SURFACE_VERTEX_SIZE=4*(4+3+3);var IDENTITY=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];var QUAD=[[0,0],[0,1],[1,0],[1,1],[1,0],[0,1]];var PERMUTATIONS=[[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0]];(function(){for(var i=0;i<3;++i){var p=PERMUTATIONS[i];var u=(i+1)%3;var v=(i+2)%3;p[u+0]=1;p[v+3]=1;p[i+6]=1;}})();function SurfacePickResult(position,index,uv,level,dataCoordinate){this.position=position;this.index=index;this.uv=uv;this.level=level;this.dataCoordinate=dataCoordinate;}var N_COLORS=256;function SurfacePlot(gl,shape,bounds,shader,pickShader,coordinates,vao,colorMap,contourShader,contourPickShader,contourBuffer,contourVAO,dynamicBuffer,dynamicVAO,objectOffset){this.gl=gl;this.shape=shape;this.bounds=bounds;this.objectOffset=objectOffset;this.intensityBounds=[];this._shader=shader;this._pickShader=pickShader;this._coordinateBuffer=coordinates;this._vao=vao;this._colorMap=colorMap;this._contourShader=contourShader;this._contourPickShader=contourPickShader;this._contourBuffer=contourBuffer;this._contourVAO=contourVAO;this._contourOffsets=[[],[],[]];this._contourCounts=[[],[],[]];this._vertexCount=0;this._pickResult=new SurfacePickResult([0,0,0],[0,0],[0,0],[0,0,0],[0,0,0]);this._dynamicBuffer=dynamicBuffer;this._dynamicVAO=dynamicVAO;this._dynamicOffsets=[0,0,0];this._dynamicCounts=[0,0,0];this.contourWidth=[1,1,1];this.contourLevels=[[1],[1],[1]];this.contourTint=[0,0,0];this.contourColor=[[0.5,0.5,0.5,1],[0.5,0.5,0.5,1],[0.5,0.5,0.5,1]];this.showContour=true;this.showSurface=true;this.enableHighlight=[true,true,true];this.highlightColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.highlightTint=[1,1,1];this.highlightLevel=[-1,-1,-1];// Dynamic contour options
this.enableDynamic=[true,true,true];this.dynamicLevel=[NaN,NaN,NaN];this.dynamicColor=[[0,0,0,1],[0,0,0,1],[0,0,0,1]];this.dynamicTint=[1,1,1];this.dynamicWidth=[1,1,1];this.axesBounds=[[Infinity,Infinity,Infinity],[-Infinity,-Infinity,-Infinity]];this.surfaceProject=[false,false,false];this.contourProject=[[false,false,false],[false,false,false],[false,false,false]];this.colorBounds=[false,false];// Store xyz fields, need this for picking
this._field=[ndarray(pool.mallocFloat(1024),[0,0]),ndarray(pool.mallocFloat(1024),[0,0]),ndarray(pool.mallocFloat(1024),[0,0])];this.pickId=1;this.clipBounds=[[-Infinity,-Infinity,-Infinity],[Infinity,Infinity,Infinity]];this.snapToData=false;this.pixelRatio=1;this.opacity=1.0;this.lightPosition=[10,10000,0];this.ambientLight=0.8;this.diffuseLight=0.8;this.specularLight=2.0;this.roughness=0.5;this.fresnel=1.5;this.vertexColor=0;this.dirty=true;}var proto=SurfacePlot.prototype;proto.genColormap=function(name,opacityscale){var hasAlpha=false;var x=pack([colormap({colormap:name,nshades:N_COLORS,format:'rgba'}).map(function(c,i){var a=opacityscale?getOpacityFromScale(i/255.0,opacityscale):c[3];if(a<1)hasAlpha=true;return[c[0],c[1],c[2],255*a];})]);ops.divseq(x,255.0);this.hasAlphaScale=hasAlpha;return x;};proto.isTransparent=function(){return this.opacity<1||this.hasAlphaScale;};proto.isOpaque=function(){return!this.isTransparent();};proto.pickSlots=1;proto.setPickBase=function(id){this.pickId=id;};function getOpacityFromScale(ratio,opacityscale){// copied form gl-mesh3d
if(!opacityscale)return 1;if(!opacityscale.length)return 1;for(var i=0;iratio&&i>0){var d=(opacityscale[i][0]-ratio)/(opacityscale[i][0]-opacityscale[i-1][0]);return opacityscale[i][1]*(1-d)+d*opacityscale[i-1][1];}}return 1;}var ZERO_VEC=[0,0,0];var PROJECT_DATA={showSurface:false,showContour:false,projections:[IDENTITY.slice(),IDENTITY.slice(),IDENTITY.slice()],clipBounds:[[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]],[[0,0,0],[0,0,0]]]};function computeProjectionData(camera,obj){var i,j,k;// Compute cube properties
var cubeAxis=obj.axes&&obj.axes.lastCubeProps.axis||ZERO_VEC;var showSurface=obj.showSurface;var showContour=obj.showContour;for(i=0;i<3;++i){showSurface=showSurface||obj.surfaceProject[i];for(j=0;j<3;++j){showContour=showContour||obj.contourProject[i][j];}}for(i=0;i<3;++i){// Construct projection onto axis
var axisSquish=PROJECT_DATA.projections[i];for(j=0;j<16;++j){axisSquish[j]=0;}for(j=0;j<4;++j){axisSquish[5*j]=1;}axisSquish[5*i]=0;axisSquish[12+i]=obj.axesBounds[+(cubeAxis[i]>0)][i];multiply(axisSquish,camera.model,axisSquish);var nclipBounds=PROJECT_DATA.clipBounds[i];for(k=0;k<2;++k){for(j=0;j<3;++j){nclipBounds[k][j]=camera.clipBounds[k][j];}}nclipBounds[0][i]=-1e8;nclipBounds[1][i]=1e8;}PROJECT_DATA.showSurface=showSurface;PROJECT_DATA.showContour=showContour;return PROJECT_DATA;}var UNIFORMS={model:IDENTITY,view:IDENTITY,projection:IDENTITY,inverseModel:IDENTITY.slice(),lowerBound:[0,0,0],upperBound:[0,0,0],colorMap:0,clipBounds:[[0,0,0],[0,0,0]],height:0.0,contourTint:0,contourColor:[0,0,0,1],permutation:[1,0,0,0,1,0,0,0,1],zOffset:-1e-4,objectOffset:[0,0,0],kambient:1,kdiffuse:1,kspecular:1,lightPosition:[1000,1000,1000],eyePosition:[0,0,0],roughness:1,fresnel:1,opacity:1,vertexColor:0};var MATRIX_INVERSE=IDENTITY.slice();var DEFAULT_PERM=[1,0,0,0,1,0,0,0,1];function drawCore(params,transparent){params=params||{};var gl=this.gl;gl.disable(gl.CULL_FACE);this._colorMap.bind(0);var uniforms=UNIFORMS;uniforms.model=params.model||IDENTITY;uniforms.view=params.view||IDENTITY;uniforms.projection=params.projection||IDENTITY;uniforms.lowerBound=[this.bounds[0][0],this.bounds[0][1],this.colorBounds[0]||this.bounds[0][2]];uniforms.upperBound=[this.bounds[1][0],this.bounds[1][1],this.colorBounds[1]||this.bounds[1][2]];uniforms.objectOffset=this.objectOffset;uniforms.contourColor=this.contourColor[0];uniforms.inverseModel=invert(uniforms.inverseModel,uniforms.model);for(var i=0;i<2;++i){var clipClamped=uniforms.clipBounds[i];for(var j=0;j<3;++j){clipClamped[j]=Math.min(Math.max(this.clipBounds[i][j],-1e8),1e8);}}uniforms.kambient=this.ambientLight;uniforms.kdiffuse=this.diffuseLight;uniforms.kspecular=this.specularLight;uniforms.roughness=this.roughness;uniforms.fresnel=this.fresnel;uniforms.opacity=this.opacity;uniforms.height=0.0;uniforms.permutation=DEFAULT_PERM;uniforms.vertexColor=this.vertexColor;// Compute camera matrix inverse
var invCameraMatrix=MATRIX_INVERSE;multiply(invCameraMatrix,uniforms.view,uniforms.model);multiply(invCameraMatrix,uniforms.projection,invCameraMatrix);invert(invCameraMatrix,invCameraMatrix);for(i=0;i<3;++i){uniforms.eyePosition[i]=invCameraMatrix[12+i]/invCameraMatrix[15];}var w=invCameraMatrix[15];for(i=0;i<3;++i){w+=this.lightPosition[i]*invCameraMatrix[4*i+3];}for(i=0;i<3;++i){var s=invCameraMatrix[12+i];for(j=0;j<3;++j){s+=invCameraMatrix[4*j+i]*this.lightPosition[j];}uniforms.lightPosition[i]=s/w;}var projectData=computeProjectionData(uniforms,this);if(projectData.showSurface){// Set up uniforms
this._shader.bind();this._shader.uniforms=uniforms;// Draw it
this._vao.bind();if(this.showSurface&&this._vertexCount){this._vao.draw(gl.TRIANGLES,this._vertexCount);}// Draw projections of surface
for(i=0;i<3;++i){if(!this.surfaceProject[i]||!this.vertexCount){continue;}this._shader.uniforms.model=projectData.projections[i];this._shader.uniforms.clipBounds=projectData.clipBounds[i];this._vao.draw(gl.TRIANGLES,this._vertexCount);}this._vao.unbind();}if(projectData.showContour){var shader=this._contourShader;// Don't apply lighting to contours
uniforms.kambient=1.0;uniforms.kdiffuse=0.0;uniforms.kspecular=0.0;uniforms.opacity=1.0;shader.bind();shader.uniforms=uniforms;// Draw contour lines
var vao=this._contourVAO;vao.bind();// Draw contour levels
for(i=0;i<3;++i){shader.uniforms.permutation=PERMUTATIONS[i];gl.lineWidth(this.contourWidth[i]*this.pixelRatio);for(j=0;j>4)/16.0)/255.0;var ix=Math.floor(x);var fx=x-ix;var y=shape[1]*(selection.value[1]+(selection.value[2]&15)/16.0)/255.0;var iy=Math.floor(y);var fy=y-iy;ix+=1;iy+=1;// Compute xyz coordinate
var pos=result.position;pos[0]=pos[1]=pos[2]=0;for(var dx=0;dx<2;++dx){var s=dx?fx:1.0-fx;for(var dy=0;dy<2;++dy){var t=dy?fy:1.0-fy;var r=ix+dx;var c=iy+dy;var w=s*t;for(var i=0;i<3;++i){pos[i]+=this._field[i].get(r,c)*w;}}}// Find closest level
var levelIndex=this._pickResult.level;for(var j=0;j<3;++j){levelIndex[j]=bsearch.le(this.contourLevels[j],pos[j]);if(levelIndex[j]<0){if(this.contourLevels[j].length>0){levelIndex[j]=0;}}else if(levelIndex[j]Math.abs(b-pos[j])){levelIndex[j]+=1;}}}result.index[0]=fx<0.5?ix:ix+1;result.index[1]=fy<0.5?iy:iy+1;result.uv[0]=x/shape[0];result.uv[1]=y/shape[1];for(i=0;i<3;++i){result.dataCoordinate[i]=this._field[i].get(result.index[0],result.index[1]);}return result;};proto.padField=function(dstField,srcField){var srcShape=srcField.shape.slice();var dstShape=dstField.shape.slice();// Center
ops.assign(dstField.lo(1,1).hi(srcShape[0],srcShape[1]),srcField);// Edges
ops.assign(dstField.lo(1).hi(srcShape[0],1),srcField.hi(srcShape[0],1));ops.assign(dstField.lo(1,dstShape[1]-1).hi(srcShape[0],1),srcField.lo(0,srcShape[1]-1).hi(srcShape[0],1));ops.assign(dstField.lo(0,1).hi(1,srcShape[1]),srcField.hi(1));ops.assign(dstField.lo(dstShape[0]-1,1).hi(1,srcShape[1]),srcField.lo(srcShape[0]-1));// Corners
dstField.set(0,0,srcField.get(0,0));dstField.set(0,dstShape[1]-1,srcField.get(0,srcShape[1]-1));dstField.set(dstShape[0]-1,0,srcField.get(srcShape[0]-1,0));dstField.set(dstShape[0]-1,dstShape[1]-1,srcField.get(srcShape[0]-1,srcShape[1]-1));};function handleArray(param,ctor){if(Array.isArray(param)){return[ctor(param[0]),ctor(param[1]),ctor(param[2])];}return[ctor(param),ctor(param),ctor(param)];}function toColor(x){if(Array.isArray(x)){if(x.length===3){return[x[0],x[1],x[2],1];}return[x[0],x[1],x[2],x[3]];}return[0,0,0,1];}function handleColor(param){if(Array.isArray(param)){if(Array.isArray(param)){return[toColor(param[0]),toColor(param[1]),toColor(param[2])];}else{var c=toColor(param);return[c.slice(),c.slice(),c.slice()];}}}proto.update=function(params){params=params||{};this.objectOffset=params.objectOffset||this.objectOffset;this.dirty=true;if('contourWidth'in params){this.contourWidth=handleArray(params.contourWidth,Number);}if('showContour'in params){this.showContour=handleArray(params.showContour,Boolean);}if('showSurface'in params){this.showSurface=!!params.showSurface;}if('contourTint'in params){this.contourTint=handleArray(params.contourTint,Boolean);}if('contourColor'in params){this.contourColor=handleColor(params.contourColor);}if('contourProject'in params){this.contourProject=handleArray(params.contourProject,function(x){return handleArray(x,Boolean);});}if('surfaceProject'in params){this.surfaceProject=params.surfaceProject;}if('dynamicColor'in params){this.dynamicColor=handleColor(params.dynamicColor);}if('dynamicTint'in params){this.dynamicTint=handleArray(params.dynamicTint,Number);}if('dynamicWidth'in params){this.dynamicWidth=handleArray(params.dynamicWidth,Number);}if('opacity'in params){this.opacity=params.opacity;}if('opacityscale'in params){this.opacityscale=params.opacityscale;}if('colorBounds'in params){this.colorBounds=params.colorBounds;}if('vertexColor'in params){this.vertexColor=params.vertexColor?1:0;}if('colormap'in params){this._colorMap.setPixels(this.genColormap(params.colormap,this.opacityscale));}var field=params.field||params.coords&¶ms.coords[2]||null;var levelsChanged=false;if(!field){if(this._field[2].shape[0]||this._field[2].shape[2]){field=this._field[2].lo(1,1).hi(this._field[2].shape[0]-2,this._field[2].shape[1]-2);}else{field=this._field[2].hi(0,0);}}// Update field
if('field'in params||'coords'in params){var fsize=(field.shape[0]+2)*(field.shape[1]+2);// Resize if necessary
if(fsize>this._field[2].data.length){pool.freeFloat(this._field[2].data);this._field[2].data=pool.mallocFloat(bits.nextPow2(fsize));}// Pad field
this._field[2]=ndarray(this._field[2].data,[field.shape[0]+2,field.shape[1]+2]);this.padField(this._field[2],field);// Save shape of field
this.shape=field.shape.slice();var shape=this.shape;// Resize coordinate fields if necessary
for(var i=0;i<2;++i){if(this._field[2].size>this._field[i].data.length){pool.freeFloat(this._field[i].data);this._field[i].data=pool.mallocFloat(this._field[2].size);}this._field[i]=ndarray(this._field[i].data,[shape[0]+2,shape[1]+2]);}// Generate x/y coordinates
if(params.coords){var coords=params.coords;if(!Array.isArray(coords)||coords.length!==3){throw new Error('gl-surface: invalid coordinates for x/y');}for(i=0;i<2;++i){var coord=coords[i];for(j=0;j<2;++j){if(coord.shape[j]!==shape[j]){throw new Error('gl-surface: coords have incorrect shape');}}this.padField(this._field[i],coord);}}else if(params.ticks){var ticks=params.ticks;if(!Array.isArray(ticks)||ticks.length!==2){throw new Error('gl-surface: invalid ticks');}for(i=0;i<2;++i){var tick=ticks[i];if(Array.isArray(tick)||tick.length){tick=ndarray(tick);}if(tick.shape[0]!==shape[i]){throw new Error('gl-surface: invalid tick length');}// Make a copy view of the tick array
var tick2=ndarray(tick.data,shape);tick2.stride[i]=tick.stride[0];tick2.stride[i^1]=0;// Fill in field array
this.padField(this._field[i],tick2);}}else{for(i=0;i<2;++i){var offset=[0,0];offset[i]=1;this._field[i]=ndarray(this._field[i].data,[shape[0]+2,shape[1]+2],offset,0);}this._field[0].set(0,0,0);for(var j=0;j0){// If we already added first edge, pop off verts
for(var l=0;l<5;++l){contourVerts.pop();}vertexCount-=1;}continue edge_loop;}}}levelCounts.push(vertexCount);}// Store results
this._contourOffsets[dim]=levelOffsets;this._contourCounts[dim]=levelCounts;}var floatBuffer=pool.mallocFloat(contourVerts.length);for(i=0;imaxSize||h<0||h>maxSize){throw new Error('gl-texture2d: Invalid texture size');}tex._shape=[w,h];tex.bind();gl.texImage2D(gl.TEXTURE_2D,0,tex.format,w,h,0,tex.format,tex.type,null);tex._mipLevels=[0];return tex;}function Texture2D(gl,handle,width,height,format,type){this.gl=gl;this.handle=handle;this.format=format;this.type=type;this._shape=[width,height];this._mipLevels=[0];this._magFilter=gl.NEAREST;this._minFilter=gl.NEAREST;this._wrapS=gl.CLAMP_TO_EDGE;this._wrapT=gl.CLAMP_TO_EDGE;this._anisoSamples=1;var parent=this;var wrapVector=[this._wrapS,this._wrapT];Object.defineProperties(wrapVector,[{get:function(){return parent._wrapS;},set:function(v){return parent.wrapS=v;}},{get:function(){return parent._wrapT;},set:function(v){return parent.wrapT=v;}}]);this._wrapVector=wrapVector;var shapeVector=[this._shape[0],this._shape[1]];Object.defineProperties(shapeVector,[{get:function(){return parent._shape[0];},set:function(v){return parent.width=v;}},{get:function(){return parent._shape[1];},set:function(v){return parent.height=v;}}]);this._shapeVector=shapeVector;}var proto=Texture2D.prototype;Object.defineProperties(proto,{minFilter:{get:function(){return this._minFilter;},set:function(v){this.bind();var gl=this.gl;if(this.type===gl.FLOAT&&linearTypes.indexOf(v)>=0){if(!gl.getExtension('OES_texture_float_linear')){v=gl.NEAREST;}}if(filterTypes.indexOf(v)<0){throw new Error('gl-texture2d: Unknown filter mode '+v);}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,v);return this._minFilter=v;}},magFilter:{get:function(){return this._magFilter;},set:function(v){this.bind();var gl=this.gl;if(this.type===gl.FLOAT&&linearTypes.indexOf(v)>=0){if(!gl.getExtension('OES_texture_float_linear')){v=gl.NEAREST;}}if(filterTypes.indexOf(v)<0){throw new Error('gl-texture2d: Unknown filter mode '+v);}gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,v);return this._magFilter=v;}},mipSamples:{get:function(){return this._anisoSamples;},set:function(i){var psamples=this._anisoSamples;this._anisoSamples=Math.max(i,1)|0;if(psamples!==this._anisoSamples){var ext=this.gl.getExtension('EXT_texture_filter_anisotropic');if(ext){this.gl.texParameterf(this.gl.TEXTURE_2D,ext.TEXTURE_MAX_ANISOTROPY_EXT,this._anisoSamples);}}return this._anisoSamples;}},wrapS:{get:function(){return this._wrapS;},set:function(v){this.bind();if(wrapTypes.indexOf(v)<0){throw new Error('gl-texture2d: Unknown wrap mode '+v);}this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,v);return this._wrapS=v;}},wrapT:{get:function(){return this._wrapT;},set:function(v){this.bind();if(wrapTypes.indexOf(v)<0){throw new Error('gl-texture2d: Unknown wrap mode '+v);}this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,v);return this._wrapT=v;}},wrap:{get:function(){return this._wrapVector;},set:function(v){if(!Array.isArray(v)){v=[v,v];}if(v.length!==2){throw new Error('gl-texture2d: Must specify wrap mode for rows and columns');}for(var i=0;i<2;++i){if(wrapTypes.indexOf(v[i])<0){throw new Error('gl-texture2d: Unknown wrap mode '+v);}}this._wrapS=v[0];this._wrapT=v[1];var gl=this.gl;this.bind();gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,this._wrapS);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,this._wrapT);return v;}},shape:{get:function(){return this._shapeVector;},set:function(x){if(!Array.isArray(x)){x=[x|0,x|0];}else{if(x.length!==2){throw new Error('gl-texture2d: Invalid texture shape');}}reshapeTexture(this,x[0]|0,x[1]|0);return[x[0]|0,x[1]|0];}},width:{get:function(){return this._shape[0];},set:function(w){w=w|0;reshapeTexture(this,w,this._shape[1]);return w;}},height:{get:function(){return this._shape[1];},set:function(h){h=h|0;reshapeTexture(this,this._shape[0],h);return h;}}});proto.bind=function(unit){var gl=this.gl;if(unit!==undefined){gl.activeTexture(gl.TEXTURE0+(unit|0));}gl.bindTexture(gl.TEXTURE_2D,this.handle);if(unit!==undefined){return unit|0;}return gl.getParameter(gl.ACTIVE_TEXTURE)-gl.TEXTURE0;};proto.dispose=function(){this.gl.deleteTexture(this.handle);};proto.generateMipmap=function(){this.bind();this.gl.generateMipmap(this.gl.TEXTURE_2D);//Update mip levels
var l=Math.min(this._shape[0],this._shape[1]);for(var i=0;l>0;++i,l>>>=1){if(this._mipLevels.indexOf(i)<0){this._mipLevels.push(i);}}};proto.setPixels=function(data,x_off,y_off,mip_level){var gl=this.gl;this.bind();if(Array.isArray(x_off)){mip_level=y_off;y_off=x_off[1]|0;x_off=x_off[0]|0;}else{x_off=x_off||0;y_off=y_off||0;}mip_level=mip_level||0;var directData=acceptTextureDOM(data)?data:data.raw;if(directData){var needsMip=this._mipLevels.indexOf(mip_level)<0;if(needsMip){gl.texImage2D(gl.TEXTURE_2D,0,this.format,this.format,this.type,directData);this._mipLevels.push(mip_level);}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,this.format,this.type,directData);}}else if(data.shape&&data.stride&&data.data){if(data.shape.length<2||x_off+data.shape[1]>this._shape[1]>>>mip_level||y_off+data.shape[0]>this._shape[0]>>>mip_level||x_off<0||y_off<0){throw new Error('gl-texture2d: Texture dimensions are out of bounds');}texSubImageArray(gl,x_off,y_off,mip_level,this.format,this.type,this._mipLevels,data);}else{throw new Error('gl-texture2d: Unsupported data type');}};function isPacked(shape,stride){if(shape.length===3){return stride[2]===1&&stride[1]===shape[0]*shape[2]&&stride[0]===shape[2];}return stride[0]===1&&stride[1]===shape[0];}function texSubImageArray(gl,x_off,y_off,mip_level,cformat,ctype,mipLevels,array){var dtype=array.dtype;var shape=array.shape.slice();if(shape.length<2||shape.length>3){throw new Error('gl-texture2d: Invalid ndarray, must be 2d or 3d');}var type=0,format=0;var packed=isPacked(shape,array.stride.slice());if(dtype==='float32'){type=gl.FLOAT;}else if(dtype==='float64'){type=gl.FLOAT;packed=false;dtype='float32';}else if(dtype==='uint8'){type=gl.UNSIGNED_BYTE;}else{type=gl.UNSIGNED_BYTE;packed=false;dtype='uint8';}var channels=1;if(shape.length===2){format=gl.LUMINANCE;shape=[shape[0],shape[1],1];array=ndarray(array.data,shape,[array.stride[0],array.stride[1],1],array.offset);}else if(shape.length===3){if(shape[2]===1){format=gl.ALPHA;}else if(shape[2]===2){format=gl.LUMINANCE_ALPHA;}else if(shape[2]===3){format=gl.RGB;}else if(shape[2]===4){format=gl.RGBA;}else{throw new Error('gl-texture2d: Invalid shape for pixel coords');}channels=shape[2];}else{throw new Error('gl-texture2d: Invalid shape for texture');}//For 1-channel textures allow conversion between formats
if((format===gl.LUMINANCE||format===gl.ALPHA)&&(cformat===gl.LUMINANCE||cformat===gl.ALPHA)){format=cformat;}if(format!==cformat){throw new Error('gl-texture2d: Incompatible texture format for setPixels');}var size=array.size;var needsMip=mipLevels.indexOf(mip_level)<0;if(needsMip){mipLevels.push(mip_level);}if(type===ctype&&packed){//Array data types are compatible, can directly copy into texture
if(array.offset===0&&array.data.length===size){if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,array.data);}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,array.data);}}else{if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,array.data.subarray(array.offset,array.offset+size));}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,array.data.subarray(array.offset,array.offset+size));}}}else{//Need to do type conversion to pack data into buffer
var pack_buffer;if(ctype===gl.FLOAT){pack_buffer=pool.mallocFloat32(size);}else{pack_buffer=pool.mallocUint8(size);}var pack_view=ndarray(pack_buffer,shape,[shape[2],shape[2]*shape[0],1]);if(type===gl.FLOAT&&ctype===gl.UNSIGNED_BYTE){convertFloatToUint8(pack_view,array);}else{ops.assign(pack_view,array);}if(needsMip){gl.texImage2D(gl.TEXTURE_2D,mip_level,cformat,shape[0],shape[1],0,cformat,ctype,pack_buffer.subarray(0,size));}else{gl.texSubImage2D(gl.TEXTURE_2D,mip_level,x_off,y_off,shape[0],shape[1],cformat,ctype,pack_buffer.subarray(0,size));}if(ctype===gl.FLOAT){pool.freeFloat32(pack_buffer);}else{pool.freeUint8(pack_buffer);}}}function initTexture(gl){var tex=gl.createTexture();gl.bindTexture(gl.TEXTURE_2D,tex);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MIN_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_MAG_FILTER,gl.NEAREST);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_S,gl.CLAMP_TO_EDGE);gl.texParameteri(gl.TEXTURE_2D,gl.TEXTURE_WRAP_T,gl.CLAMP_TO_EDGE);return tex;}function createTextureShape(gl,width,height,format,type){var maxTextureSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(width<0||width>maxTextureSize||height<0||height>maxTextureSize){throw new Error('gl-texture2d: Invalid texture shape');}if(type===gl.FLOAT&&!gl.getExtension('OES_texture_float')){throw new Error('gl-texture2d: Floating point textures not supported on this platform');}var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,width,height,0,format,type,null);return new Texture2D(gl,tex,width,height,format,type);}function createTextureDOM(gl,directData,width,height,format,type){var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,format,type,directData);return new Texture2D(gl,tex,width,height,format,type);}//Creates a texture from an ndarray
function createTextureArray(gl,array){var dtype=array.dtype;var shape=array.shape.slice();var maxSize=gl.getParameter(gl.MAX_TEXTURE_SIZE);if(shape[0]<0||shape[0]>maxSize||shape[1]<0||shape[1]>maxSize){throw new Error('gl-texture2d: Invalid texture size');}var packed=isPacked(shape,array.stride.slice());var type=0;if(dtype==='float32'){type=gl.FLOAT;}else if(dtype==='float64'){type=gl.FLOAT;packed=false;dtype='float32';}else if(dtype==='uint8'){type=gl.UNSIGNED_BYTE;}else{type=gl.UNSIGNED_BYTE;packed=false;dtype='uint8';}var format=0;if(shape.length===2){format=gl.LUMINANCE;shape=[shape[0],shape[1],1];array=ndarray(array.data,shape,[array.stride[0],array.stride[1],1],array.offset);}else if(shape.length===3){if(shape[2]===1){format=gl.ALPHA;}else if(shape[2]===2){format=gl.LUMINANCE_ALPHA;}else if(shape[2]===3){format=gl.RGB;}else if(shape[2]===4){format=gl.RGBA;}else{throw new Error('gl-texture2d: Invalid shape for pixel coords');}}else{throw new Error('gl-texture2d: Invalid shape for texture');}if(type===gl.FLOAT&&!gl.getExtension('OES_texture_float')){type=gl.UNSIGNED_BYTE;packed=false;}var buffer,buf_store;var size=array.size;if(!packed){var stride=[shape[2],shape[2]*shape[0],1];buf_store=pool.malloc(size,dtype);var buf_array=ndarray(buf_store,shape,stride,0);if((dtype==='float32'||dtype==='float64')&&type===gl.UNSIGNED_BYTE){convertFloatToUint8(buf_array,array);}else{ops.assign(buf_array,array);}buffer=buf_store.subarray(0,size);}else if(array.offset===0&&array.data.length===size){buffer=array.data;}else{buffer=array.data.subarray(array.offset,array.offset+size);}var tex=initTexture(gl);gl.texImage2D(gl.TEXTURE_2D,0,format,shape[0],shape[1],0,format,type,buffer);if(!packed){pool.free(buf_store);}return new Texture2D(gl,tex,shape[0],shape[1],format,type);}function createTexture2D(gl){if(arguments.length<=1){throw new Error('gl-texture2d: Missing arguments for texture2d constructor');}if(!linearTypes){lazyInitLinearTypes(gl);}if(typeof arguments[1]==='number'){return createTextureShape(gl,arguments[1],arguments[2],arguments[3]||gl.RGBA,arguments[4]||gl.UNSIGNED_BYTE);}if(Array.isArray(arguments[1])){return createTextureShape(gl,arguments[1][0]|0,arguments[1][1]|0,arguments[2]||gl.RGBA,arguments[3]||gl.UNSIGNED_BYTE);}if(typeof arguments[1]==='object'){var obj=arguments[1];var directData=acceptTextureDOM(obj)?obj:obj.raw;if(directData){return createTextureDOM(gl,directData,obj.width|0,obj.height|0,arguments[2]||gl.RGBA,arguments[3]||gl.UNSIGNED_BYTE);}else if(obj.shape&&obj.data&&obj.stride){return createTextureArray(gl,obj);}}throw new Error('gl-texture2d: Invalid arguments for texture2d constructor');}/***/},/***/1433:/***/function(module){"use strict";function doBind(gl,elements,attributes){if(elements){elements.bind();}else{gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER,null);}var nattribs=gl.getParameter(gl.MAX_VERTEX_ATTRIBS)|0;if(attributes){if(attributes.length>nattribs){throw new Error("gl-vao: Too many vertex attributes");}for(var i=0;i1.0){return 0;}else{return Math.acos(cosine);}}/***/},/***/9226:/***/function(module){module.exports=ceil;/**
* Math.ceil the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to ceil
* @returns {vec3} out
*/function ceil(out,a){out[0]=Math.ceil(a[0]);out[1]=Math.ceil(a[1]);out[2]=Math.ceil(a[2]);return out;}/***/},/***/3126:/***/function(module){module.exports=clone;/**
* Creates a new vec3 initialized with values from an existing vector
*
* @param {vec3} a vector to clone
* @returns {vec3} a new 3D vector
*/function clone(a){var out=new Float32Array(3);out[0]=a[0];out[1]=a[1];out[2]=a[2];return out;}/***/},/***/3990:/***/function(module){module.exports=copy;/**
* Copy the values from one vec3 to another
*
* @param {vec3} out the receiving vector
* @param {vec3} a the source vector
* @returns {vec3} out
*/function copy(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];return out;}/***/},/***/1091:/***/function(module){module.exports=create;/**
* Creates a new, empty vec3
*
* @returns {vec3} a new 3D vector
*/function create(){var out=new Float32Array(3);out[0]=0;out[1]=0;out[2]=0;return out;}/***/},/***/5911:/***/function(module){module.exports=cross;/**
* Computes the cross product of two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/function cross(out,a,b){var ax=a[0],ay=a[1],az=a[2],bx=b[0],by=b[1],bz=b[2];out[0]=ay*bz-az*by;out[1]=az*bx-ax*bz;out[2]=ax*by-ay*bx;return out;}/***/},/***/5455:/***/function(module,__unused_webpack_exports,__nested_webpack_require_590018__){module.exports=__nested_webpack_require_590018__(7056);/***/},/***/7056:/***/function(module){module.exports=distance;/**
* Calculates the euclidian distance between two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} distance between a and b
*/function distance(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2];return Math.sqrt(x*x+y*y+z*z);}/***/},/***/4008:/***/function(module,__unused_webpack_exports,__nested_webpack_require_590487__){module.exports=__nested_webpack_require_590487__(6690);/***/},/***/6690:/***/function(module){module.exports=divide;/**
* Divides two vec3's
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/function divide(out,a,b){out[0]=a[0]/b[0];out[1]=a[1]/b[1];out[2]=a[2]/b[2];return out;}/***/},/***/244:/***/function(module){module.exports=dot;/**
* Calculates the dot product of two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} dot product of a and b
*/function dot(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2];}/***/},/***/2613:/***/function(module){module.exports=0.000001;/***/},/***/9922:/***/function(module,__unused_webpack_exports,__nested_webpack_require_591282__){module.exports=equals;var EPSILON=__nested_webpack_require_591282__(2613);/**
* Returns whether or not the vectors have approximately the same elements in the same position.
*
* @param {vec3} a The first vector.
* @param {vec3} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/function equals(a,b){var a0=a[0];var a1=a[1];var a2=a[2];var b0=b[0];var b1=b[1];var b2=b[2];return Math.abs(a0-b0)<=EPSILON*Math.max(1.0,Math.abs(a0),Math.abs(b0))&&Math.abs(a1-b1)<=EPSILON*Math.max(1.0,Math.abs(a1),Math.abs(b1))&&Math.abs(a2-b2)<=EPSILON*Math.max(1.0,Math.abs(a2),Math.abs(b2));}/***/},/***/9265:/***/function(module){module.exports=exactEquals;/**
* Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
*
* @param {vec3} a The first vector.
* @param {vec3} b The second vector.
* @returns {Boolean} True if the vectors are equal, false otherwise.
*/function exactEquals(a,b){return a[0]===b[0]&&a[1]===b[1]&&a[2]===b[2];}/***/},/***/2681:/***/function(module){module.exports=floor;/**
* Math.floor the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to floor
* @returns {vec3} out
*/function floor(out,a){out[0]=Math.floor(a[0]);out[1]=Math.floor(a[1]);out[2]=Math.floor(a[2]);return out;}/***/},/***/5137:/***/function(module,__unused_webpack_exports,__nested_webpack_require_592699__){module.exports=forEach;var vec=__nested_webpack_require_592699__(1091)();/**
* Perform some operation over an array of vec3s.
*
* @param {Array} a the array of vectors to iterate over
* @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
* @param {Number} offset Number of elements to skip at the beginning of the array
* @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
* @param {Function} fn Function to call for each vector in the array
* @param {Object} [arg] additional argument to pass to fn
* @returns {Array} a
* @function
*/function forEach(a,stride,offset,count,fn,arg){var i,l;if(!stride){stride=3;}if(!offset){offset=0;}if(count){l=Math.min(count*stride+offset,a.length);}else{l=a.length;}for(i=offset;i0){//TODO: evaluate use of glm_invsqrt here?
len=1/Math.sqrt(len);out[0]=a[0]*len;out[1]=a[1]*len;out[2]=a[2]*len;}return out;}/***/},/***/7636:/***/function(module){module.exports=random;/**
* Generates a random vector with the given scale
*
* @param {vec3} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec3} out
*/function random(out,scale){scale=scale||1.0;var r=Math.random()*2.0*Math.PI;var z=Math.random()*2.0-1.0;var zScale=Math.sqrt(1.0-z*z)*scale;out[0]=Math.cos(r)*zScale;out[1]=Math.sin(r)*zScale;out[2]=z*scale;return out;}/***/},/***/6894:/***/function(module){module.exports=rotateX;/**
* Rotate a 3D vector around the x-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/function rotateX(out,a,b,c){var by=b[1];var bz=b[2];// Translate point to the origin
var py=a[1]-by;var pz=a[2]-bz;var sc=Math.sin(c);var cc=Math.cos(c);// perform rotation and translate to correct position
out[0]=a[0];out[1]=by+py*cc-pz*sc;out[2]=bz+py*sc+pz*cc;return out;}/***/},/***/109:/***/function(module){module.exports=rotateY;/**
* Rotate a 3D vector around the y-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/function rotateY(out,a,b,c){var bx=b[0];var bz=b[2];// translate point to the origin
var px=a[0]-bx;var pz=a[2]-bz;var sc=Math.sin(c);var cc=Math.cos(c);// perform rotation and translate to correct position
out[0]=bx+pz*sc+px*cc;out[1]=a[1];out[2]=bz+pz*cc-px*sc;return out;}/***/},/***/8692:/***/function(module){module.exports=rotateZ;/**
* Rotate a 3D vector around the z-axis
* @param {vec3} out The receiving vec3
* @param {vec3} a The vec3 point to rotate
* @param {vec3} b The origin of the rotation
* @param {Number} c The angle of rotation
* @returns {vec3} out
*/function rotateZ(out,a,b,c){var bx=b[0];var by=b[1];//Translate point to the origin
var px=a[0]-bx;var py=a[1]-by;var sc=Math.sin(c);var cc=Math.cos(c);// perform rotation and translate to correct position
out[0]=bx+px*cc-py*sc;out[1]=by+px*sc+py*cc;out[2]=a[2];return out;}/***/},/***/2447:/***/function(module){module.exports=round;/**
* Math.round the components of a vec3
*
* @param {vec3} out the receiving vector
* @param {vec3} a vector to round
* @returns {vec3} out
*/function round(out,a){out[0]=Math.round(a[0]);out[1]=Math.round(a[1]);out[2]=Math.round(a[2]);return out;}/***/},/***/6621:/***/function(module){module.exports=scale;/**
* Scales a vec3 by a scalar number
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec3} out
*/function scale(out,a,b){out[0]=a[0]*b;out[1]=a[1]*b;out[2]=a[2]*b;return out;}/***/},/***/8489:/***/function(module){module.exports=scaleAndAdd;/**
* Adds two vec3's after scaling the second operand by a scalar value
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec3} out
*/function scaleAndAdd(out,a,b,scale){out[0]=a[0]+b[0]*scale;out[1]=a[1]+b[1]*scale;out[2]=a[2]+b[2]*scale;return out;}/***/},/***/1463:/***/function(module){module.exports=set;/**
* Set the components of a vec3 to the given values
*
* @param {vec3} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @returns {vec3} out
*/function set(out,x,y,z){out[0]=x;out[1]=y;out[2]=z;return out;}/***/},/***/6141:/***/function(module,__unused_webpack_exports,__nested_webpack_require_602394__){module.exports=__nested_webpack_require_602394__(2953);/***/},/***/5486:/***/function(module,__unused_webpack_exports,__nested_webpack_require_602519__){module.exports=__nested_webpack_require_602519__(3066);/***/},/***/2953:/***/function(module){module.exports=squaredDistance;/**
* Calculates the squared euclidian distance between two vec3's
*
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {Number} squared distance between a and b
*/function squaredDistance(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2];return x*x+y*y+z*z;}/***/},/***/3066:/***/function(module){module.exports=squaredLength;/**
* Calculates the squared length of a vec3
*
* @param {vec3} a vector to calculate squared length of
* @returns {Number} squared length of a
*/function squaredLength(a){var x=a[0],y=a[1],z=a[2];return x*x+y*y+z*z;}/***/},/***/2229:/***/function(module,__unused_webpack_exports,__nested_webpack_require_603297__){module.exports=__nested_webpack_require_603297__(6843);/***/},/***/6843:/***/function(module){module.exports=subtract;/**
* Subtracts vector b from vector a
*
* @param {vec3} out the receiving vector
* @param {vec3} a the first operand
* @param {vec3} b the second operand
* @returns {vec3} out
*/function subtract(out,a,b){out[0]=a[0]-b[0];out[1]=a[1]-b[1];out[2]=a[2]-b[2];return out;}/***/},/***/492:/***/function(module){module.exports=transformMat3;/**
* Transforms the vec3 with a mat3.
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {mat4} m the 3x3 matrix to transform with
* @returns {vec3} out
*/function transformMat3(out,a,m){var x=a[0],y=a[1],z=a[2];out[0]=x*m[0]+y*m[3]+z*m[6];out[1]=x*m[1]+y*m[4]+z*m[7];out[2]=x*m[2]+y*m[5]+z*m[8];return out;}/***/},/***/5673:/***/function(module){module.exports=transformMat4;/**
* Transforms the vec3 with a mat4.
* 4th vector component is implicitly '1'
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec3} out
*/function transformMat4(out,a,m){var x=a[0],y=a[1],z=a[2],w=m[3]*x+m[7]*y+m[11]*z+m[15];w=w||1.0;out[0]=(m[0]*x+m[4]*y+m[8]*z+m[12])/w;out[1]=(m[1]*x+m[5]*y+m[9]*z+m[13])/w;out[2]=(m[2]*x+m[6]*y+m[10]*z+m[14])/w;return out;}/***/},/***/264:/***/function(module){module.exports=transformQuat;/**
* Transforms the vec3 with a quat
*
* @param {vec3} out the receiving vector
* @param {vec3} a the vector to transform
* @param {quat} q quaternion to transform with
* @returns {vec3} out
*/function transformQuat(out,a,q){// benchmarks: http://jsperf.com/quaternion-transform-vec3-implementations
var x=a[0],y=a[1],z=a[2],qx=q[0],qy=q[1],qz=q[2],qw=q[3],// calculate quat * vec
ix=qw*x+qy*z-qz*y,iy=qw*y+qz*x-qx*z,iz=qw*z+qx*y-qy*x,iw=-qx*x-qy*y-qz*z;// calculate result * inverse quat
out[0]=ix*qw+iw*-qx+iy*-qz-iz*-qy;out[1]=iy*qw+iw*-qy+iz*-qx-ix*-qz;out[2]=iz*qw+iw*-qz+ix*-qy-iy*-qx;return out;}/***/},/***/4361:/***/function(module){module.exports=add;/**
* Adds two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/function add(out,a,b){out[0]=a[0]+b[0];out[1]=a[1]+b[1];out[2]=a[2]+b[2];out[3]=a[3]+b[3];return out;}/***/},/***/2335:/***/function(module){module.exports=clone;/**
* Creates a new vec4 initialized with values from an existing vector
*
* @param {vec4} a vector to clone
* @returns {vec4} a new 4D vector
*/function clone(a){var out=new Float32Array(4);out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out;}/***/},/***/2933:/***/function(module){module.exports=copy;/**
* Copy the values from one vec4 to another
*
* @param {vec4} out the receiving vector
* @param {vec4} a the source vector
* @returns {vec4} out
*/function copy(out,a){out[0]=a[0];out[1]=a[1];out[2]=a[2];out[3]=a[3];return out;}/***/},/***/7536:/***/function(module){module.exports=create;/**
* Creates a new, empty vec4
*
* @returns {vec4} a new 4D vector
*/function create(){var out=new Float32Array(4);out[0]=0;out[1]=0;out[2]=0;out[3]=0;return out;}/***/},/***/4691:/***/function(module){module.exports=distance;/**
* Calculates the euclidian distance between two vec4's
*
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {Number} distance between a and b
*/function distance(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2],w=b[3]-a[3];return Math.sqrt(x*x+y*y+z*z+w*w);}/***/},/***/1373:/***/function(module){module.exports=divide;/**
* Divides two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/function divide(out,a,b){out[0]=a[0]/b[0];out[1]=a[1]/b[1];out[2]=a[2]/b[2];out[3]=a[3]/b[3];return out;}/***/},/***/3750:/***/function(module){module.exports=dot;/**
* Calculates the dot product of two vec4's
*
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {Number} dot product of a and b
*/function dot(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3];}/***/},/***/3390:/***/function(module){module.exports=fromValues;/**
* Creates a new vec4 initialized with the given values
*
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @param {Number} w W component
* @returns {vec4} a new 4D vector
*/function fromValues(x,y,z,w){var out=new Float32Array(4);out[0]=x;out[1]=y;out[2]=z;out[3]=w;return out;}/***/},/***/9970:/***/function(module,__unused_webpack_exports,__nested_webpack_require_607964__){module.exports={create:__nested_webpack_require_607964__(7536),clone:__nested_webpack_require_607964__(2335),fromValues:__nested_webpack_require_607964__(3390),copy:__nested_webpack_require_607964__(2933),set:__nested_webpack_require_607964__(4578),add:__nested_webpack_require_607964__(4361),subtract:__nested_webpack_require_607964__(6860),multiply:__nested_webpack_require_607964__(3576),divide:__nested_webpack_require_607964__(1373),min:__nested_webpack_require_607964__(2334),max:__nested_webpack_require_607964__(160),scale:__nested_webpack_require_607964__(9288),scaleAndAdd:__nested_webpack_require_607964__(4844),distance:__nested_webpack_require_607964__(4691),squaredDistance:__nested_webpack_require_607964__(7960),length:__nested_webpack_require_607964__(6808),squaredLength:__nested_webpack_require_607964__(483),negate:__nested_webpack_require_607964__(1498),inverse:__nested_webpack_require_607964__(4494),normalize:__nested_webpack_require_607964__(5177),dot:__nested_webpack_require_607964__(3750),lerp:__nested_webpack_require_607964__(2573),random:__nested_webpack_require_607964__(9131),transformMat4:__nested_webpack_require_607964__(5352),transformQuat:__nested_webpack_require_607964__(4041)};/***/},/***/4494:/***/function(module){module.exports=inverse;/**
* Returns the inverse of the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to invert
* @returns {vec4} out
*/function inverse(out,a){out[0]=1.0/a[0];out[1]=1.0/a[1];out[2]=1.0/a[2];out[3]=1.0/a[3];return out;}/***/},/***/6808:/***/function(module){module.exports=length;/**
* Calculates the length of a vec4
*
* @param {vec4} a vector to calculate length of
* @returns {Number} length of a
*/function length(a){var x=a[0],y=a[1],z=a[2],w=a[3];return Math.sqrt(x*x+y*y+z*z+w*w);}/***/},/***/2573:/***/function(module){module.exports=lerp;/**
* Performs a linear interpolation between two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @param {Number} t interpolation amount between the two inputs
* @returns {vec4} out
*/function lerp(out,a,b,t){var ax=a[0],ay=a[1],az=a[2],aw=a[3];out[0]=ax+t*(b[0]-ax);out[1]=ay+t*(b[1]-ay);out[2]=az+t*(b[2]-az);out[3]=aw+t*(b[3]-aw);return out;}/***/},/***/160:/***/function(module){module.exports=max;/**
* Returns the maximum of two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/function max(out,a,b){out[0]=Math.max(a[0],b[0]);out[1]=Math.max(a[1],b[1]);out[2]=Math.max(a[2],b[2]);out[3]=Math.max(a[3],b[3]);return out;}/***/},/***/2334:/***/function(module){module.exports=min;/**
* Returns the minimum of two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/function min(out,a,b){out[0]=Math.min(a[0],b[0]);out[1]=Math.min(a[1],b[1]);out[2]=Math.min(a[2],b[2]);out[3]=Math.min(a[3],b[3]);return out;}/***/},/***/3576:/***/function(module){module.exports=multiply;/**
* Multiplies two vec4's
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/function multiply(out,a,b){out[0]=a[0]*b[0];out[1]=a[1]*b[1];out[2]=a[2]*b[2];out[3]=a[3]*b[3];return out;}/***/},/***/1498:/***/function(module){module.exports=negate;/**
* Negates the components of a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to negate
* @returns {vec4} out
*/function negate(out,a){out[0]=-a[0];out[1]=-a[1];out[2]=-a[2];out[3]=-a[3];return out;}/***/},/***/5177:/***/function(module){module.exports=normalize;/**
* Normalize a vec4
*
* @param {vec4} out the receiving vector
* @param {vec4} a vector to normalize
* @returns {vec4} out
*/function normalize(out,a){var x=a[0],y=a[1],z=a[2],w=a[3];var len=x*x+y*y+z*z+w*w;if(len>0){len=1/Math.sqrt(len);out[0]=x*len;out[1]=y*len;out[2]=z*len;out[3]=w*len;}return out;}/***/},/***/9131:/***/function(module,__unused_webpack_exports,__nested_webpack_require_611792__){var vecNormalize=__nested_webpack_require_611792__(5177);var vecScale=__nested_webpack_require_611792__(9288);module.exports=random;/**
* Generates a random vector with the given scale
*
* @param {vec4} out the receiving vector
* @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
* @returns {vec4} out
*/function random(out,scale){scale=scale||1.0;// TODO: This is a pretty awful way of doing this. Find something better.
out[0]=Math.random();out[1]=Math.random();out[2]=Math.random();out[3]=Math.random();vecNormalize(out,out);vecScale(out,out,scale);return out;}/***/},/***/9288:/***/function(module){module.exports=scale;/**
* Scales a vec4 by a scalar number
*
* @param {vec4} out the receiving vector
* @param {vec4} a the vector to scale
* @param {Number} b amount to scale the vector by
* @returns {vec4} out
*/function scale(out,a,b){out[0]=a[0]*b;out[1]=a[1]*b;out[2]=a[2]*b;out[3]=a[3]*b;return out;}/***/},/***/4844:/***/function(module){module.exports=scaleAndAdd;/**
* Adds two vec4's after scaling the second operand by a scalar value
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @param {Number} scale the amount to scale b by before adding
* @returns {vec4} out
*/function scaleAndAdd(out,a,b,scale){out[0]=a[0]+b[0]*scale;out[1]=a[1]+b[1]*scale;out[2]=a[2]+b[2]*scale;out[3]=a[3]+b[3]*scale;return out;}/***/},/***/4578:/***/function(module){module.exports=set;/**
* Set the components of a vec4 to the given values
*
* @param {vec4} out the receiving vector
* @param {Number} x X component
* @param {Number} y Y component
* @param {Number} z Z component
* @param {Number} w W component
* @returns {vec4} out
*/function set(out,x,y,z,w){out[0]=x;out[1]=y;out[2]=z;out[3]=w;return out;}/***/},/***/7960:/***/function(module){module.exports=squaredDistance;/**
* Calculates the squared euclidian distance between two vec4's
*
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {Number} squared distance between a and b
*/function squaredDistance(a,b){var x=b[0]-a[0],y=b[1]-a[1],z=b[2]-a[2],w=b[3]-a[3];return x*x+y*y+z*z+w*w;}/***/},/***/483:/***/function(module){module.exports=squaredLength;/**
* Calculates the squared length of a vec4
*
* @param {vec4} a vector to calculate squared length of
* @returns {Number} squared length of a
*/function squaredLength(a){var x=a[0],y=a[1],z=a[2],w=a[3];return x*x+y*y+z*z+w*w;}/***/},/***/6860:/***/function(module){module.exports=subtract;/**
* Subtracts vector b from vector a
*
* @param {vec4} out the receiving vector
* @param {vec4} a the first operand
* @param {vec4} b the second operand
* @returns {vec4} out
*/function subtract(out,a,b){out[0]=a[0]-b[0];out[1]=a[1]-b[1];out[2]=a[2]-b[2];out[3]=a[3]-b[3];return out;}/***/},/***/5352:/***/function(module){module.exports=transformMat4;/**
* Transforms the vec4 with a mat4.
*
* @param {vec4} out the receiving vector
* @param {vec4} a the vector to transform
* @param {mat4} m matrix to transform with
* @returns {vec4} out
*/function transformMat4(out,a,m){var x=a[0],y=a[1],z=a[2],w=a[3];out[0]=m[0]*x+m[4]*y+m[8]*z+m[12]*w;out[1]=m[1]*x+m[5]*y+m[9]*z+m[13]*w;out[2]=m[2]*x+m[6]*y+m[10]*z+m[14]*w;out[3]=m[3]*x+m[7]*y+m[11]*z+m[15]*w;return out;}/***/},/***/4041:/***/function(module){module.exports=transformQuat;/**
* Transforms the vec4 with a quat
*
* @param {vec4} out the receiving vector
* @param {vec4} a the vector to transform
* @param {quat} q quaternion to transform with
* @returns {vec4} out
*/function transformQuat(out,a,q){var x=a[0],y=a[1],z=a[2],qx=q[0],qy=q[1],qz=q[2],qw=q[3],// calculate quat * vec
ix=qw*x+qy*z-qz*y,iy=qw*y+qz*x-qx*z,iz=qw*z+qx*y-qy*x,iw=-qx*x-qy*y-qz*z;// calculate result * inverse quat
out[0]=ix*qw+iw*-qx+iy*-qz-iz*-qy;out[1]=iy*qw+iw*-qy+iz*-qx-ix*-qz;out[2]=iz*qw+iw*-qz+ix*-qy-iy*-qx;out[3]=a[3];return out;}/***/},/***/1848:/***/function(module,__unused_webpack_exports,__nested_webpack_require_615841__){var tokenize=__nested_webpack_require_615841__(4905);var atob=__nested_webpack_require_615841__(6468);module.exports=getName;function getName(src){var tokens=Array.isArray(src)?src:tokenize(src);for(var i=0;i0)continue;res=buf.slice(0,1).join('');}token(res);start+=res.length;content=content.slice(res.length);return content.length;}while(1);}function hex(){if(/[^a-fA-F0-9]/.test(c)){token(content.join(''));mode=NORMAL;return i;}content.push(c);last=c;return i+1;}function integer(){if(c==='.'){content.push(c);mode=FLOAT;last=c;return i+1;}if(/[eE]/.test(c)){content.push(c);mode=FLOAT;last=c;return i+1;}if(c==='x'&&content.length===1&&content[0]==='0'){mode=HEX;content.push(c);last=c;return i+1;}if(/[^\d]/.test(c)){token(content.join(''));mode=NORMAL;return i;}content.push(c);last=c;return i+1;}function decimal(){if(c==='f'){content.push(c);last=c;i+=1;}if(/[eE]/.test(c)){content.push(c);last=c;return i+1;}if((c==='-'||c==='+')&&/[eE]/.test(last)){content.push(c);last=c;return i+1;}if(/[^\d]/.test(c)){token(content.join(''));mode=NORMAL;return i;}content.push(c);last=c;return i+1;}function readtoken(){if(/[^\d\w_]/.test(c)){var contentstr=content.join('');if(literalsDict[contentstr]){mode=KEYWORD;}else if(builtinsDict[contentstr]){mode=BUILTIN;}else{mode=IDENT;}token(content.join(''));mode=NORMAL;return i;}content.push(c);last=c;return i+1;}}/***/},/***/3508:/***/function(module,__unused_webpack_exports,__nested_webpack_require_621240__){// 300es builtins/reserved words that were previously valid in v100
var v100=__nested_webpack_require_621240__(6852);// The texture2D|Cube functions have been removed
// And the gl_ features are updated
v100=v100.slice().filter(function(b){return!/^(gl\_|texture)/.test(b);});module.exports=v100.concat([// the updated gl_ constants
'gl_VertexID','gl_InstanceID','gl_Position','gl_PointSize','gl_FragCoord','gl_FrontFacing','gl_FragDepth','gl_PointCoord','gl_MaxVertexAttribs','gl_MaxVertexUniformVectors','gl_MaxVertexOutputVectors','gl_MaxFragmentInputVectors','gl_MaxVertexTextureImageUnits','gl_MaxCombinedTextureImageUnits','gl_MaxTextureImageUnits','gl_MaxFragmentUniformVectors','gl_MaxDrawBuffers','gl_MinProgramTexelOffset','gl_MaxProgramTexelOffset','gl_DepthRangeParameters','gl_DepthRange'// other builtins
,'trunc','round','roundEven','isnan','isinf','floatBitsToInt','floatBitsToUint','intBitsToFloat','uintBitsToFloat','packSnorm2x16','unpackSnorm2x16','packUnorm2x16','unpackUnorm2x16','packHalf2x16','unpackHalf2x16','outerProduct','transpose','determinant','inverse','texture','textureSize','textureProj','textureLod','textureOffset','texelFetch','texelFetchOffset','textureProjOffset','textureLodOffset','textureProjLod','textureProjLodOffset','textureGrad','textureGradOffset','textureProjGrad','textureProjGradOffset']);/***/},/***/6852:/***/function(module){module.exports=[// Keep this list sorted
'abs','acos','all','any','asin','atan','ceil','clamp','cos','cross','dFdx','dFdy','degrees','distance','dot','equal','exp','exp2','faceforward','floor','fract','gl_BackColor','gl_BackLightModelProduct','gl_BackLightProduct','gl_BackMaterial','gl_BackSecondaryColor','gl_ClipPlane','gl_ClipVertex','gl_Color','gl_DepthRange','gl_DepthRangeParameters','gl_EyePlaneQ','gl_EyePlaneR','gl_EyePlaneS','gl_EyePlaneT','gl_Fog','gl_FogCoord','gl_FogFragCoord','gl_FogParameters','gl_FragColor','gl_FragCoord','gl_FragData','gl_FragDepth','gl_FragDepthEXT','gl_FrontColor','gl_FrontFacing','gl_FrontLightModelProduct','gl_FrontLightProduct','gl_FrontMaterial','gl_FrontSecondaryColor','gl_LightModel','gl_LightModelParameters','gl_LightModelProducts','gl_LightProducts','gl_LightSource','gl_LightSourceParameters','gl_MaterialParameters','gl_MaxClipPlanes','gl_MaxCombinedTextureImageUnits','gl_MaxDrawBuffers','gl_MaxFragmentUniformComponents','gl_MaxLights','gl_MaxTextureCoords','gl_MaxTextureImageUnits','gl_MaxTextureUnits','gl_MaxVaryingFloats','gl_MaxVertexAttribs','gl_MaxVertexTextureImageUnits','gl_MaxVertexUniformComponents','gl_ModelViewMatrix','gl_ModelViewMatrixInverse','gl_ModelViewMatrixInverseTranspose','gl_ModelViewMatrixTranspose','gl_ModelViewProjectionMatrix','gl_ModelViewProjectionMatrixInverse','gl_ModelViewProjectionMatrixInverseTranspose','gl_ModelViewProjectionMatrixTranspose','gl_MultiTexCoord0','gl_MultiTexCoord1','gl_MultiTexCoord2','gl_MultiTexCoord3','gl_MultiTexCoord4','gl_MultiTexCoord5','gl_MultiTexCoord6','gl_MultiTexCoord7','gl_Normal','gl_NormalMatrix','gl_NormalScale','gl_ObjectPlaneQ','gl_ObjectPlaneR','gl_ObjectPlaneS','gl_ObjectPlaneT','gl_Point','gl_PointCoord','gl_PointParameters','gl_PointSize','gl_Position','gl_ProjectionMatrix','gl_ProjectionMatrixInverse','gl_ProjectionMatrixInverseTranspose','gl_ProjectionMatrixTranspose','gl_SecondaryColor','gl_TexCoord','gl_TextureEnvColor','gl_TextureMatrix','gl_TextureMatrixInverse','gl_TextureMatrixInverseTranspose','gl_TextureMatrixTranspose','gl_Vertex','greaterThan','greaterThanEqual','inversesqrt','length','lessThan','lessThanEqual','log','log2','matrixCompMult','max','min','mix','mod','normalize','not','notEqual','pow','radians','reflect','refract','sign','sin','smoothstep','sqrt','step','tan','texture2D','texture2DLod','texture2DProj','texture2DProjLod','textureCube','textureCubeLod','texture2DLodEXT','texture2DProjLodEXT','textureCubeLodEXT','texture2DGradEXT','texture2DProjGradEXT','textureCubeGradEXT'];/***/},/***/7932:/***/function(module,__unused_webpack_exports,__nested_webpack_require_625246__){var v100=__nested_webpack_require_625246__(620);module.exports=v100.slice().concat(['layout','centroid','smooth','case','mat2x2','mat2x3','mat2x4','mat3x2','mat3x3','mat3x4','mat4x2','mat4x3','mat4x4','uvec2','uvec3','uvec4','samplerCubeShadow','sampler2DArray','sampler2DArrayShadow','isampler2D','isampler3D','isamplerCube','isampler2DArray','usampler2D','usampler3D','usamplerCube','usampler2DArray','coherent','restrict','readonly','writeonly','resource','atomic_uint','noperspective','patch','sample','subroutine','common','partition','active','filter','image1D','image2D','image3D','imageCube','iimage1D','iimage2D','iimage3D','iimageCube','uimage1D','uimage2D','uimage3D','uimageCube','image1DArray','image2DArray','iimage1DArray','iimage2DArray','uimage1DArray','uimage2DArray','image1DShadow','image2DShadow','image1DArrayShadow','image2DArrayShadow','imageBuffer','iimageBuffer','uimageBuffer','sampler1DArray','sampler1DArrayShadow','isampler1D','isampler1DArray','usampler1D','usampler1DArray','isampler2DRect','usampler2DRect','samplerBuffer','isamplerBuffer','usamplerBuffer','sampler2DMS','isampler2DMS','usampler2DMS','sampler2DMSArray','isampler2DMSArray','usampler2DMSArray']);/***/},/***/620:/***/function(module){module.exports=[// current
'precision','highp','mediump','lowp','attribute','const','uniform','varying','break','continue','do','for','while','if','else','in','out','inout','float','int','uint','void','bool','true','false','discard','return','mat2','mat3','mat4','vec2','vec3','vec4','ivec2','ivec3','ivec4','bvec2','bvec3','bvec4','sampler1D','sampler2D','sampler3D','samplerCube','sampler1DShadow','sampler2DShadow','struct'// future
,'asm','class','union','enum','typedef','template','this','packed','goto','switch','default','inline','noinline','volatile','public','static','extern','external','interface','long','short','double','half','fixed','unsigned','input','output','hvec2','hvec3','hvec4','dvec2','dvec3','dvec4','fvec2','fvec3','fvec4','sampler2DRect','sampler3DRect','sampler2DRectShadow','sizeof','cast','namespace','using'];/***/},/***/7827:/***/function(module){module.exports=['<<=','>>=','++','--','<<','>>','<=','>=','==','!=','&&','||','+=','-=','*=','/=','%=','&=','^^','^=','|=','(',')','[',']','.','!','~','*','/','%','+','-','<','>','&','^','|','?',':','=',',',';','{','}'];/***/},/***/4905:/***/function(module,__unused_webpack_exports,__nested_webpack_require_627648__){var tokenize=__nested_webpack_require_627648__(5874);module.exports=tokenizeString;function tokenizeString(str,opt){var generator=tokenize(opt);var tokens=[];tokens=tokens.concat(generator(str));tokens=tokens.concat(generator(null));return tokens;}/***/},/***/3236:/***/function(module){module.exports=function(strings){if(typeof strings==='string')strings=[strings];var exprs=[].slice.call(arguments,1);var parts=[];for(var i=0;i */exports.read=function(buffer,offset,isLE,mLen,nBytes){var e,m;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var nBits=-7;var i=isLE?nBytes-1:0;var d=isLE?-1:1;var s=buffer[offset+i];i+=d;e=s&(1<<-nBits)-1;s>>=-nBits;nBits+=eLen;for(;nBits>0;e=e*256+buffer[offset+i],i+=d,nBits-=8){}m=e&(1<<-nBits)-1;e>>=-nBits;nBits+=mLen;for(;nBits>0;m=m*256+buffer[offset+i],i+=d,nBits-=8){}if(e===0){e=1-eBias;}else if(e===eMax){return m?NaN:(s?-1:1)*Infinity;}else{m=m+Math.pow(2,mLen);e=e-eBias;}return(s?-1:1)*m*Math.pow(2,e-mLen);};exports.write=function(buffer,value,offset,isLE,mLen,nBytes){var e,m,c;var eLen=nBytes*8-mLen-1;var eMax=(1<>1;var rt=mLen===23?Math.pow(2,-24)-Math.pow(2,-77):0;var i=isLE?0:nBytes-1;var d=isLE?1:-1;var s=value<0||value===0&&1/value<0?1:0;value=Math.abs(value);if(isNaN(value)||value===Infinity){m=isNaN(value)?1:0;e=eMax;}else{e=Math.floor(Math.log(value)/Math.LN2);if(value*(c=Math.pow(2,-e))<1){e--;c*=2;}if(e+eBias>=1){value+=rt/c;}else{value+=rt*Math.pow(2,1-eBias);}if(value*c>=2){e++;c/=2;}if(e+eBias>=eMax){m=0;e=eMax;}else if(e+eBias>=1){m=(value*c-1)*Math.pow(2,mLen);e=e+eBias;}else{m=value*Math.pow(2,eBias-1)*Math.pow(2,mLen);e=0;}}for(;mLen>=8;buffer[offset+i]=m&0xff,i+=d,m/=256,mLen-=8){}e=e<0;buffer[offset+i]=e&0xff,i+=d,e/=256,eLen-=8){}buffer[offset+i-d]|=s*128;};/***/},/***/8954:/***/function(module,__unused_webpack_exports,__nested_webpack_require_630212__){"use strict";//High level idea:
// 1. Use Clarkson's incremental construction to find convex hull
// 2. Point location in triangulation by jump and walk
module.exports=incrementalConvexHull;var orient=__nested_webpack_require_630212__(3250);var compareCell=__nested_webpack_require_630212__(6803)/* .compareCells */.Fw;function Simplex(vertices,adjacent,boundary){this.vertices=vertices;this.adjacent=adjacent;this.boundary=boundary;this.lastVisited=-1;}Simplex.prototype.flip=function(){var t=this.vertices[0];this.vertices[0]=this.vertices[1];this.vertices[1]=t;var u=this.adjacent[0];this.adjacent[0]=this.adjacent[1];this.adjacent[1]=u;};function GlueFacet(vertices,cell,index){this.vertices=vertices;this.cell=cell;this.index=index;}function compareGlue(a,b){return compareCell(a.vertices,b.vertices);}function wrapper(test){return function(){var tuple=this.tuple;return test.apply(this,tuple);};}function bakeOrient(d){var test=orient[d+1];if(!test){test=orient;}return wrapper(test);}var BAKED=[];function Triangulation(dimension,vertices,simplices){this.dimension=dimension;this.vertices=vertices;this.simplices=simplices;this.interior=simplices.filter(function(c){return!c.boundary;});this.tuple=new Array(dimension+1);for(var i=0;i<=dimension;++i){this.tuple[i]=this.vertices[i];}var o=BAKED[dimension];if(!o){o=BAKED[dimension]=bakeOrient(dimension);}this.orient=o;}var proto=Triangulation.prototype;//Degenerate situation where we are on boundary, but coplanar to face
proto.handleBoundaryDegeneracy=function(cell,point){var d=this.dimension;var n=this.vertices.length-1;var tuple=this.tuple;var verts=this.vertices;//Dumb solution: Just do dfs from boundary cell until we find any peak, or terminate
var toVisit=[cell];cell.lastVisited=-n;while(toVisit.length>0){cell=toVisit.pop();var cellAdj=cell.adjacent;for(var i=0;i<=d;++i){var neighbor=cellAdj[i];if(!neighbor.boundary||neighbor.lastVisited<=-n){continue;}var nv=neighbor.vertices;for(var j=0;j<=d;++j){var vv=nv[j];if(vv<0){tuple[j]=point;}else{tuple[j]=verts[vv];}}var o=this.orient();if(o>0){return neighbor;}neighbor.lastVisited=-n;if(o===0){toVisit.push(neighbor);}}}return null;};proto.walk=function(point,random){//Alias local properties
var n=this.vertices.length-1;var d=this.dimension;var verts=this.vertices;var tuple=this.tuple;//Compute initial jump cell
var initIndex=random?this.interior.length*Math.random()|0:this.interior.length-1;var cell=this.interior[initIndex];//Start walking
outerLoop:while(!cell.boundary){var cellVerts=cell.vertices;var cellAdj=cell.adjacent;for(var i=0;i<=d;++i){tuple[i]=verts[cellVerts[i]];}cell.lastVisited=n;//Find farthest adjacent cell
for(var i=0;i<=d;++i){var neighbor=cellAdj[i];if(neighbor.lastVisited>=n){continue;}var prev=tuple[i];tuple[i]=point;var o=this.orient();tuple[i]=prev;if(o<0){cell=neighbor;continue outerLoop;}else{if(!neighbor.boundary){neighbor.lastVisited=n;}else{neighbor.lastVisited=-n;}}}return;}return cell;};proto.addPeaks=function(point,cell){var n=this.vertices.length-1;var d=this.dimension;var verts=this.vertices;var tuple=this.tuple;var interior=this.interior;var simplices=this.simplices;//Walking finished at boundary, time to add peaks
var tovisit=[cell];//Stretch initial boundary cell into a peak
cell.lastVisited=n;cell.vertices[cell.vertices.indexOf(-1)]=n;cell.boundary=false;interior.push(cell);//Record a list of all new boundaries created by added peaks so we can glue them together when we are all done
var glueFacets=[];//Do a traversal of the boundary walking outward from starting peak
while(tovisit.length>0){//Pop off peak and walk over adjacent cells
var cell=tovisit.pop();var cellVerts=cell.vertices;var cellAdj=cell.adjacent;var indexOfN=cellVerts.indexOf(n);if(indexOfN<0){continue;}for(var i=0;i<=d;++i){if(i===indexOfN){continue;}//For each boundary neighbor of the cell
var neighbor=cellAdj[i];if(!neighbor.boundary||neighbor.lastVisited>=n){continue;}var nv=neighbor.vertices;//Test if neighbor is a peak
if(neighbor.lastVisited!==-n){//Compute orientation of p relative to each boundary peak
var indexOfNeg1=0;for(var j=0;j<=d;++j){if(nv[j]<0){indexOfNeg1=j;tuple[j]=point;}else{tuple[j]=verts[nv[j]];}}var o=this.orient();//Test if neighbor cell is also a peak
if(o>0){nv[indexOfNeg1]=n;neighbor.boundary=false;interior.push(neighbor);tovisit.push(neighbor);neighbor.lastVisited=n;continue;}else{neighbor.lastVisited=-n;}}var na=neighbor.adjacent;//Otherwise, replace neighbor with new face
var vverts=cellVerts.slice();var vadj=cellAdj.slice();var ncell=new Simplex(vverts,vadj,true);simplices.push(ncell);//Connect to neighbor
var opposite=na.indexOf(cell);if(opposite<0){continue;}na[opposite]=ncell;vadj[indexOfN]=neighbor;//Connect to cell
vverts[i]=-1;vadj[i]=cell;cellAdj[i]=ncell;//Flip facet
ncell.flip();//Add to glue list
for(var j=0;j<=d;++j){var uu=vverts[j];if(uu<0||uu===n){continue;}var nface=new Array(d-1);var nptr=0;for(var k=0;k<=d;++k){var vv=vverts[k];if(vv<0||k===j){continue;}nface[nptr++]=vv;}glueFacets.push(new GlueFacet(nface,ncell,j));}}}//Glue boundary facets together
glueFacets.sort(compareGlue);for(var i=0;i+1=0){bcell[ptr++]=cv[j];}else{parity=j&1;}}if(parity===(d&1)){var t=bcell[0];bcell[0]=bcell[1];bcell[1]=t;}boundary.push(bcell);}}return boundary;};function incrementalConvexHull(points,randomSearch){var n=points.length;if(n===0){throw new Error("Must have at least d+1 points");}var d=points[0].length;if(n<=d){throw new Error("Must input at least d+1 points");}//FIXME: This could be degenerate, but need to select d+1 non-coplanar points to bootstrap process
var initialSimplex=points.slice(0,d+1);//Make sure initial simplex is positively oriented
var o=orient.apply(void 0,initialSimplex);if(o===0){throw new Error("Input not in general position");}var initialCoords=new Array(d+1);for(var i=0;i<=d;++i){initialCoords[i]=i;}if(o<0){initialCoords[0]=1;initialCoords[1]=0;}//Create initial topological index, glue pointers together (kind of messy)
var initialCell=new Simplex(initialCoords,new Array(d+1),false);var boundary=initialCell.adjacent;var list=new Array(d+2);for(var i=0;i<=d;++i){var verts=initialCoords.slice();for(var j=0;j<=d;++j){if(j===i){verts[j]=-1;}}var t=verts[0];verts[0]=verts[1];verts[1]=t;var cell=new Simplex(verts,new Array(d+1),true);boundary[i]=cell;list[i]=cell;}list[d+1]=initialCell;for(var i=0;i<=d;++i){var verts=boundary[i].vertices;var adj=boundary[i].adjacent;for(var j=0;j<=d;++j){var v=verts[j];if(v<0){adj[j]=initialCell;continue;}for(var k=0;k<=d;++k){if(boundary[k].vertices.indexOf(v)<0){adj[j]=boundary[k];}}}}//Initialize triangles
var triangles=new Triangulation(d,initialSimplex,list);//Insert remaining points
var useRandom=!!randomSearch;for(var i=d+1;i3*(weight+1)){rebuildWithInterval(this,interval);}else{this.left.insert(interval);}}else{this.left=createIntervalTree([interval]);}}else if(interval[0]>this.mid){if(this.right){if(4*(this.right.count+1)>3*(weight+1)){rebuildWithInterval(this,interval);}else{this.right.insert(interval);}}else{this.right=createIntervalTree([interval]);}}else{var l=bounds.ge(this.leftPoints,interval,compareBegin);var r=bounds.ge(this.rightPoints,interval,compareEnd);this.leftPoints.splice(l,0,interval);this.rightPoints.splice(r,0,interval);}};proto.remove=function(interval){var weight=this.count-this.leftPoints;if(interval[1]3*(weight-1)){return rebuildWithoutInterval(this,interval);}var r=this.left.remove(interval);if(r===EMPTY){this.left=null;this.count-=1;return SUCCESS;}else if(r===SUCCESS){this.count-=1;}return r;}else if(interval[0]>this.mid){if(!this.right){return NOT_FOUND;}var lw=this.left?this.left.count:0;if(4*lw>3*(weight-1)){return rebuildWithoutInterval(this,interval);}var r=this.right.remove(interval);if(r===EMPTY){this.right=null;this.count-=1;return SUCCESS;}else if(r===SUCCESS){this.count-=1;}return r;}else{if(this.count===1){if(this.leftPoints[0]===interval){return EMPTY;}else{return NOT_FOUND;}}if(this.leftPoints.length===1&&this.leftPoints[0]===interval){if(this.left&&this.right){var p=this;var n=this.left;while(n.right){p=n;n=n.right;}if(p===this){n.right=this.right;}else{var l=this.left;var r=this.right;p.count-=n.count;p.right=n.left;n.left=l;n.right=r;}copy(this,n);this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length;}else if(this.left){copy(this,this.left);}else{copy(this,this.right);}return SUCCESS;}for(var l=bounds.ge(this.leftPoints,interval,compareBegin);l=0&&arr[i][1]>=lo;--i){var r=cb(arr[i]);if(r){return r;}}}function reportRange(arr,cb){for(var i=0;ithis.mid){if(this.right){var r=this.right.queryPoint(x,cb);if(r){return r;}}return reportRightRange(this.rightPoints,x,cb);}else{return reportRange(this.leftPoints,cb);}};proto.queryInterval=function(lo,hi,cb){if(lothis.mid&&this.right){var r=this.right.queryInterval(lo,hi,cb);if(r){return r;}}if(hithis.mid){return reportRightRange(this.rightPoints,lo,cb);}else{return reportRange(this.leftPoints,cb);}};function compareNumbers(a,b){return a-b;}function compareBegin(a,b){var d=a[0]-b[0];if(d){return d;}return a[1]-b[1];}function compareEnd(a,b){var d=a[1]-b[1];if(d){return d;}return a[0]-b[0];}function createIntervalTree(intervals){if(intervals.length===0){return null;}var pts=[];for(var i=0;i>1];var leftIntervals=[];var rightIntervals=[];var centerIntervals=[];for(var i=0;i
* @license MIT
*/ // The _isBuffer check is for Safari 5-7 support, because it's missing
// Object.prototype.constructor. Remove this eventually
module.exports=function(obj){return obj!=null&&(isBuffer(obj)||isSlowBuffer(obj)||!!obj._isBuffer);};function isBuffer(obj){return!!obj.constructor&&typeof obj.constructor.isBuffer==='function'&&obj.constructor.isBuffer(obj);}// For Node v0.10 support. Remove this eventually.
function isSlowBuffer(obj){return typeof obj.readFloatLE==='function'&&typeof obj.slice==='function'&&isBuffer(obj.slice(0,0));}/***/},/***/5219:/***/function(module){"use strict";/**
* Is this string all whitespace?
* This solution kind of makes my brain hurt, but it's significantly faster
* than !str.trim() or any other solution I could find.
*
* whitespace codes from: http://en.wikipedia.org/wiki/Whitespace_character
* and verified with:
*
* for(var i = 0; i < 65536; i++) {
* var s = String.fromCharCode(i);
* if(+s===0 && !s.trim()) console.log(i, s);
* }
*
* which counts a couple of these as *not* whitespace, but finds nothing else
* that *is* whitespace. Note that charCodeAt stops at 16 bits, but it appears
* that there are no whitespace characters above this, and code points above
* this do not map onto white space characters.
*/module.exports=function(str){var l=str.length,a;for(var i=0;i13)&&a!==32&&a!==133&&a!==160&&a!==5760&&a!==6158&&(a<8192||a>8205)&&a!==8232&&a!==8233&&a!==8239&&a!==8287&&a!==8288&&a!==12288&&a!==65279){return false;}}return true;};/***/},/***/395:/***/function(module){function lerp(v0,v1,t){return v0*(1-t)+v1*t;}module.exports=lerp;/***/},/***/2652:/***/function(module,__unused_webpack_exports,__nested_webpack_require_646920__){/*jshint unused:true*/ /*
Input: matrix ; a 4x4 matrix
Output: translation ; a 3 component vector
scale ; a 3 component vector
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
perspective ; a 4 component vector
quaternion ; a 4 component vector
Returns false if the matrix cannot be decomposed, true if it can
References:
https://github.com/kamicane/matrix3d/blob/master/lib/Matrix3d.js
https://github.com/ChromiumWebApps/chromium/blob/master/ui/gfx/transform_util.cc
http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix
*/var normalize=__nested_webpack_require_646920__(4335);var create=__nested_webpack_require_646920__(6864);var clone=__nested_webpack_require_646920__(1903);var determinant=__nested_webpack_require_646920__(9921);var invert=__nested_webpack_require_646920__(7608);var transpose=__nested_webpack_require_646920__(5665);var vec3={length:__nested_webpack_require_646920__(1387),normalize:__nested_webpack_require_646920__(3536),dot:__nested_webpack_require_646920__(244),cross:__nested_webpack_require_646920__(5911)};var tmp=create();var perspectiveMatrix=create();var tmpVec4=[0,0,0,0];var row=[[0,0,0],[0,0,0],[0,0,0]];var pdum3=[0,0,0];module.exports=function decomposeMat4(matrix,translation,scale,skew,perspective,quaternion){if(!translation)translation=[0,0,0];if(!scale)scale=[0,0,0];if(!skew)skew=[0,0,0];if(!perspective)perspective=[0,0,0,1];if(!quaternion)quaternion=[0,0,0,1];//normalize, if not possible then bail out early
if(!normalize(tmp,matrix))return false;// perspectiveMatrix is used to solve for perspective, but it also provides
// an easy way to test for singularity of the upper 3x3 component.
clone(perspectiveMatrix,tmp);perspectiveMatrix[3]=0;perspectiveMatrix[7]=0;perspectiveMatrix[11]=0;perspectiveMatrix[15]=1;// If the perspectiveMatrix is not invertible, we are also unable to
// decompose, so we'll bail early. Constant taken from SkMatrix44::invert.
if(Math.abs(determinant(perspectiveMatrix)<1e-8))return false;var a03=tmp[3],a13=tmp[7],a23=tmp[11],a30=tmp[12],a31=tmp[13],a32=tmp[14],a33=tmp[15];// First, isolate perspective.
if(a03!==0||a13!==0||a23!==0){tmpVec4[0]=a03;tmpVec4[1]=a13;tmpVec4[2]=a23;tmpVec4[3]=a33;// Solve the equation by inverting perspectiveMatrix and multiplying
// rightHandSide by the inverse.
// resuing the perspectiveMatrix here since it's no longer needed
var ret=invert(perspectiveMatrix,perspectiveMatrix);if(!ret)return false;transpose(perspectiveMatrix,perspectiveMatrix);//multiply by transposed inverse perspective matrix, into perspective vec4
vec4multMat4(perspective,tmpVec4,perspectiveMatrix);}else{//no perspective
perspective[0]=perspective[1]=perspective[2]=0;perspective[3]=1;}// Next take care of translation
translation[0]=a30;translation[1]=a31;translation[2]=a32;// Now get scale and shear. 'row' is a 3 element array of 3 component vectors
mat3from4(row,tmp);// Compute X scale factor and normalize first row.
scale[0]=vec3.length(row[0]);vec3.normalize(row[0],row[0]);// Compute XY shear factor and make 2nd row orthogonal to 1st.
skew[0]=vec3.dot(row[0],row[1]);combine(row[1],row[1],row[0],1.0,-skew[0]);// Now, compute Y scale and normalize 2nd row.
scale[1]=vec3.length(row[1]);vec3.normalize(row[1],row[1]);skew[0]/=scale[1];// Compute XZ and YZ shears, orthogonalize 3rd row
skew[1]=vec3.dot(row[0],row[2]);combine(row[2],row[2],row[0],1.0,-skew[1]);skew[2]=vec3.dot(row[1],row[2]);combine(row[2],row[2],row[1],1.0,-skew[2]);// Next, get Z scale and normalize 3rd row.
scale[2]=vec3.length(row[2]);vec3.normalize(row[2],row[2]);skew[1]/=scale[2];skew[2]/=scale[2];// At this point, the matrix (in rows) is orthonormal.
// Check for a coordinate system flip. If the determinant
// is -1, then negate the matrix and the scaling factors.
vec3.cross(pdum3,row[1],row[2]);if(vec3.dot(row[0],pdum3)<0){for(var i=0;i<3;i++){scale[i]*=-1;row[i][0]*=-1;row[i][1]*=-1;row[i][2]*=-1;}}// Now, get the rotations out
quaternion[0]=0.5*Math.sqrt(Math.max(1+row[0][0]-row[1][1]-row[2][2],0));quaternion[1]=0.5*Math.sqrt(Math.max(1-row[0][0]+row[1][1]-row[2][2],0));quaternion[2]=0.5*Math.sqrt(Math.max(1-row[0][0]-row[1][1]+row[2][2],0));quaternion[3]=0.5*Math.sqrt(Math.max(1+row[0][0]+row[1][1]+row[2][2],0));if(row[2][1]>row[1][2])quaternion[0]=-quaternion[0];if(row[0][2]>row[2][0])quaternion[1]=-quaternion[1];if(row[1][0]>row[0][1])quaternion[2]=-quaternion[2];return true;};//will be replaced by gl-vec4 eventually
function vec4multMat4(out,a,m){var x=a[0],y=a[1],z=a[2],w=a[3];out[0]=m[0]*x+m[4]*y+m[8]*z+m[12]*w;out[1]=m[1]*x+m[5]*y+m[9]*z+m[13]*w;out[2]=m[2]*x+m[6]*y+m[10]*z+m[14]*w;out[3]=m[3]*x+m[7]*y+m[11]*z+m[15]*w;return out;}//gets upper-left of a 4x4 matrix into a 3x3 of vectors
function mat3from4(out,mat4x4){out[0][0]=mat4x4[0];out[0][1]=mat4x4[1];out[0][2]=mat4x4[2];out[1][0]=mat4x4[4];out[1][1]=mat4x4[5];out[1][2]=mat4x4[6];out[2][0]=mat4x4[8];out[2][1]=mat4x4[9];out[2][2]=mat4x4[10];}function combine(out,a,b,scale1,scale2){out[0]=a[0]*scale1+b[0]*scale2;out[1]=a[1]*scale1+b[1]*scale2;out[2]=a[2]*scale1+b[2]*scale2;}/***/},/***/4335:/***/function(module){module.exports=function normalize(out,mat){var m44=mat[15];// Cannot normalize.
if(m44===0)return false;var scale=1/m44;for(var i=0;i<16;i++)out[i]=mat[i]*scale;return true;};/***/},/***/7442:/***/function(module,__unused_webpack_exports,__nested_webpack_require_652200__){var lerp=__nested_webpack_require_652200__(6658);var recompose=__nested_webpack_require_652200__(7182);var decompose=__nested_webpack_require_652200__(2652);var determinant=__nested_webpack_require_652200__(9921);var slerp=__nested_webpack_require_652200__(8648);var state0=state();var state1=state();var tmp=state();module.exports=interpolate;function interpolate(out,start,end,alpha){if(determinant(start)===0||determinant(end)===0)return false;//decompose the start and end matrices into individual components
var r0=decompose(start,state0.translate,state0.scale,state0.skew,state0.perspective,state0.quaternion);var r1=decompose(end,state1.translate,state1.scale,state1.skew,state1.perspective,state1.quaternion);if(!r0||!r1)return false;//now lerp/slerp the start and end components into a temporary lerp(tmptranslate, state0.translate, state1.translate, alpha)
lerp(tmp.translate,state0.translate,state1.translate,alpha);lerp(tmp.skew,state0.skew,state1.skew,alpha);lerp(tmp.scale,state0.scale,state1.scale,alpha);lerp(tmp.perspective,state0.perspective,state1.perspective,alpha);slerp(tmp.quaternion,state0.quaternion,state1.quaternion,alpha);//and recompose into our 'out' matrix
recompose(out,tmp.translate,tmp.scale,tmp.skew,tmp.perspective,tmp.quaternion);return true;}function state(){return{translate:vec3(),scale:vec3(1),skew:vec3(),perspective:vec4(),quaternion:vec4()};}function vec3(n){return[n||0,n||0,n||0];}function vec4(){return[0,0,0,1];}/***/},/***/7182:/***/function(module,__unused_webpack_exports,__nested_webpack_require_653678__){/*
Input: translation ; a 3 component vector
scale ; a 3 component vector
skew ; skew factors XY,XZ,YZ represented as a 3 component vector
perspective ; a 4 component vector
quaternion ; a 4 component vector
Output: matrix ; a 4x4 matrix
From: http://www.w3.org/TR/css3-transforms/#recomposing-to-a-3d-matrix
*/var mat4={identity:__nested_webpack_require_653678__(7894),translate:__nested_webpack_require_653678__(7656),multiply:__nested_webpack_require_653678__(6760),create:__nested_webpack_require_653678__(6864),scale:__nested_webpack_require_653678__(2504),fromRotationTranslation:__nested_webpack_require_653678__(6743)};var rotationMatrix=mat4.create();var temp=mat4.create();module.exports=function recomposeMat4(matrix,translation,scale,skew,perspective,quaternion){mat4.identity(matrix);//apply translation & rotation
mat4.fromRotationTranslation(matrix,quaternion,translation);//apply perspective
matrix[3]=perspective[0];matrix[7]=perspective[1];matrix[11]=perspective[2];matrix[15]=perspective[3];// apply skew
// temp is a identity 4x4 matrix initially
mat4.identity(temp);if(skew[2]!==0){temp[9]=skew[2];mat4.multiply(matrix,matrix,temp);}if(skew[1]!==0){temp[9]=0;temp[8]=skew[1];mat4.multiply(matrix,matrix,temp);}if(skew[0]!==0){temp[8]=0;temp[4]=skew[0];mat4.multiply(matrix,matrix,temp);}//apply scale
mat4.scale(matrix,matrix,scale);return matrix;};/***/},/***/4192:/***/function(module,__unused_webpack_exports,__nested_webpack_require_655101__){"use strict";var bsearch=__nested_webpack_require_655101__(2478);var m4interp=__nested_webpack_require_655101__(7442);var invert44=__nested_webpack_require_655101__(7608);var rotateX=__nested_webpack_require_655101__(5567);var rotateY=__nested_webpack_require_655101__(2408);var rotateZ=__nested_webpack_require_655101__(7089);var lookAt=__nested_webpack_require_655101__(6582);var translate=__nested_webpack_require_655101__(7656);var scale=__nested_webpack_require_655101__(2504);var normalize=__nested_webpack_require_655101__(3536);var DEFAULT_CENTER=[0,0,0];module.exports=createMatrixCameraController;function MatrixCameraController(initialMatrix){this._components=initialMatrix.slice();this._time=[0];this.prevMatrix=initialMatrix.slice();this.nextMatrix=initialMatrix.slice();this.computedMatrix=initialMatrix.slice();this.computedInverse=initialMatrix.slice();this.computedEye=[0,0,0];this.computedUp=[0,0,0];this.computedCenter=[0,0,0];this.computedRadius=[0];this._limits=[-Infinity,Infinity];}var proto=MatrixCameraController.prototype;proto.recalcMatrix=function(t){var time=this._time;var tidx=bsearch.le(time,t);var mat=this.computedMatrix;if(tidx<0){return;}var comps=this._components;if(tidx===time.length-1){var ptr=16*tidx;for(var i=0;i<16;++i){mat[i]=comps[ptr++];}}else{var dt=time[tidx+1]-time[tidx];var ptr=16*tidx;var prev=this.prevMatrix;var allEqual=true;for(var i=0;i<16;++i){prev[i]=comps[ptr++];}var next=this.nextMatrix;for(var i=0;i<16;++i){next[i]=comps[ptr++];allEqual=allEqual&&prev[i]===next[i];}if(dt<1e-6||allEqual){for(var i=0;i<16;++i){mat[i]=prev[i];}}else{m4interp(mat,prev,next,(t-time[tidx])/dt);}}var up=this.computedUp;up[0]=mat[1];up[1]=mat[5];up[2]=mat[9];normalize(up,up);var imat=this.computedInverse;invert44(imat,mat);var eye=this.computedEye;var w=imat[15];eye[0]=imat[12]/w;eye[1]=imat[13]/w;eye[2]=imat[14]/w;var center=this.computedCenter;var radius=Math.exp(this.computedRadius[0]);for(var i=0;i<3;++i){center[i]=eye[i]-mat[2+4*i]*radius;}};proto.idle=function(t){if(t